Some Enhancements

Oct 25, 2009 at 10:14 AM

Here is a screen shot of some mofications to the windows forms lib.

http://img21.imageshack.us/img21/2191/mapview.png

Google sytle tool tip and map grayscale mode.

Why grayscal you may ask, well sometimes it is usefull to see all the overlays without the map color.

I will post the patch when I am happy all is stable.

Cheers

 

 

 

Coordinator
Oct 25, 2009 at 1:07 PM

great! ;}

Nov 9, 2009 at 11:55 AM

Hi Azlan

Is there a way that you can post your code for grayscale mode?

Looking forward for oyur feedback.

Best regards,

Nov 9, 2009 at 12:15 PM
Edited Nov 10, 2009 at 7:56 AM

See my last post for optimzed version.

Cheers

 

Nov 9, 2009 at 11:37 PM

Hi Azlan

Thank you for posting your code. I hope you didn't have to much work and I think the code is good as it is without additional need for optimization.

Have a nice day and once again thank you and my thanks to radioman also for excellent control.

Best regards. 

Nov 10, 2009 at 7:55 AM
Edited Nov 10, 2009 at 3:26 PM

Here is an optimized version for the grayscale which speeds things up!!!!!.

Just add the new property and changes to DrawMapGDIplus in GMapControl.cs

Cheers

  private bool _GrayScale = false;

[Description("Gray Scale"), Category("Map Control")]
public bool GrayScale
{
get { return _GrayScale; }
set { _GrayScale = value; }
}

See my last post for main code.

Nov 10, 2009 at 10:01 AM

Radioman,

Please can you incorporate this greyscale code into the standard release.

Thanks azlan, radioman

Paul.

 

Coordinator
Nov 10, 2009 at 1:23 PM

I've just tested it, and performance is quite bad, is there other option, maybe convert image when it's loaded?

Nov 10, 2009 at 1:48 PM

how about create a cache of the grey scale tile when the option is first chosen to display the current map in greyscale, then look for these titles again when grey scale is selected ?

is it any quicker to load from cache or do the conversion realtime again ?

Nov 10, 2009 at 3:25 PM
Try the code below, subjective testing there is not much difference when gray.

Cheers

void DrawMapGDIplus(Graphics g) { ColorMatrix cm = new ColorMatrix(new float[][] { new float[] {0.213f, 0.213f, 0.213f, 0, 0}, new float[] {0.715f, 0.715f, 0.715f, 0, 0}, new float[] {0.072f, 0.072f, 0.072f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); ImageAttributes ImageAttribs = new ImageAttributes(); ImageAttribs.SetColorMatrix(cm); for(int i = -Core.sizeOfMapArea.Width; i <= Core.sizeOfMapArea.Width; i++) { for(int j = -Core.sizeOfMapArea.Height; j <= Core.sizeOfMapArea.Height; j++) { Core.tilePoint = Core.centerTileXYLocation; Core.tilePoint.X += i; Core.tilePoint.Y += j; { Tile t = Core.Matrix[Core.tilePoint]; if(t != null) { Core.tileRect.X = Core.tilePoint.X*Core.tileRect.Width; Core.tileRect.Y = Core.tilePoint.Y*Core.tileRect.Height; Core.tileRect.Offset(Core.renderOffset); if(Core.CurrentRegion.IntersectsWith(Core.tileRect)) { bool found = false; // render tile lock(t.Overlays) { foreach(WindowsFormsImage img in t.Overlays) { if(img != null && img.Img != null) { if(!found) found = true; if (_GrayScale == true) { Drawing.Rectangle rect = new Drawing.Rectangle(Core.tileRect.X, Core.tileRect.Y, img.Img.Width, img.Img.Height); g.DrawImage(img.Img, rect, 0, 0, Core.tileRect.Width, Core.tileRect.Height, GraphicsUnit.Pixel, ImageAttribs); } else { g.DrawImage(img.Img, Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height); } if(ShowTileGridLines) { g.DrawRectangle(_EmptyTileBorders, Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height); if(Core.tilePoint == Core.centerTileXYLocation) { g.DrawString("CENTER TILE: " + Core.tilePoint.ToString(), MissingDataFont, Brushes.Red, new RectangleF(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height), CenterFormat); } else { g.DrawString("TILE: " + Core.tilePoint.ToString(), MissingDataFont, Brushes.Red, new RectangleF(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height), CenterFormat); } } } } } // add text if tile is missing if(!found) { g.FillRectangle(_EmptytileBrush, new RectangleF(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height)); g.DrawString(_EmptyTileText, MissingDataFont, _EmptytileTextColor, new RectangleF(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height), CenterFormat); if(ShowTileGridLines) { g.DrawString("TILE: " + Core.tilePoint.ToString(), MissingDataFont, Brushes.Red, new RectangleF(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height), BottomFormat); } g.DrawRectangle(_EmptyTileBorders, Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height); // raise error if(OnEmptyTileError != null) { if(!RaiseEmptyTileError) { RaiseEmptyTileError = true; OnEmptyTileError(t.Zoom, t.Pos); } } } } } } } } ImageAttribs.Dispose(); }

 

Coordinator
Nov 10, 2009 at 3:50 PM

compare this with new version ;}

Nov 10, 2009 at 4:14 PM

hmm, can't load the project in VS2008 , 'The tools version 4.0 is unrecognised' 

Is the project VS2010 only now ?

 

Coordinator
Nov 10, 2009 at 4:19 PM

both, but when using vs2008 i just get waring message: "Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5"."