I can't seem to find anyone else with this problem, but I'm hoping maybe I'm missing something obvious!
I am writing an Editor Extension add-in using VB.net for ArcMap 10. The feature layer I'm rendering is from an SDE dataset.
Once the user starts editing, I use a unique value renderer to display features, omitting some (the client wants features they have classified as 'inactive' to disappear - without being deleted - and my understanding is that a definition query won't work in an edit session, so I have modified the symbology instead).
After I set the renderer, I want the display to refresh to show the new symbology. However, ActiveView.Refresh, ActiveView.PartialRefresh, and ScreenDisplay.Invalidate will not work. There is no error, but the screen does not refresh. I have stepped through using the debugger and confirmed that the program execution does reach those lines, but after 'executing' those lines nothing happens. The TOC updates properly, but the view does not. I can manually click the refresh button and it refreshes just fine, but I can't seem to make it work programmatically.
I have tried brute forcing it by using ActiveView.Deactivate followed by ActiveView.Activate, and this does cause a screen refresh, but then when I try to draw the point, the mouse pointer and the marker symbol indicating the potential location of the new point are offset by about 4 inches.
I'm completely at a loss here. Any ideas?
I've included an exerpt from my code below (this is done nearly identically for 4 feature layers, so normally the select case would have 3 more entries, but I simplified it for this post). Thanks!!
'define the colors to use in the renderers
Dim pOutlineColor As New ESRI.ArcGIS.Display.RgbColor
Dim pStructureColor As New ESRI.ArcGIS.Display.RgbColor
'make the structure outline color black
pOutlineColor.Red = 0
pOutlineColor.Blue = 0
pOutlineColor.Green = 0
'make the structure center color macaw green
pStructureColor.Red = 152
pStructureColor.Blue = 0
pStructureColor.Green = 230
'create the symbols
Dim pStructureSymbol As New ESRI.ArcGIS.Display.SimpleMarkerSymbol
'construct the structures symbol
pStructureSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
pStructureSymbol.Size = 4
pStructureSymbol.Outline = True
pStructureSymbol.OutlineSize = 1
pStructureSymbol.OutlineColor = pOutlineColor
pStructureSymbol.Color = pStructureColor
'define renderers
Dim pStructureRenderer As New ESRI.ArcGIS.Carto.UniqueValueRenderer
'set the fields used in the renderers - we'll just have one, the 'Active' field
'set usedefaultsymbol to false so that inactive features
'will not draw (i.e., if Active <> 1 or Null)
'structures renderer
With pStructureRenderer
.FieldCount = 1
.Field(0) = "Active"
.UseDefaultSymbol = False
'add "1" to the value list for the renderer - i.e., display "1" values using pStructureSymbol
.AddValue("1", "Active", pStructureSymbol)
.Label("1") = "Active"
'add "<Null>" to the value list for the renderer using the same symbology as "1"
.AddReferenceValue("<Null>", "1")
'tell it we're using our own custom style
.ColorScheme = "Custom"
'tell it the field type for the 'Active' field is not a string (it's an integer)
.FieldType(0) = False
End With
Dim pLayer As ESRI.ArcGIS.Carto.ILayer
Dim pFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer2
Dim pGeoFeatureLayerStructures As ESRI.ArcGIS.Carto.IGeoFeatureLayer
'this makes the layer properties symbology tab show
'the correct interface.
Dim pPropertyPage As ESRI.ArcGIS.CartoUI.IRendererPropertyPage
pPropertyPage = New ESRI.ArcGIS.CartoUI.UniqueValuePropertyPage
Do Until pLayer Is Nothing
If TypeOf (pLayer) Is ESRI.ArcGIS.Carto.IFeatureLayer2 Then
pFeatureLayer = pLayer
If pFeatureLayer.FeatureClass.FindField("Active") > 0 Then 'only set the renderer if there is an 'active' field in the layer
Select Case pFeatureLayer.FeatureClass.AliasName
Case strStructuresLayerName
pGeoFeatureLayerStructures = pFeatureLayer
pGeoFeatureLayerStructures.Renderer = pStructureRenderer
pGeoFeatureLayerStructures.DisplayField = "Active"
pGeoFeatureLayerStructures.RendererPropertyPageClassID = pPropertyPage.ClassID
End Select
End If
pFeatureLayer = Nothing
End If
pLayer = pEnumLayers.Next
Loop
My.Document.ActiveView.ContentsChanged()
My.Document.UpdateContents()
My.Document.ActiveView.Refresh() 'this does nothing
'This also does nothing:
'My.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewAll, Nothing, pActiveView.Extent)
'This also does nothing:
'My.ThisApplication.Display.Invalidate(My.Document.ActiveView.Extent, False, ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache)
'this makes the screen go blank:
'Dim pMaps As ESRI.ArcGIS.Carto.IMaps
'pMaps = My.Document.Maps
'My.Document.ActiveView = My.Document.PageLayout
'My.Document.ActiveView = pMaps.Item(0)
'My.Document.ActiveView.Refresh()
'this makes the cursor and the point to be drawn offset by about 4 inches:
'Dim pActiveView As ESRI.ArcGIS.Carto.IActiveView
'pActiveView = My.Document.FocusMap
'pActiveView.Deactivate()
'pActiveView.Activate(My.ThisApplication.Display.hWnd)
-
Hi @RZeckoski. Welcome to GIS SE! What happens when you hit the refresh button in ArcMap after your extension finishes refreshing. (When you are expecting to see the features).Jakub Sisak GeoGraphics– Jakub Sisak GeoGraphics2012年04月26日 15:11:44 +00:00Commented Apr 26, 2012 at 15:11
-
Thanks! If I hit the refresh button in ArcMap after the extension finishes the rendering and supposedly finishes refreshing, it works just fine - my new symbology is displayed in the view. I just can't seem to convince it to refresh through the code.BeckyZ– BeckyZ2012年04月26日 15:58:00 +00:00Commented Apr 26, 2012 at 15:58
-
do two partial refreshs, using geoselection and geodata as a phase param.George Silva– George Silva2012年04月26日 21:27:08 +00:00Commented Apr 26, 2012 at 21:27
-
Thanks for that suggestion, unfortunately that does not work either. I currently have an issue open with ESRI support, if they come up with a solution I will post it here.BeckyZ– BeckyZ2012年04月30日 15:10:00 +00:00Commented Apr 30, 2012 at 15:10
2 Answers 2
You might need to reference the active view of the ArcMap document via iMXDocument. Try this:
dim m_focusMap As ESRI.ArcGIS.Carto.IActiveView
Dim mxDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument = My.ArcMap.Document
m_focusMap = TryCast(mxDoc.FocusMap, ESRI.ArcGIS.Carto.IActiveView)
m_focusMap.Refresh()
-
Thanks for your post, I tried that and unfortunately still no luck.BeckyZ– BeckyZ2012年04月30日 15:01:26 +00:00Commented Apr 30, 2012 at 15:01
-
The above works for data view. Are you trying to refresh the Layout View?Jakub Sisak GeoGraphics– Jakub Sisak GeoGraphics2012年04月30日 16:27:21 +00:00Commented Apr 30, 2012 at 16:27
-
No, I am trying to refresh the data view. I agree your method should work - but in my case it does not. This seems to be a bug - I still haven't heard back from ESRI but found a workaround that I'm about to post.BeckyZ– BeckyZ2012年04月30日 18:51:56 +00:00Commented Apr 30, 2012 at 18:51
I have come across a rather strange workaround, so I figured I should post in case anyone else has this issue in the future.
As far as I can tell, this issue was occurring because I was trying to refresh the view as part of my OnStartEditing event handling (this seems to be a bug, and I've reported it to the lady I was working with at ESRI support on this issue). In my editor extension, the OnStartup wired the OnStartEditing event, and the OnStartEditing event tried to create the renderer and refresh the view.
I decided that rather than immediately enabling the capabilities of my extension when the editing session starts, I wanted to have the user click a button to enable the capabilities. I'll skip over all my reasoning on that as it's irrelevant to the issue at hand.
What is relevant is that I moved the call to the rendering routine (CreateRenderer) (with the code as previously posted) OUT of the OnStartEditing event and INTO my new button click event. So, the new flow is something like this:
On Startup --> Enable new custom button, Wire OnStartEditing and OnStopEditing
Custom button click --> run CreateRenderer subroutine
And voila! All the sudden my screen actually refreshes. I want to emphasize that I changed NOTHING in the CreateRenderer subroutine - I just moved the call to it out of the OnStartEditing Event and into the new button click event.
If I do hear back from ESRI about this issue I'll post any additional relevant information.
-
ESRI support has confirmed that I have found a bug in ArcGIS 10 and has submitted a bug report for it (bug NIM080497). The specific bug is that IActiveView::Refresh does not work when called inside an IEditEvents.OnStartEditing event handler. They didn't mention when this might be fixed.BeckyZ– BeckyZ2012年05月03日 11:34:26 +00:00Commented May 3, 2012 at 11:34
-
1Just noticed in our bug logs that this issue has now been fixed in version 10.1!BeckyZ– BeckyZ2012年10月09日 13:23:16 +00:00Commented Oct 9, 2012 at 13:23