/// <summary> /// Create smaller grid for pathfinding - for non-async calls /// </summary> /// <param name="designer">From this viewmodel is grid created</param> /// <param name="step">Grid row/col step</param> /// <returns>Created grid</returns> public static Grid CreateMinifiedGridForPathFindingSync(DatabaseModelDesignerViewModel designer, int step) { var rects = GetTableRectangles(designer.TableViewModels, step).Select(s => { var t = s.Y / step; var l = s.X / step; var r = s.Right / step; var b = s.Bottom / step; return(new Rectangle(l, t, r - l, b - t)); }); return(PathFinderHelper.CreateGrid((int)(designer.CanvasWidth / step), (int)designer.CanvasHeight / step, rects)); }
/// <summary> /// Create smaller grid for pathfinding /// </summary> /// <param name="designer">From this viewmodel is grid created</param> /// <param name="step">Grid row/col step</param> /// <returns>Task for async execution => Created grid</returns> public static async Task <Grid> CreateMinifiedGridForPathFinding(DatabaseModelDesignerViewModel designer, int step) { var rects = GetTableRectangles(designer.TableViewModels, step).Select(s => { var t = s.Y / step; var l = s.X / step; var r = s.Right / step; var b = s.Bottom / step; return(new Rectangle(l, t, r - l, b - t)); }); var res = await Task.Factory.StartNew(() => PathFinderHelper.CreateGrid((int)(designer.CanvasWidth / step), (int)designer.CanvasHeight / step, rects)); return(res); }