ArcObjects Style of a symbol chosen with the ISymbolSelector interface

المشرف العام

Administrator
طاقم الإدارة
I am trying to store the properties of a SimpleMarkerSymbol symbol selected by the user using the ISymbolSelector interface.

I plan to store the size, colour and style number in a file.

I can get the size and colour of the selected symbol but cannot locate the style.

If the user selects one of the Simple Marker Symbols without changing the size or colour then my code works. If they change anything, the code cannot find the style in the style gallery.

Even though I modify the Style gallery enumeration so that they have the same size and colour as the chosen symbol the clone test fails.

Is there any other way of doing this?

Here is my code:

Dim sError As String Dim pSymbolSelector As ISymbolSelector Dim pMarker As ISimpleMarkerSymbol Dim pColour As IColor Dim pCol As System.Drawing.Color Dim iColour As Integer Dim sName As String = "" Dim dSize As Double Dim sStartEnd As String = comboStEnd.Text Dim iStyle As Integer = -1 Dim pSymbol As ISymbol Dim pMSym As IMarkerSymbol Dim pStyleStorage As IStyleGalleryStorage Dim pStyleGallery As IStyleGallery Dim pMxDoc As IMxDocument Dim pEnumStyleGall As IEnumStyleGalleryItem Dim pStyleItem As IStyleGalleryItem Dim pMarkerSym As IMarkerSymbol Dim pMSymClone As IClone Dim pMarkerClone As IClone Try sError = "" StatusLabel1.Text = "" If String.IsNullOrEmpty(sStartEnd) Then StatusLabel1.Text = "Please choose Start or End" Exit Sub End If pSymbolSelector = New SymbolSelector pMarker = New SimpleMarkerSymbol If Not pSymbolSelector.AddSymbol(pMarker) Then Exit Sub ElseIf pSymbolSelector.SelectSymbol(0) Then pSymbol = pSymbolSelector.GetSymbolAt(0) pMSym = TryCast(pSymbol, IMarkerSymbol) If pMSym Is Nothing Then Exit Sub dSize = pMSym.Size pColour = pMSym.Color pCol = New System.Drawing.Color pCol = modMain.colourESRItoMS(pColour, sError) If sError.Length > 0 Then sError = "cmdChoose;" & vbCrLf & sError MsgBox(sError) Exit Sub End If iColour = pCol.ToArgb pMSymClone = CType(pMSym, IClone) ' Get the symbol style pMxDoc = m_pApp.Document pStyleGallery = pMxDoc.StyleGallery pStyleStorage = pStyleGallery pEnumStyleGall = pStyleGallery.Items("Marker Symbols", "ESRI.Style", "Default") pEnumStyleGall.Reset() pStyleItem = pEnumStyleGall.Next While pStyleItem IsNot Nothing pMarkerSym = pStyleItem.Item pMarkerSym.Size = dSize pMarkerSym.Color = pColour pMarkerClone = CType(pMarkerSym, IClone) If pMSymClone.IsEqual(pMarkerClone) Then ' True if pMSym has not been modifed for size or colour sName = pStyleItem.Name iStyle = pStyleItem.ID Exit While End If pStyleItem = pEnumStyleGall.Next End While End If Catch ex As Exception sError = "ERROR: cmdChoose; Line: " & Erl() & vbCrLf & ex.ToString MsgBox(sError) End Try

أكثر...
 
أعلى