My brain is dead. How do I change the default style for the tracking and editing interactive overlays from that default blue?
How do you set the style for the edit interative overlay
Ted,
You would modify these guys…
winformsMap1.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle
Of course it would DefaultLineStyle if it were track lines. One interesting thing I did find is that I don’t seem to see a way to change the color of the ExtentInteractiveOverlay. I mean we cant change the qualities of the track zoom rectangle. Maybe I am brain dead today and missing it. Anyway I will look into that and make sure we expose that.
David
Thanks, I finally had a Duh moment and had figured it out. Should have posted. Question, though. I’m running custom zoom level sets. So I was under the impression that I had to set the style on all 50 of my zoom levels. That seems silly. On the standard sets, there is the ApplyTo* methods to run a style through everwhere. Is there any way to set a single style and have it automatically applied at all levels?
Ted,
If you are using the CustomZoomLevels collection then there is no way to set it just once and apply it. :-( The only thing I can think of would be to put that code in some kind of factory so that when you create your custom zoom levels it automatically gets applied.
Another idea, assuming that you always want it the same style, you could possibly override the TrackInteractiveOverlay at some point and apply your style there. Maybe in in the draw method you could loop through all your custom zoom levels and just set them. Sounds like a bit of a backwards way but I think could work and then you could add a property for the styles at the TrackInteractiveOverlayLevel and it would apply it every time. Of course you can setup a flag to know you have applied it already so you don’t have to do it every draw cycle.
That might get you thinking about things in a different way.
David
In our application, we have the concept of a Theme. A theme object logically maps to your CustomStyles collection. We have a factory object which converts our theme and it parts into your styles. We do have a method on that class to apply a style to all or a subset of the custom zoom level set, when necessary. I just didn’t know if I was overlooking something.
I did run into one problem that you might address. On the EditInteractiveOverlay, I wanted to use CustomStyles as that is what is returned from my factory converter. That’s what we use on all other layers and we get along fine. But on this class, you already had the Default Area, Lilne, Point, and Text styles defined… as expected. And, as expected, I got an error indicating that I was trying to use custom styles as well as default. So I set all of the Default*Style properties to Null. And then I got a null reference extension error. It appears to me that you might be explicitly hardcoded to a Default*Style property in that overlay’s implementation of DrawCore? Am I thinking right on that, and if so, is that by design, or is it an oversight?
I"ve worked around it by ieterating the styles collection and for each member, setting the most appropriate Default*Style property. Works fine. Just a heads up if other people encounter this.
Ted,
Good find on the custom styles for the interactive overlays. We will look into this and see what we find. I am assuming it is our mistake and put you into a catch 22 position.
David
Ted & David,
I am sorry I jumped into here to say something I know, hope I did not screw it up.
As we know, in our whole system, we cannot allow the setting of both Default Style and CustomStyles, otherwise the exception will be throw to force us to change it. In our EditInterativeOverlay, we definitely set those default styles, so we have to make them inactive if we want to use the CustomStyles. Following code snippet shows how to do it.
LineStyle lineStyle = LineStyles.Highway1;
AreaStyle areaStyle = AreaStyles.County1;
PointStyle pointStyle = PointStyles.Capital1;
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive = false;
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive = false;
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.IsActive = false;
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(lineStyle);
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pointStyle);
winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
If I misunderstand anything or making any mistake, please do not hesitate to let me know.
Thanks.
Yale
Ok… I was setting them to null. You wanted them set to InActive. That would explain the null reference exception. Maybe you should not let me set them to null then?
Thanks for catching my mistake, Yale.
Ted,
We’re glad it’s working with you, we might consider update our document or something else to let user know how to disable default style.
Please let us know if you have more questions.
Thanks
James
Ted / James,
We will update the documentation for sure. The Wiki will be out soon and that wil make it 100 times easier for us to document things like this. I can’t wait to launch that!
David