public void UpdateSectorURL(SectorObj theSector) { if (theSector.terrainId == parent.pop.curTerrain.Id) { RefreshGridSquare(theSector.Id, theSector.sectorUrl); } }
private void SaveSectorImage() { Bitmap.Config config = Bitmap.Config.Argb8888; Bitmap newBitmap = Bitmap.CreateBitmap(1000, 1000, config); int cellSize = 100; Canvas canvas = new Canvas(newBitmap); Rect destRect = new Rect(0, 0, 1024, 1024); Bitmap bkgnd = BitmapHelper.GetImageBitmapFromUrl(parent.pop.curSector.DefaultUrl); Rect srcRect = new Rect(0, 0, bkgnd.Width, bkgnd.Height); Paint thePaint = new Paint(PaintFlags.AntiAlias); canvas.DrawBitmap(bkgnd, srcRect, destRect, thePaint); SectorObj curSector = parent.pop.curSector; foreach (StructureObj curStructure in parent.pop.curSector.structures) { bkgnd = BitmapHelper.GetImageBitmapFromUrl(curStructure.imageURL); srcRect = new Rect(0, 0, bkgnd.Width, bkgnd.Height); destRect = new Rect(curStructure.xLoc * cellSize, curStructure.yLoc * cellSize, (curStructure.xLoc + curStructure.xSize) * cellSize, (curStructure.yLoc + curStructure.ySize) * cellSize); canvas.DrawBitmap(bkgnd, srcRect, destRect, thePaint); } // at this point, the bitmap should be drawn using (System.IO.MemoryStream photoStream = new System.IO.MemoryStream()) { newBitmap.Compress(Bitmap.CompressFormat.Jpeg, 90, photoStream); photoStream.Flush(); PhabrikServer.UploadImage(photoStream, "sector", (newURL) => { parent.UpdateSectorUrl(curSector, newURL); }); } }
public void UpdateSectorUrl(SectorObj theSector, string theUrl) { theSector.sectorUrl = theUrl; PhabrikServer.UpdateSectorUrl(theSector, theUrl); if (curScale == PointOfPresenceObj.PopScale.Planet) { planetFragment.UpdateSectorURL(theSector); } }
private bool validateForm(SectorObj obj) { var exist = repoSector.AllEager(f => f.SECTOR_CODE == obj.SECTOR_CODE).FirstOrDefault(); if (exist == null) { return(true); } return(false); }
private void RefreshGridView() { if (this.View != null) { Activity.RunOnUiThread(() => { var curPlanet = parent.pop.curPlanet; var curTerrain = parent.pop.curTerrain; bool tidallyLocked = ((int)curPlanet.day == (int)(curPlanet.orb_period * 24.0)) || curPlanet.resonant_period; var width = curTerrain.width; var height = curTerrain.height; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { View newView = Activity.LayoutInflater.Inflate(Resource.Layout.GridSectorLayout, null); gridView.AddView(newView); var gridLayout = new GridLayout.LayoutParams(GridLayout.InvokeSpec(y), GridLayout.InvokeSpec(x)); //gridLayout.SetMargins(2, 2, 2, 2); gridLayout.Width = kGridSize; gridLayout.Height = kGridSize; newView.LayoutParameters = gridLayout; var textField = newView.FindViewById <TextView>(Resource.Id.coordLabel); if (PhabrikServer.CurrentUser.isAdmin) { textField.Text = string.Format("{0},{1}", x, y); textField.SetBackgroundColor(Color.Blue); textField.SetTextColor(Color.White); } else { ((ViewGroup)newView).RemoveView(textField); } var imageView = newView.FindViewById <ImageView>(Resource.Id.backgroundImage); if (curTerrain._sectorArray != null) { SectorObj curSec = curTerrain._sectorArray[x][y]; newView.Tag = curSec.Id; imageView.SetScaleType(ImageView.ScaleType.Center); string url = curSec.sectorUrl; if (string.IsNullOrEmpty(url)) { url = curSec.DefaultUrl; } else { url += "=s" + kGridSize; } Koush.UrlImageViewHelper.SetUrlDrawable(imageView, url, Resource.Drawable.Icon); } else { // todo - handle unknown terrain.. } if (!tidallyLocked || x <= width / 2) { var darkness = newView.FindViewById(Resource.Id.nighttime); ((ViewGroup)newView).RemoveView(darkness); } } } selectionView = new View(this.Activity); gridView.AddView(selectionView); selectionView.Visibility = ViewStates.Gone; selectionView.SetBackgroundResource(Resource.Drawable.SelectionBorder); }); } }
public ActionResult Create(SectorObj model, string m) { try { menuId = SmartUtil.GetMenuId(m); ViewBag.MenuId = HttpUtility.UrlDecode(m); var errorMsg = ""; if (ModelState.IsValid) { if (model.ITBID > 0) { //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ var BType = new SM_SECTORTEMP() { SECTOR_NAME = model.SECTOR_NAME, SECTOR_CODE = model.SECTOR_CODE, STATUS = open, RECORDID = model.ITBID, USERID = User.Identity.Name, CREATEDATE = DateTime.Now }; repoSectorTemp.Insert(BType); if (uow.Save(User.Identity.Name) > 0) { SM_AUTHLIST auth = new SM_AUTHLIST() { CREATEDATE = DateTime.Now, EVENTTYPE = model.STATUS == active ? eventEdit : model.STATUS, MENUID = menuId, //MENUNAME = "", RECORDID = BType.ITBID, STATUS = open, // TABLENAME = "ADMIN_DEPARTMENT", URL = Request.FilePath, USERID = User.Identity.Name, INSTITUTION_ITBID = institutionId, POSTTYPE = Single }; repoAuth.Insert(auth); var rst = uow.Save(User.Identity.Name) > 0 ? true : false; if (rst) { EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Sector Record"); TempData["msg"] = "Record Updated SuccessFully...Authorization Pending."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(RedirectToAction("Index", "Sector", new { m = m })); //return Json(new { RespCode = 0, RespMessage = "Record Updated SuccessFully...Authorization Pending." }); } else { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m, id = model.ITBID })); //return Json(new { RespCode = 1, RespMessage = "Problem Updating Record." }); } } // var ret = _repo.PostRole(model, 1); //if (ret != null && ret.RespCode == 0) //{ // model.RoleId = int.Parse(ret.OutputKey.ToString()); // return Json(new { data = model, RespCode = 0, RespMessage = "Record Created Successfully" }); //} } else { if (!validateForm(model)) { ViewBag.Message = "Carscheme already Exist."; return(View("Add", model)); } var BType = new SM_SECTORTEMP() { SECTOR_CODE = model.SECTOR_CODE, SECTOR_NAME = model.SECTOR_NAME, STATUS = open, RECORDID = model.ITBID, USERID = User.Identity.Name, CREATEDATE = DateTime.Now }; repoSectorTemp.Insert(BType); if (uow.Save(User.Identity.Name) > 0) { //var controller = ControllerContext.Controller..ToString(); SM_AUTHLIST auth = new SM_AUTHLIST() { CREATEDATE = DateTime.Now, EVENTTYPE = eventInsert, MENUID = menuId, //MENUNAME = "", RECORDID = BType.ITBID, STATUS = open, // TABLENAME = "ADMIN_DEPARTMENT", URL = Request.FilePath, USERID = User.Identity.Name, INSTITUTION_ITBID = institutionId, POSTTYPE = Single }; repoAuth.Insert(auth); var rst = uow.Save(User.Identity.Name) > 0 ? true : false; if (rst) { //newR = 1; EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Sector Record"); TempData["msg"] = "Record Created SuccessFully...Authorization Pending."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(RedirectToAction("Index", new { m = m })); //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); } else { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); // return Json(new { RespCode = 1, RespMessage = "Problem Creating Record." }); } } } } // If we got this far, something failed, redisplay form return(Json(new { RespCode = 1, RespMessage = errorMsg })); } catch (SqlException ex) { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); //return Json(new { RespCode = 1, RespMessage = ex.Message }); } catch (Exception ex) { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); //return Json(new { RespCode = 1, RespMessage = ex.Message }); } }