home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / vbnetroundrect.vb < prev    next >
Encoding:
Text File  |  2004-07-15  |  24.5 KB  |  629 lines

  1. '******************************************************************'
  2. '*                                                                *'
  3. '*                      TurboCAD for Windows                      *'
  4. '*                   Copyright (c) 1993 - 2004                    *'
  5. '*             International Microcomputer Software, Inc.         *'
  6. '*                            (IMSI)                              *'
  7. '*                      All rights reserved.                      *'
  8. '*                                                                *'
  9. '******************************************************************'
  10. Public Class VBNETRoundRect
  11.     Const gkGraphic As Integer = 11
  12.     Const gkArc As Integer = 2
  13.     Const gkText As Integer = 6
  14.     Const gfCosmetic As Integer = 128
  15.  
  16.     'Useful math constants
  17.     Const Pi# = 3.14159265
  18.  
  19.     'Real variant types!
  20.     Const typeEmpty As Integer = 0
  21.     Const typeInteger As Integer = 2
  22.     Const typeLong As Integer = 3
  23.     Const typeSingle As Integer = 4
  24.     Const typeDouble As Integer = 5
  25.     Const typeCurrency As Integer = 6
  26.     Const typeDate As Integer = 7
  27.     Const typeString As Integer = 8
  28.     Const typeObject As Integer = 9
  29.     Const typeBoolean As Integer = 11
  30.     Const typeVariant As Integer = 12
  31.     Const typeIntegerEnum As Integer = typeInteger + 100
  32.     Const typeLongEnum As Integer = typeLong + 100
  33.     Const typeStringEnum As Integer = typeString + 100
  34.  
  35.     'Stock property pages
  36.     Const ppStockPen As Integer = 1
  37.     Const ppStockBrush As Integer = 2
  38.     Const ppStockText As Integer = 4
  39.     Const ppStockInsert As Integer = 8
  40.     Const ppStockViewport As Integer = 16
  41.     Const ppStockAuto As Integer = 32
  42.  
  43.     'Property Ids
  44.     Const idRoundness As Integer = 1
  45.     Const idBeginColor As Integer = 2
  46.     Const idEndColor As Integer = 3
  47.     Const idGradientMode As Integer = 4
  48.  
  49.     'Property enums
  50.  
  51.     'Number of properties, pages, wizards
  52.     Const NUM_PROPERTIES As Integer = 4
  53.     Const NUM_PAGES As Integer = 1
  54.     Const NUM_WIZARDS As Integer = 0
  55.  
  56.     Dim m_RRectPropertyPage As frmRRect
  57.     Dim m_MyFill As GradientFill
  58.     Dim m_LB As Drawing.Drawing2D.LinearGradientBrush
  59.     Dim m_rRect As New Drawing.Rectangle
  60.     Public Function Description() As String
  61.         Description = "SDK VB NET RoundRectangle (VB NET sample)"
  62.     End Function
  63.  
  64.     'Returns the persistent class id for this RegenMethod's property section
  65.     Public Function ClassID() As String
  66.         ClassID = "{0B5266B5-9EC0-446A-8A97-EFED748B2803}"
  67.     End Function
  68.  
  69.     'Retrieve types and names
  70.     Public Function GetPropertyInfo(ByRef Names As Object, ByRef Types As Object, _
  71.     ByRef IDs As Object, ByRef Defaults As Object) As Integer
  72.         '        ReDim Names(NUM_PROPERTIES), Types(NUM_PROPERTIES), _
  73.         '           IDs(NUM_PROPERTIES), Defaults(NUM_PROPERTIES)
  74.         Dim strNames(NUM_PROPERTIES - 1) As String
  75.         Dim intTypes(NUM_PROPERTIES - 1) As Integer
  76.         Dim intIds(NUM_PROPERTIES - 1) As Integer
  77.         Dim dblDefaults(NUM_PROPERTIES - 1) As Object
  78.         Dim retVal As Integer
  79.  
  80.         strNames(0) = "Roundness"
  81.         intTypes(0) = typeDouble
  82.         intIds(0) = idRoundness
  83.         dblDefaults(0) = 0.0#
  84.  
  85.         strNames(1) = "BeginColor"
  86.         intTypes(1) = typeInteger
  87.         intIds(1) = idBeginColor
  88.         dblDefaults(1) = 0
  89.  
  90.         strNames(2) = "EndColor"
  91.         intTypes(2) = typeInteger
  92.         intIds(2) = idEndColor
  93.         dblDefaults(2) = 16777215
  94.  
  95.         strNames(3) = "GradientMode"
  96.         intTypes(3) = typeInteger
  97.         intIds(3) = idGradientMode
  98.         dblDefaults(3) = 0
  99.  
  100.         Names = strNames
  101.         Types = intTypes
  102.         IDs = intIds
  103.         Defaults = dblDefaults
  104.  
  105.         retVal = NUM_PROPERTIES
  106.         GetPropertyInfo = retVal
  107.     End Function
  108.  
  109.     'Get the number of property pages supporting this RegenMethod
  110.     Public Function GetPageInfo(ByVal AGraphic As Object, ByRef StockPages As Integer, _
  111.     ByRef Names As Object) As Integer
  112.         '        ReDim Names(NUM_PAGES)
  113.         Dim strNames(NUM_PAGES) As String
  114.  
  115.         strNames(0) = m_RRectPropertyPage.Text
  116.         StockPages = ppStockBrush + ppStockPen + ppStockAuto
  117.         Names = strNames
  118.         GetPageInfo = NUM_PAGES
  119.         Exit Function
  120.  
  121.         StockPages = ppStockBrush + ppStockPen + ppStockAuto
  122.         GetPageInfo = NUM_PAGES
  123.     End Function
  124.  
  125.     Public Function GetWizardInfo(ByVal Names As Object) As Long
  126.         ReDim Names(NUM_WIZARDS)
  127.         GetWizardInfo = NUM_WIZARDS
  128.     End Function
  129.  
  130.     'Enumerate the names and values of a specified property
  131.     Public Function GetEnumNames(ByVal PropID As Long, ByVal Names As Object, ByVal Values As Object) As Integer
  132.         GetEnumNames = 0
  133.     End Function
  134.  
  135.     Public Function PageControls(ByVal ThisRegenMethod As Object, ByVal Graphic As Object, ByVal PageNumber As Integer, ByVal SaveProperties As Boolean) As Boolean
  136.         'Set up error function
  137.         On Error GoTo Failed
  138.         Dim gxProp As IMSIGX.Property
  139.         Dim Roundness#
  140.         Dim BeginColor As Drawing.Color
  141.         Dim EndColor As Drawing.Color
  142.         Dim GradientMode As Drawing.Drawing2D.LinearGradientMode
  143.         Dim mbMode As Drawing.Drawing2D.LinearGradientMode
  144.         Dim mBeginColor As Drawing.Color
  145.         Dim mEndColor As Drawing.Color
  146.         Dim mGradientMode As Drawing.Drawing2D.LinearGradientMode
  147.  
  148.  
  149.  
  150.         If SaveProperties Then
  151.             'OK button on property page was clicked
  152.             'Form is still loaded
  153.             With m_RRectPropertyPage
  154.                 'Need On Error statement for the case where you have
  155.                 'RRect Turbo Shape and ahother "shape" selected
  156.                 On Error Resume Next
  157.  
  158.                 'When the property page is closed, transfer the numeric
  159.                 'roundness value from the TextBox to the Graphic
  160.                 'Get the value as a double-precision number
  161.                 Roundness# = CDbl(.tbRoundness.Text)
  162.                 mBeginColor = .cmColor1.BackColor
  163.                 mEndColor = .cmColor2.BackColor
  164.                 mGradientMode = .cModesCombo.SelectedIndex
  165.                 'Make sure it's between 0 and 100
  166.                 If Roundness# < 0.0# Then Roundness# = 0.0#
  167.                 If Roundness# > 100.0# Then Roundness# = 100.0#
  168.                 'Set the roundness property value in the Graphic
  169.                 gxProp = Graphic.Properties("Roundness")
  170.                 gxProp.Value = Roundness#
  171.                 gxProp = Graphic.Properties("BeginColor")
  172.                 gxProp.Value = Drawing.ColorTranslator.ToWin32(mBeginColor)
  173.                 gxProp = Graphic.Properties("EndColor")
  174.                 gxProp.Value = Drawing.ColorTranslator.ToWin32(mEndColor)
  175.                 gxProp = Graphic.Properties("GradientMode")
  176.                 gxProp.Value = mGradientMode
  177.             End With
  178.         Else
  179.             'Property page is about to be opened
  180.             'Make sure the form is loaded
  181.             ''  Load(frmRRect)
  182.             With m_RRectPropertyPage
  183.                 'If more than one RRect is selected and they do not
  184.                 'have the same properties, don't set up this field
  185.                 On Error GoTo NoRType
  186.  
  187.                 'When the property page is opening, transfer the numeric
  188.                 'roundness value from the Graphic to the TextBox
  189.                 'Get the roundness property value from the Graphic
  190.                 gxProp = Graphic.Properties("Roundness")
  191.                 Roundness# = gxProp.Value
  192.                 'Set the TextBox control's text
  193.                 .tbRoundness.Text = Roundness#
  194.                 gxProp = Graphic.Properties("BeginColor")
  195.                 mBeginColor = Drawing.ColorTranslator.FromWin32(gxProp.Value)
  196.                 gxProp = Graphic.Properties("EndColor")
  197.                 mEndColor = Drawing.ColorTranslator.FromWin32(gxProp.Value)
  198.                 gxProp = Graphic.Properties("GradientMode")
  199.                 mGradientMode = gxProp.Value
  200.  
  201.                 .cmColor1.BackColor = mBeginColor
  202.                 .cmColor2.BackColor = mEndColor
  203.                 .cModesCombo.SelectedIndex = mGradientMode
  204.  
  205. NoRType:
  206.             End With
  207.         End If
  208.  
  209.         PageControls = True
  210.         Exit Function
  211.  
  212. Failed:
  213.         'For debugging purposes, report that an error occurred
  214.         If Err.Number <> 0 Then
  215.             MsgBox("Error in PageControls: " & Err.Description)
  216.         End If
  217.  
  218.         'Return false if an error occurred
  219.         PageControls = False
  220.     End Function
  221.  
  222.     Public Function PageDone(ByVal ThisRegenMethod As Object, ByVal PageNumber As Object)
  223.         'Done with form
  224.         ''Unload(frmRRect)
  225.     End Function
  226.  
  227.     Public Function PropertyPages(ByVal ThisRegenMethod As Object, Optional ByVal PageNumber As Object = 0) As Boolean
  228.         m_RRectPropertyPage.ShowDialog()
  229.         PropertyPages = Not m_RRectPropertyPage.bCanceled
  230.     End Function
  231.  
  232.     Public Function Wizard(ByVal ThisRegenMethod As Object, Optional ByVal WizardNumber As Object = 0) As Boolean
  233.         Wizard = False
  234.     End Function
  235.  
  236.     'Called when vertex has been moved, or other geometry change
  237.     Public Function OnGeometryChanged(ByVal Graphic As Object, ByVal GeomID As Long, ByVal paramOld As Object, ByVal paramNew As Object)
  238.         'Do nothing
  239.         'Regen Graphic
  240.     End Function
  241.  
  242.     'Called when vertex is moved, or other geometry change
  243.     Public Function OnGeometryChanging(ByVal Graphic As Object, ByVal GeomID As Long, ByVal paramOld As Object, ByVal paramNew As Object) As Boolean
  244.         'OK to continue with change
  245.         OnGeometryChanging = True
  246.     End Function
  247.  
  248.     Public Function OnNewGraphic(ByVal grfThis As Object, ByVal boolCopy As Boolean) As Boolean
  249.         If boolCopy Then
  250.             'Vertices are already added for us...
  251.             OnNewGraphic = True
  252.             Exit Function
  253.         End If
  254.  
  255.         On Error GoTo Failed
  256.         'New Graphic being created
  257.         'X, Y, Z, PenDown, Selectable, Snappable, Editable, Linkable
  258.         'First Vertex is "lower left" corner
  259.         grfThis.Vertices.Add(-1.0#, -0.5, 0.0#, False, True, False, False, False)
  260.         'Second Vertex is "upper right" corner
  261.         grfThis.Vertices.Add(1.0#, 0.5, 0.0#, False, True, False, False, False)
  262.         'Third Vertex is rounding handle (calculated)
  263.         Dim R#, Roundness#, Offset#
  264.         Dim P As IMSIGX.Property
  265.         P = grfThis.Properties("Roundness")
  266.         Roundness# = P.Value
  267.         P = Nothing
  268.         R# = 0.5 * Roundness# / 100.0#
  269.         Offset# = 0.1 * R#
  270.         grfThis.Vertices.Add(1.0# - R#, 0.5 + Offset#, 0.0#, False, False, False, False, False)
  271.         'Fourth Vertex is rounding handle (editable)
  272.         grfThis.Vertices.Add(1.0# - R#, 0.5 + Offset#, 0.0#, False, True, False, True, False)
  273.         grfThis.Properties("LimitVertices") = 4
  274.         OnNewGraphic = True
  275.         Exit Function
  276.  
  277. Failed:
  278.         'Return false on failure
  279.         OnNewGraphic = False
  280.     End Function
  281.  
  282.     'Function called whenever a copy of a graphic is being made
  283.     Public Function OnCopyGraphic(ByVal grfCopy As Object, ByVal grfSource As Object) As Boolean
  284.         'Return false on failure
  285.         OnCopyGraphic = True
  286.     End Function
  287.  
  288.     'Notification function called after graphic property is saved
  289.     Public Function OnPropertyChanged(ByVal Graphic As Object, ByVal PropID As Long, _
  290.     ByVal ValueOld As Object, ByVal ValueNew As Object)
  291.         'Do nothing
  292.     End Function
  293.  
  294.     'Notification function called when graphic property is saved
  295.     Public Function OnPropertyChanging(ByVal Graphic As Object, ByVal PropID As Long, _
  296.     ByVal ValueOld As Object, ByVal ValueNew As Object) As Boolean
  297.         'OK to proceed
  298.         OnPropertyChanging = True
  299.     End Function
  300.  
  301.     'Notification function called when graphic property is retrieved
  302.     Public Function OnPropertyGet(ByVal Graphic As Object, ByVal PropID As Long)
  303.         'Do nothing
  304.     End Function
  305.  
  306.     'Called when we need to update our object
  307.     Public Function Regen(ByVal grfThis As Object)
  308.         'Setup error handler
  309.         On Error GoTo Failed
  310.  
  311.         'Set up lock (prevent recursion)
  312.         Dim LockCount&
  313.         LockCount& = grfThis.RegenLock
  314.  
  315.         'Setup error handler (make sure lock is removed)
  316.         On Error GoTo FailedLock
  317.         If LockCount& = 0 Then
  318.             'Delete any previous cosmetic children
  319.             grfThis.Graphics.Clear(gfCosmetic)
  320.  
  321.             Dim boolHandleMoved As Boolean
  322.  
  323.  
  324.             'Calculate height, width and radius of corners
  325.             Dim W#, H#, R#, Roundness#
  326.             With grfThis.Vertices
  327.                 If (Math.Abs(.Item(2).X - .Item(3).X) < 0.000001 And _
  328.                     Math.Abs(.Item(2).Y - .Item(3).Y) < 0.000001) Then
  329.                     boolHandleMoved = False
  330.                 Else
  331.                     boolHandleMoved = True
  332.                 End If
  333.                 W# = Math.Abs(.Item(1).X - .Item(0).X)
  334.                 H# = Math.Abs(.Item(1).Y - .Item(0).Y)
  335.             End With
  336.             'Radius of arcs is based on minimum of width and height
  337.             If W# < H# Then
  338.                 R# = W# / 2.0#
  339.             Else
  340.                 R# = H# / 2.0#
  341.             End If
  342.             'Adjust radius for roundness
  343.             If boolHandleMoved Then
  344.                 Roundness# = Math.Abs(grfThis.Vertices(2).X - grfThis.Vertices(3).X)
  345.                 Roundness# = Roundness# * 100.0# / R#
  346.                 If Roundness# > 100.0# Then Roundness# = 100.0#
  347.                 'Relocate handle
  348.  
  349.                 'Update property to reflect handle location
  350.                 Dim P As IMSIGX.Property
  351.                 P = grfThis.Properties("Roundness")
  352.                 grfThis.Properties("Roundness") = Roundness#
  353.                 P.Value = Roundness#
  354.                 P = Nothing
  355.             Else
  356.                 Dim P As IMSIGX.Property
  357.                 P = grfThis.Properties("Roundness")
  358.                 P = grfThis.Properties("Roundness")
  359.                 Roundness# = P.Value
  360.                 P = Nothing
  361.                 If Roundness# < 0.0# Then Roundness# = 0.0#
  362.                 If Roundness# > 100.0# Then Roundness# = 100.0#
  363.             End If
  364.             R# = R# * Roundness# / 100.0#
  365.  
  366.             'Add child Graphics
  367.             Dim grfChild As Object
  368.             Dim X0#, Y0#, X1#, Y1#, T#
  369.             With grfThis.Vertices
  370.                 X0# = .Item(0).X
  371.                 Y0# = .Item(0).Y
  372.                 X1# = .Item(1).X
  373.                 Y1# = .Item(1).Y
  374.                 'Make sure X0 < X1
  375.                 If (X0# > X1#) Then
  376.                     T# = X0#
  377.                     X0# = X1#
  378.                     X1# = T#
  379.                 End If
  380.                 'Make sure Y0 < Y1
  381.                 If (Y0# > Y1#) Then
  382.                     T# = Y0#
  383.                     Y0# = Y1#
  384.                     Y1# = T#
  385.                 End If
  386.             End With
  387.             If R# = 0.0# Then
  388.                 'No rounded corners
  389.                 'All children are cosmetic
  390.                 grfChild = grfThis.Graphics.Add(gkGraphic)
  391.                 grfChild.Cosmetic = True
  392.                 'Now add vertices to the child
  393.                 With grfChild.Vertices
  394.                     .Add(X0#, Y0#, 0)
  395.                     .Add(X0#, Y1#, 0, True)
  396.                     .Add(X1#, Y1#, 0, True)
  397.                     .Add(X1#, Y0#, 0, True)
  398.                     'Close the rectangle
  399.                     .AddClose(PenDown:=True) 'PenDown
  400.                 End With
  401.             Else
  402.                 'Rounded corners
  403.                 'We'll make 4 line children and 4 arc children
  404.                 'First line
  405.                 'All children are cosmetic
  406.                 grfChild = grfThis.Graphics.Add(gkGraphic)
  407.                 grfChild.Cosmetic = True
  408.                 'Now add vertices to the child
  409.                 With grfChild.Vertices
  410.                     .Add(X0# + R#, Y0#, 0)
  411.                     .Add(X1# - R#, Y0#, 0, True)
  412.                 End With
  413.                 'First arc
  414.                 grfChild = grfThis.Graphics.Add(gkArc)
  415.                 grfChild.Cosmetic = True
  416.                 grfChild.ArcSet(X1# - R#, Y0# + R#, 0.0#, R#, , 1.5 * Pi#, 0.0#)
  417.                 'Second line
  418.                 grfChild = grfThis.Graphics.Add(gkGraphic)
  419.                 grfChild.Cosmetic = True
  420.                 With grfChild.Vertices
  421.                     .Add(X1#, Y0# + R#, 0)
  422.                     .Add(X1#, Y1# - R#, 0, True)
  423.                 End With
  424.                 'Second arc
  425.                 grfChild = grfThis.Graphics.Add(gkArc)
  426.                 grfChild.Cosmetic = True
  427.                 grfChild.ArcSet(X1# - R#, Y1# - R#, 0.0#, R#, , 0.0#, 0.5 * Pi#)
  428.                 'Third line
  429.                 grfChild = grfThis.Graphics.Add(gkGraphic)
  430.                 grfChild.Cosmetic = True
  431.                 With grfChild.Vertices
  432.                     .Add(X1# - R#, Y1#, 0)
  433.                     .Add(X0# + R#, Y1#, 0, True)
  434.                 End With
  435.                 'Third arc
  436.                 grfChild = grfThis.Graphics.Add(gkArc)
  437.                 grfChild.Cosmetic = True
  438.                 grfChild.ArcSet(X0# + R#, Y1# - R#, 0.0#, R#, , 0.5 * Pi#, Pi#)
  439.                 'Fourth line
  440.                 grfChild = grfThis.Graphics.Add(gkGraphic)
  441.                 grfChild.Cosmetic = True
  442.                 With grfChild.Vertices
  443.                     .Add(X0#, Y1# - R#, 0)
  444.                     .Add(X0#, Y0# + R#, 0, True)
  445.                 End With
  446.                 'Fourth arc
  447.                 grfChild = grfThis.Graphics.Add(gkArc)
  448.                 grfChild.Cosmetic = True
  449.                 grfChild.ArcSet(X0# + R#, Y0# + R#, 0.0#, R#, , Pi#, 1.5 * Pi#)
  450.             End If
  451.  
  452.             'Add visible child Graphics
  453.         End If
  454.  
  455.         grfThis.RegenUnlock()
  456.         Exit Function
  457.  
  458. FailedLock:
  459.         'Remove lock
  460.         grfThis.RegenUnlock()
  461.  
  462. Failed:
  463.         'grfThis.Application.PopVertexDefaults
  464.  
  465.         If Err.Number <> 0 Then
  466.             '            MsgBox "Regen error: " & Err.Description
  467.         End If
  468.     End Function
  469.  
  470.     Public Function Draw(ByVal grfThis As Object, ByVal view As Object, Optional ByVal mat As Object = Nothing) As Boolean
  471.         'Return True if we did the redraw (no further processing necessary, no children will be drawn).
  472.         'Since this is just a test, we return False to let TurboCAD do the drawing operation.
  473.         Dim gxProp As IMSIGX.Property
  474.         Dim cBegin As Drawing.Color
  475.         Dim cEnd As Drawing.Color
  476.         Dim iMode As Drawing.Drawing2D.LinearGradientMode
  477.         Draw = False
  478.         If view.SpaceMode = IMSIGX.ImsiSpaceModeType.imsiModelSpace Then
  479.             '           for model space it is required additional programming (process matrix etc)
  480.             Exit Function
  481.         End If
  482.         gxProp = grfThis.Properties("BeginColor")
  483.         cBegin = Drawing.ColorTranslator.FromWin32(gxProp.Value)
  484.         gxProp = grfThis.Properties("EndColor")
  485.         cEnd = Drawing.ColorTranslator.FromWin32(gxProp.Value)
  486.         gxProp = grfThis.Properties("GradientMode")
  487.         iMode = gxProp.Value
  488.  
  489.         m_MyFill.FillRoundRectWithLinearGradient(grfThis, view, cBegin, cEnd, iMode)
  490.     End Function
  491.     Private Class GradientFill
  492.  
  493.         Public Shared Function GetScreenCords(ByVal gxView As IMSIGX.View, ByVal V As IMSIGX.Vertex, ByRef X As Double, ByRef y As Double)
  494.             Dim XW As Double, yW As Double, xV As Double, yV As Double
  495.             XW = V.X
  496.             yW = V.Y
  497.             gxView.WorldToView(XW, yW, 0, xV, yV, 0)
  498.             gxView.ViewToScreen(xV, yV, X, y)
  499.         End Function
  500.         Public Shared Function GetScreenCordsEx(ByVal gxView As IMSIGX.View, ByVal xW As Double, ByVal yW As Double, ByRef X As Double, ByRef y As Double)
  501.             Dim xV As Double, yV As Double
  502.             gxView.WorldToView(xW, yW, 0, xV, yV, 0)
  503.             gxView.ViewToScreen(xV, yV, X, y)
  504.         End Function
  505.         Public Shared Function FillRoundRectWithLinearGradient(ByVal Gr As IMSIGX.IGraphic, ByVal gxView As IMSIGX.View, ByVal BeginColor As Drawing.Color, ByVal EndColor As Drawing.Color, ByVal GradientMode As Drawing.Drawing2D.LinearGradientMode)
  506.             Dim gxVert As IMSIGX.Vertex
  507.             Dim P1 As New Drawing.Point
  508.             Dim P2 As New Drawing.Point
  509.             Dim P3 As New Drawing.Point
  510.             Dim Ps(7) As Drawing.Point
  511.             Dim Grs As System.Drawing.Graphics
  512.             Dim gxGr As IMSIGX.Graphic
  513.             Dim gxGrTmp As IMSIGX.Graphic
  514.             Dim hW As Long
  515.             Dim hWP As System.IntPtr
  516.             '            Dim n As Long
  517.  
  518.             On Error GoTo ErrH
  519.             If Gr Is Nothing Then
  520.                 Exit Function
  521.             End If
  522.             If gxView Is Nothing Then
  523.                 Exit Function
  524.             End If
  525.             'Dim i As Integer
  526.             'i = 0
  527.             Dim xS As Double, yS As Double
  528.  
  529.             Dim curInd As Integer
  530.             curInd = 0
  531.             Dim bUseWorldCS = False
  532.             Dim P As IMSIGX.Property
  533.             P = Gr.Properties("Roundness")
  534.             If P.Value > 0 Then
  535.                 For Each gxGrTmp In Gr.Graphics
  536.                     If gxGrTmp.TypeByValue = gkGraphic Then
  537.                         bUseWorldCS = gxGrTmp.Vertices.UseWorldCS
  538.                         gxGrTmp.Vertices.UseWorldCS = True
  539.                         GetScreenCords(gxView, gxGrTmp.Vertices(0), xS, yS)
  540.                         P1.X = xS
  541.                         P1.Y = yS
  542.                         Ps(curInd) = P1
  543.                         curInd = curInd + 1
  544.                         GetScreenCords(gxView, gxGrTmp.Vertices(1), xS, yS)
  545.                         P2.X = xS
  546.                         P2.Y = yS
  547.                         Ps(curInd) = P2
  548.                         curInd = curInd + 1
  549.                         gxGrTmp.Vertices.UseWorldCS = bUseWorldCS
  550.                     ElseIf gxGrTmp.TypeByValue = gkArc Then
  551.                         ' Add your code here to process arc segments
  552.  
  553.                     End If
  554.                 Next
  555.             Else
  556.                 ' in this case we have only one cosmetic - polyline
  557.                 For Each gxGrTmp In Gr.Graphics
  558.                     If gxGrTmp.TypeByValue = 11 Then
  559.                         bUseWorldCS = gxGrTmp.Vertices.UseWorldCS
  560.                         gxGrTmp.Vertices.UseWorldCS = True
  561.                         For Each gxVert In gxGrTmp.Vertices
  562.                             GetScreenCords(gxView, gxGrTmp.Vertices(curInd), xS, yS)
  563.                             P1.X = xS
  564.                             P1.Y = yS
  565.                             Ps(curInd) = P1
  566.                             curInd = curInd + 1
  567.                         Next
  568.                         gxGrTmp.Vertices.UseWorldCS = bUseWorldCS
  569.                     End If
  570.                 Next
  571.  
  572.             End If
  573.  
  574.             hW = gxView.HWND
  575.             Dim bDC As Boolean
  576.             bDC = False
  577.             If hW = 0 Then
  578.                 hW = gxView.DC
  579.                 If hW = 0 Then
  580.                     Exit Function
  581.                 End If
  582.                 bDC = True
  583.             End If
  584.             hWP = New System.IntPtr(hW)
  585.  
  586.             If bDC Then
  587.                 Grs = System.Drawing.Graphics.FromHdc(hWP)
  588.             Else
  589.                 Grs = System.Drawing.Graphics.FromHwnd(hWP)
  590.             End If
  591.  
  592.             Grs.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
  593.             Grs.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
  594.             Dim Bb As IMSIGX.BoundingBox
  595.             Bb = Gr.CalcBoundingBox()
  596.             Dim xBMin As Double, yBMin As Double, xBMax As Double, yBMax As Double
  597.             GetScreenCordsEx(gxView, Bb.Min.X, Bb.Min.Y, P1.X, P1.Y)
  598.             GetScreenCordsEx(gxView, Bb.Max.X, Bb.Max.Y, P3.X, P3.Y)
  599.             Bb = Nothing
  600.             Dim myBBRect As New Drawing.Rectangle(P1.X, P3.Y, Math.Abs(P3.X - P1.X), Math.Abs(P3.Y - P1.Y))
  601.             Dim pG3 As New Drawing.Drawing2D.LinearGradientBrush(myBBRect, BeginColor, EndColor, GradientMode)
  602.             pG3.GammaCorrection = True
  603.             Grs.FillPolygon(pG3, Ps)
  604.  
  605.             myBBRect = Nothing
  606.             pG3.Dispose()
  607.             Grs.Dispose()
  608.             Exit Function
  609. ErrH:
  610.             '            i = 1
  611.  
  612.         End Function
  613.  
  614.     End Class
  615.  
  616.     Public Sub New()
  617.         m_RRectPropertyPage = New frmRRect
  618.         m_MyFill = New GradientFill
  619.         Dim m_rRect As New Drawing.Rectangle
  620.         Dim m_bMode As Drawing.Drawing2D.LinearGradientMode
  621.  
  622.     End Sub
  623.  
  624.     Protected Overrides Sub Finalize()
  625.  
  626.         MyBase.Finalize()
  627.     End Sub
  628. End Class
  629.