@@ -59,7 +59,7 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
5959 writer . Write ( "Captures=" ) ;
6060
6161 foreach ( Capture capture in capturesList )
62- writer . Write ( capture . Coordinate [ 0 ] + "," + capture . Coordinate [ 1 ] + "," + capture . Altitude + "," + capture . Overlap + ";" ) ;
62+ writer . Write ( capture . Coordinate [ 0 ] + "," + capture . Coordinate [ 1 ] + "," + capture . Altitude + "," + capture . Overlap + "," + capture . Completed + " ;") ;
6363 }
6464 }
6565 }
@@ -106,7 +106,11 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
106106 if ( capture != "" )
107107 {
108108 string [ ] captureData = capture . Split ( ',' ) ;
109- capturesList . Add ( new Capture ( new double [ ] { double . Parse ( captureData [ 0 ] ) , double . Parse ( captureData [ 1 ] ) } , int . Parse ( captureData [ 2 ] ) , int . Parse ( captureData [ 3 ] ) ) ) ;
109+ if ( captureData . Length > 4 )
110+ capturesList . Add ( new Capture ( new double [ ] { double . Parse ( captureData [ 0 ] ) , double . Parse ( captureData [ 1 ] ) } , int . Parse ( captureData [ 2 ] ) , int . Parse ( captureData [ 3 ] ) ,
111+ bool . Parse ( captureData [ 4 ] ) ) ) ;
112+ else
113+ capturesList . Add ( new Capture ( new double [ ] { double . Parse ( captureData [ 0 ] ) , double . Parse ( captureData [ 1 ] ) } , int . Parse ( captureData [ 2 ] ) , int . Parse ( captureData [ 3 ] ) , false ) ) ;
110114 }
111115 }
112116 break ;
@@ -267,17 +271,17 @@ private double[] AlignCoords(double lat, double lng, double[] captureSize)
267271 return new double [ ] { lat + alignedLat , lng - alignedLng } ;
268272 }
269273
270- private List < Capture > GetCaptures ( )
274+ private List < Capture > GetCaptures ( string startCoord , string endCoord )
271275 {
272276 List < Capture > myCaptures = new List < Capture > ( ) ;
273277 double [ ] captureSize = GetCaptureDimensions ( camAltitude , Convert . ToInt32 ( numOverlap . Value ) ) ;
274- double [ ] selDimensions = GetDimensionsFromCoords ( txtSelCoordUpper . Text , txtSelCoordLower . Text ) ;
278+ double [ ] selDimensions = GetDimensionsFromCoords ( startCoord , endCoord ) ;
275279
276280 int numHorizontal = ( int ) Math . Ceiling ( selDimensions [ 0 ] / captureSize [ 0 ] ) ;
277281 int numVertical = ( int ) Math . Ceiling ( selDimensions [ 1 ] / captureSize [ 1 ] ) ;
278282
279- double startLat = Math . Max ( double . Parse ( txtSelCoordUpper . Text . Split ( ',' ) [ 0 ] ) , double . Parse ( txtSelCoordLower . Text . Split ( ',' ) [ 0 ] ) ) ;
280- double startLng = Math . Min ( double . Parse ( txtSelCoordUpper . Text . Split ( ',' ) [ 1 ] ) , double . Parse ( txtSelCoordLower . Text . Split ( ',' ) [ 1 ] ) ) ;
283+ double startLat = Math . Max ( double . Parse ( startCoord . Split ( ',' ) [ 0 ] ) , double . Parse ( endCoord . Split ( ',' ) [ 0 ] ) ) ;
284+ double startLng = Math . Min ( double . Parse ( startCoord . Split ( ',' ) [ 1 ] ) , double . Parse ( endCoord . Split ( ',' ) [ 1 ] ) ) ;
281285
282286 if ( chbCentre . Checked )
283287 {
@@ -288,15 +292,19 @@ private List<Capture> GetCaptures()
288292
289293 if ( chbAlignCaptures . Checked && capturesList . Count > 0 )
290294 {
291- double [ ] alignedCoords = AlignCoords ( startLat , startLng , captureSize ) ;
295+ double [ ] alignedCoords ;
296+ if ( grid . Split ( ',' ) . Length > 2 )
297+ alignedCoords = AlignCoords ( startLat , startLng , GetCaptureDimensions ( int . Parse ( grid . Split ( ',' ) [ 2 ] ) , int . Parse ( grid . Split ( ',' ) [ 3 ] ) ) ) ;
298+ else
299+ alignedCoords = AlignCoords ( startLat , startLng , captureSize ) ;
292300 startLat = alignedCoords [ 0 ] ;
293301 startLng = alignedCoords [ 1 ] ;
294302 }
295303
296304 if ( capturesList . Count == 0 )
297- grid = startLat + "," + startLng ;
305+ grid = startLat + "," + startLng + "," + camAltitude + "," + numOverlap . Value ;
298306
299- double curLat = startLat ;
307+ double curLat = startLat ;
300308 double curLng = startLng ;
301309
302310 for ( int i = 0 ; i < numVertical ; i ++ )
@@ -307,7 +315,7 @@ private List<Capture> GetCaptures()
307315 double captureLowerLng = curLng + DistanceToLng ( captureLowerLat , captureSize [ 0 ] ) ;
308316 double captureMidLat = ( curLat + captureLowerLat ) / 2 ;
309317 double captureMidLng = ( curLng + captureLowerLng ) / 2 ;
310- myCaptures . Add ( new Capture ( new double [ ] { Math . Round ( captureMidLat , 6 ) , Math . Round ( captureMidLng , 6 ) } , camAltitude , Convert . ToInt32 ( numOverlap . Value ) ) ) ;
318+ myCaptures . Add ( new Capture ( new double [ ] { Math . Round ( captureMidLat , 6 ) , Math . Round ( captureMidLng , 6 ) } , camAltitude , Convert . ToInt32 ( numOverlap . Value ) , false ) ) ;
311319 curLng = captureLowerLng ;
312320 }
313321 curLat -= DistanceToLat ( captureSize [ 1 ] ) ;
@@ -334,7 +342,12 @@ private void DisplayCaptures(List<Capture> captures)
334342
335343 GMapPolygon capturePoly = new GMapPolygon ( new List < PointLatLng > ( ) { new PointLatLng ( topLat , topLng ) , new PointLatLng ( topLat , bottomLng ) ,
336344 new PointLatLng ( bottomLat , bottomLng ) , new PointLatLng ( bottomLat , topLng ) } , "" ) ;
337- capturePoly . Stroke = new Pen ( Color . Blue , 2 ) ;
345+
346+ if ( capture . Completed )
347+ capturePoly . Stroke = new Pen ( Color . Red , 2 ) ;
348+ else
349+ capturePoly . Stroke = new Pen ( Color . Blue , 2 ) ;
350+
338351 capturePoly . Fill = new SolidBrush ( Color . Empty ) ;
339352 captureOverlay . Polygons . Add ( capturePoly ) ;
340353
@@ -347,9 +360,18 @@ private void btnCalculate_Click(object sender, EventArgs e)
347360 {
348361 try
349362 {
350- var returnedCoords = GetCaptures ( ) ;
351- capturesList . AddRange ( returnedCoords ) ;
352- DisplayCaptures ( returnedCoords ) ;
363+ string startCoord = txtSelCoordUpper . Text ;
364+ string endCoord = txtSelCoordLower . Text ;
365+ if ( startCoord . Split ( ',' ) . Length > 2 || endCoord . Split ( ',' ) . Length > 2 )
366+ {
367+ string [ ] startSplit = startCoord . Split ( ',' ) ;
368+ string [ ] endSplit = endCoord . Split ( ',' ) ;
369+ startCoord = startSplit [ 0 ] + "." + startSplit [ 1 ] + "," + startSplit [ 2 ] + "." + startSplit [ 3 ] ;
370+ endCoord = endSplit [ 0 ] + "." + endSplit [ 1 ] + "," + endSplit [ 2 ] + "." + endSplit [ 3 ] ;
371+ }
372+ var returnedCaptures = GetCaptures ( startCoord , endCoord ) ;
373+ capturesList . AddRange ( returnedCaptures ) ;
374+ DisplayCaptures ( returnedCaptures ) ;
353375 }
354376 catch ( Exception )
355377 {
@@ -402,6 +424,8 @@ private void gMapControl_MouseDoubleClick(object sender, MouseEventArgs e)
402424 captureOverlay . Markers [ i ] . ToolTipText = "Copied!" ;
403425 Clipboard . SetText ( capturesList [ i ] . URL ) ;
404426 Task . Factory . StartNew ( ( ) => ResetToolTip ( url , i ) ) ;
427+ capturesList [ i ] . Completed = true ;
428+ captureOverlay . Polygons [ i ] . Stroke = new Pen ( Color . Red , 2 ) ;
405429 return ;
406430 }
407431 }
0 commit comments