public DashItem SetupDashItem(Gebruiker user, List <Follow> follows) { InitNonExistingRepo(true); bool UoW = false; repo.SetUnitofWork(UoW); TileZone tile = new TileZone() { Dashbord = GetDashboard(user), DashItem = follows[0].DashItem }; uowManager.Save(); foreach (Follow follow in follows) { repo.AddTileZone(tile); follow.DashItem.TileZones.Add(tile); } AddOneZonesOrder(GetDashboard(user)); uowManager.Save(); UoW = true; repo.SetUnitofWork(UoW); return(follows[0].DashItem); }
public Dashbord DashbordInitGraphs(int dashId) { InitNonExistingRepo(); Dashbord dashbord = repo.ReadDashbord(dashId); //We halen vaste grafieken op (AdminGraphs) en koppelen deze aan de //nieuw aangemaakte dashboard van de nieuwe gebruiker IEnumerable <DashItem> dashItems = GetDashItems().Where(d => d.AdminGraph == true); if (dashbord.TileZones == null) { dashbord.TileZones = new Collection <TileZone>(); } foreach (DashItem item in dashItems) { TileZone tile = new TileZone() { DashItem = item, Dashbord = dashbord }; repo.AddTileZone(tile); } repo.UpdateDashboard(dashbord); return(dashbord); }
public DashItem SetupDashItem(Gebruiker user, Follow follow) { InitNonExistingRepo(true); bool UoW = false; repo.SetUnitofWork(UoW); follow.DashItem.Follows = new Collection <Follow> { follow }; Dashbord dashbord = GetDashboard(user); TileZone tile = new TileZone() { Dashbord = dashbord, DashItem = follow.DashItem }; repo.AddTileZone(tile); follow.DashItem.TileZones.Add(tile); repo.UpdateFollow(follow); //repo.UpdateDashItem(dashItem); AddOneZonesOrder(dashbord); uowManager.Save(); UoW = true; repo.SetUnitofWork(UoW); return(follow.DashItem); }
public void SetZone(TileZone zone) { this.zone = zone; if (cbChanged != null) { cbChanged(this); } }
public void OnRenderObject(NavmeshBuild build, TileSelection selection) { if (!build) { return; } TileSetDefinition tdef = build.TileSetDefinition; if (!mShow || !mEnabled || build != selection.Build || tdef == null) { return; } Color color = ControlUtil.SelectionColor; DebugDraw.SimpleMaterial.SetPass(0); GL.Begin(GL.LINES); GL.Color(color); if (selection.Validate()) { Vector3 bmin; Vector3 bmax; Vector3 trash; TileZone zone = selection.Zone; tdef.GetTileBounds(zone.xmin, zone.zmin, true, out bmin, out trash); tdef.GetTileBounds(zone.xmax, zone.zmax, true, out trash, out bmax); DebugDraw.AppendBounds(bmin, bmax); if (mIncludeRootTile) { GL.Color(new Color(0.93f, 0.58f, 0.11f)); // Orange tdef.GetTileBounds(selection.SelectedX, selection.SelectedZ, true , out bmin, out bmax); DebugDraw.AppendBounds(bmin, bmax); } } else { Vector3 bmax = tdef.BoundsMin; float tileSize = build.Config.TileWorldSize; bmax.x += tileSize * tdef.Width; bmax.y = tdef.BoundsMax.y; bmax.z += tileSize * tdef.Depth; DebugDraw.AppendBounds(tdef.BoundsMin, bmax); } GL.End(); }
internal bool GetMeshBuildData(Vector3 origin, float tileWorldSize, TileZone zone , out NavmeshParams config , out NavmeshTileData[] tiles) { // Is there anything to bake? config = null; tiles = null; int maxPolyCount; int tileCount; BakeableCount(out tileCount, out maxPolyCount); if (tileCount == 0) { return(false); } config = new NavmeshParams(origin , tileWorldSize, tileWorldSize , Mathf.Max(1, tileCount) , Mathf.Max(1, maxPolyCount)); // Add the tiles. List <NavmeshTileData> ltiles = new List <NavmeshTileData>(); for (int tx = zone.xmin; tx <= zone.xmax; tx++) { for (int tz = zone.zmin; tz <= zone.zmax; tz++) { int trash; NavmeshTileData td = GetTileData(tx, tz, out trash); if (td == null) { // Tile is not available. continue; } ltiles.Add(td); } } tiles = ltiles.ToArray(); return(true); }
private void HandleBuildRequest(bool forceAll) { TileSelection sel = Context.Selection; int w; int d; int ix = 0; int iz = 0; int priority; if (!forceAll && sel.Validate()) { TileZone zone = sel.Zone; w = zone.xmax + 1; d = zone.zmax + 1; ix = zone.xmin; iz = zone.zmin; priority = BuildTaskProcessor.MediumPriority; } else { TileBuildData tdata = Context.Build.BuildData; w = tdata.Width; d = tdata.Depth; priority = BuildTaskProcessor.LowPriority; } // Note: The iteration order appears odd, but it makes for better // progress visualizations. Filling downward. for (int tz = d - 1; tz >= iz; tz--) { for (int tx = ix; tx < w; tx++) { if (!Context.QueueTask(tx, tz, priority--, Logger)) { Logger.PostError(string.Format("Build task failed: ({0},{1})", tx, tz) , Context.Build); } } } }
public void SyncWithAdmins(string userId, int dashItemId) { InitNonExistingRepo(true); gebruikerMgr = new GebruikerManager(uowManager); IEnumerable <Gebruiker> admins = gebruikerMgr.GetGebruikersWithDash().Where(u => u.Role == "Admin" && u.GebruikerId != userId).ToList(); foreach (Gebruiker admin in admins) { foreach (Dashbord dash in admin.Dashboards) { TileZone tile = new TileZone() { Dashbord = dash, DashItem = repo.ReadDashItem(dashItemId) }; repo.AddTileZone(tile); AddOneZonesOrder(dash); uowManager.Save(); } } }
private void HandleWorkingNavmesh(TileSelection selection) { NavmeshBuild build = selection.Build; TileBuildData tdata = build.BuildData; if (mDebugObject == null) { Navmesh navmesh = null; if (tdata.BakeableCount() == 0) { // Nothing to display. return; } bool success = true; TileSetDefinition tdef = build.TileSetDefinition; NavmeshParams nconfig; NavmeshTileData[] tiles; if (tdef == null) { tiles = new NavmeshTileData[1] { tdata.GetTileData(0, 0) }; nconfig = NavUtil.DeriveConfig(tiles[0]); } else { TileZone zone; if (selection.HasSelection) { zone = selection.Zone; } else { zone = new TileZone(0, 0, tdef.Width - 1, tdef.Depth - 1); } success = tdata.GetMeshBuildData(tdef.BoundsMin.ToUnityVector3(), tdef.TileWorldSize, zone , out nconfig, out tiles); } NavStatus status = NavStatus.Sucess; if (success) { status = Navmesh.Create(nconfig, out navmesh); if ((status & NavStatus.Failure) == 0) { foreach (NavmeshTileData tile in tiles) { uint trash; status = navmesh.AddTile(tile, Navmesh.NullTile, out trash); if ((status & NavStatus.Sucess) == 0) { navmesh = null; break; } } } } if ((status & NavStatus.Sucess) == 0) { Show = MeshDebugOption.None; // Use property. Debug.LogError("Mesh Debug View: Error creating working navigation mesh: " + status + ". Disabled display.", build); } else { mDebugObject = navmesh; } } if (mDebugObject != null) { Navmesh nm = ( Navmesh )mDebugObject; NavDebug.Draw(nm, NavmeshSceneDraw.Instance.ColorByArea); } }
internal bool GetMeshBuildData(Vector3 origin, float tileWorldSize, TileZone zone , out NavmeshParams config , out NavmeshTileData[] tiles) { // Is there anything to bake? config = null; tiles = null; int maxPolyCount; int tileCount; BakeableCount(out tileCount, out maxPolyCount); if (tileCount == 0) return false; config = new NavmeshParams(origin , tileWorldSize, tileWorldSize , Mathf.Max(1, tileCount) , Mathf.Max(1, maxPolyCount)); // Add the tiles. List<NavmeshTileData> ltiles = new List<NavmeshTileData>(); for (int tx = zone.xmin; tx <= zone.xmax; tx++) { for (int tz = zone.zmin; tz <= zone.zmax; tz++) { int trash; NavmeshTileData td = GetTileData(tx, tz, out trash); if (td == null) // Tile is not available. continue; ltiles.Add(td); } } tiles = ltiles.ToArray(); return true; }
public void AddTileZone(TileZone tile) { repo.AddTileZone(tile); }
private void OnGUISelection(float areaHeight) { Vector3 origin; int xSize = GridCellSize; int ySize = GridCellSize; TileSelection selection = Context.Selection; if (selection.Validate()) { // Draw the tile marker. origin = new Vector3(selection.SelectedX * GridCellSize , areaHeight - selection.SelectedZ * GridCellSize); mCellVerts[0] = origin; mCellVerts[1] = origin; mCellVerts[1].x += GridCellSize; mCellVerts[2] = origin; mCellVerts[2].x += GridCellSize; mCellVerts[2].y -= GridCellSize; mCellVerts[3] = origin; mCellVerts[3].y -= GridCellSize; Handles.DrawSolidRectangleWithOutline(mCellVerts , Color.clear , new Color(0.93f, 0.58f, 0.11f)); // Orange. TileZone zone = selection.Zone; origin = new Vector3(zone.xmin * GridCellSize, areaHeight - zone.zmin * GridCellSize); xSize = zone.Width * GridCellSize; ySize = zone.Depth * GridCellSize; } else { origin = new Vector3(0, areaHeight); TileBuildData tdata = Context.Build.BuildData; xSize = tdata.Width * GridCellSize; ySize = tdata.Depth * GridCellSize; } mCellVerts[0] = origin; mCellVerts[1] = origin; mCellVerts[1].x += xSize; mCellVerts[2] = origin; mCellVerts[2].x += xSize; mCellVerts[2].y -= ySize; mCellVerts[3] = origin; mCellVerts[3].y -= ySize; Handles.DrawSolidRectangleWithOutline(mCellVerts , Color.clear , ControlUtil.SelectionColor); }
private void HandleWorkingNavmesh(TileSelection selection) { NavmeshBuild build = selection.Build; TileBuildData tdata = build.BuildData; if (mDebugObject == null) { Navmesh navmesh = null; if (tdata.BakeableCount() == 0) // Nothing to display. return; bool success = true; TileSetDefinition tdef = build.TileSetDefinition; NavmeshParams nconfig; NavmeshTileData[] tiles; if (tdef == null) { tiles = new NavmeshTileData[1] { tdata.GetTileData(0, 0) }; nconfig = NavUtil.DeriveConfig(tiles[0]); } else { TileZone zone; if (selection.HasSelection) zone = selection.Zone; else zone = new TileZone(0, 0, tdef.Width - 1, tdef.Depth - 1); success = tdata.GetMeshBuildData(tdef.BoundsMin, tdef.TileWorldSize, zone , out nconfig, out tiles); } NavStatus status = NavStatus.Sucess; if (success) { status = Navmesh.Create(nconfig, out navmesh); if ((status & NavStatus.Failure) == 0) { foreach (NavmeshTileData tile in tiles) { uint trash; status = navmesh.AddTile(tile, Navmesh.NullTile, out trash); if ((status & NavStatus.Sucess) == 0) { navmesh = null; break; } } } } if ((status & NavStatus.Sucess) == 0) { Show = MeshDebugOption.None; // Use property. Debug.LogError("Mesh Debug View: Error creating working navigation mesh: " + status + ". Disabled display.", build); } else mDebugObject = navmesh; } if (mDebugObject != null) { Navmesh nm = (Navmesh)mDebugObject; NavDebug.Draw(nm, NavmeshSceneDraw.Instance.ColorByArea); } }
public void AddTileZone(TileZone tileZone) { ctx.TileZones.Add(tileZone); ctx.SaveChanges(); }
public void UpdateTileZone(TileZone tileZone) { ctx.Entry(tileZone).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); }