/// <summary> /// Thread safe set of the autoscrollposition of the the scroll panel. /// </summary> /// <param name="scrollPosition">A <see cref="Point"/> with the new scroll position.</param> protected void ThreadSafeSetAutoScrollPosition(Point scrollPosition) { if (this.Picture.Parent.Parent == null) { return; } ScrollableControl scrollPanel = this.Picture.Parent.Parent as ScrollableControl; if (scrollPanel == null) { return; } if (scrollPanel.InvokeRequired) { SetPointCallback d = new SetPointCallback(this.ThreadSafeSetAutoScrollPosition); scrollPanel.Invoke(d, new object[] { scrollPosition }); } else { scrollPanel.AutoScrollPosition = scrollPosition; } }
private void refreshTour() { try { Point Point1, Point0; for (int c = 1; c <= counter_City; c++) try { //this.shapeContainer_allCityShape.Shapes.Remove(lineShape_Way[c]); RemoveLineShape(lineShape_Way[c]); // } catch { break; } for (int c = 1; c < counter_City; c++) { // pop[0] is Elite chromosome or best less Distance ----------------------- Point1 = ovalShape_City[pop[0].Tour[c]].Location; Point0 = ovalShape_City[pop[0].Tour[c - 1]].Location; try { SetPointCallback d = new SetPointCallback(SetPoint); this.BeginInvoke(d, new object[] { c, Point0, Point1 }); } catch { } //this.shapeContainer_allCityShape.Shapes.Add(lineShape_Way[c]); AddLineShape(lineShape_Way[c]); // } // design line between city 0 & last city // pop[0] is Elite chromosome or best less Distance Point1 = ovalShape_City[pop[0].Tour[counter_City - 1]].Location; Point0 = ovalShape_City[pop[0].Tour[0]].Location; try { SetPointCallback d2 = new SetPointCallback(SetPoint); this.BeginInvoke(d2, new object[] { 0, Point0, Point1 }); } catch { } //this.shapeContainer_allCityShape.Shapes.Add(lineShape_Way[0]); AddLineShape(lineShape_Way[0]); } catch { } }