private void dgv_sector_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i = dgv_sector.CurrentRow.Index; int id = int.Parse(dgv_sector.Rows[i].Cells["ID"].Value.ToString()); sec = DBAccess.get_sector(id); if (sec != null) { try { txtID.Text = sec.Id.ToString(); txtTitle.Text = sec.Name; txtTitle.Enabled = true; lblerror1.Visible = false; temp_name = txtTitle.Text.Trim(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Null"); } }
public ActionResult AddSectors(List <AddSector> sectors) { if (ModelState.IsValid) { using (mmpEntities mP = new mmpEntities()) { mP.Configuration.ProxyCreationEnabled = false; foreach (var i in sectors) { #region Sector Already Exists var isSectorExists = IsSectorExist(i.sector_name); if (isSectorExists) { ModelState.AddModelError("SectorExists", "Sector already exists"); return(View(sectors)); } #endregion sector sector = new sector() { sector_name = i.sector_name }; mP.sectors.Add(sector); } mP.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } } else { return(View(sectors)); } }
static void checkGroups(sector a, sector b) { if ((a.myGroup != null) && (b.myGroup != null)) { mergeGroups(a.myGroup, b.myGroup); } else { if (a.myGroup != null) { a.myGroup.list.Add(b); b.myGroup = a.myGroup; } else if (b.myGroup != null) { b.myGroup.list.Add(a); a.myGroup = b.myGroup; } else { group tmp = new group(); tmp.list.Add(a); tmp.list.Add(b); a.myGroup = tmp; b.myGroup = tmp; sector.groups.Add(tmp); } } }
public static void groupSectors(groupingCondition cnd, ref sector[,] grid, int gridsize) { foreach (sector s in grid) { s.myGroup = null; } groups.Clear(); for (int x = 0; x < gridsize; x++) { for (int y = 0; y < gridsize; y++) { sector s = grid[x, y]; if ((x < gridsize - 1) && (cnd(s, grid[x + 1, y]))) { checkGroups(s, grid[x + 1, y]); } if ((y < gridsize - 1) && (cnd(s, grid[x, y + 1]))) { checkGroups(s, grid[x, y + 1]); } } } }
public ActionResult EditSector(EditSector ae) { if (ModelState.IsValid) { using (mmpEntities mP = new mmpEntities()) { #region Sector Already Exists var isSectorExists = IsSectorExist(ae.sector_name); if (isSectorExists) { ModelState.AddModelError("SectorExists", "Sector already exists"); return(View(ae)); } #endregion sector sector = new sector() { sector_id = ae.sector_id, sector_name = ae.sector_name }; mP.Entry(sector).State = EntityState.Modified; mP.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } return(View()); }
void Start() { int cnt = colors.Length; materials = new Material[colors.Length]; for (int i = 0; i < cnt; i++) { materials[i] = Instantiate <Material>(blockMaterial); materials[i].SetColor("_Color", colors[i]); } if (!LoadGame()) { grid = new sector[gridsize, gridsize]; for (int x = 0; x < gridsize; x++) { for (int y = 0; y < gridsize; y++) { grid[x, y] = new sector(x, y); } } StartGame(); } }
public static void EliminarSector(short IdSector) { RBVDataContext contextoRBV = new RBVDataContext(); sector sectorEliminar = new sector(); sectorEliminar = contextoRBV.sector.SingleOrDefault(p => p.idSector == IdSector); contextoRBV.sector.DeleteOnSubmit(sectorEliminar); contextoRBV.SubmitChanges(); }
static ulong largestPalindromeSectors(int input) { ulong largest = 0; ulong startingFactor = (ulong)Math.Pow(10, input) - 1; ulong endingFactor = (ulong)Math.Pow(10, input - 1) - 1; ulong sectorSize = (ulong)Math.Pow(10, (input + 2) / 2) / 2; ulong sectorNumber = (ulong)Math.Pow(10, (input - 1) / 2) * 2; sector[] sectors = new sector[(sectorNumber + 1) * sectorNumber / 2]; int index = 0; for (ulong i = 0; i < sectorNumber; i++) { for (ulong j = i; j < sectorNumber; j++) { sectors[index].startingPointI = startingFactor - i * sectorSize; sectors[index++].startingPointJ = startingFactor - j * sectorSize; } } sectors = sectors.OrderByDescending((s) => s.startingPointI * s.startingPointJ).ToArray(); for (int k = 0; k < sectors.Length; ++k) { sector s = sectors[k]; if (s.startingPointI * s.startingPointJ < largest) { break; } ulong endI = s.startingPointI - sectorSize; for (ulong i = s.startingPointI; i > endI; --i) { ulong endJ = s.startingPointJ - sectorSize; if (largest >= i * s.startingPointJ) { break; } for (ulong j = s.startingPointJ; j > endJ; --j) { ulong local = j * i; if (largest >= local) { break; } if (isPalindrome(local)) { largest = local; } } } } return(largest); }
void updatePointedSector() { RaycastHit hit; if (_collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 9999)) { Vector2 pos = hit.textureCoord * gridsize; pointedSector = grid[(int)pos.x, (int)pos.y]; } }
void SetSectorValue(sector sec, BlockScript b) { sec.myBlock = b; if (b != null) { b.mySector = sec; b.transform.position = sectorToPosition(sec); b.transform.localScale = Vector3.one; } }
public static void ActualizarSector(Sector sector) { RBVDataContext contextoRBV = new RBVDataContext(); sector sectorAnterior = new sector(); sectorAnterior = contextoRBV.sector.SingleOrDefault(p => p.idSector == sector.IdSector); sectorAnterior.sector1 = sector.NombreSector; contextoRBV.SubmitChanges(); }
void SetSectorValue(sector sec, BlockScript b) { sec.myBlock = b; if (b != null) { b.mySector = sec; b.transform.position = sectorToPosition(sec); b.transform.localScale = Vector3.one; b.gameObject.layer = pixelsLayer; } UpdateBG(); }
public void Sector_With_Valid_Radius_Get_Arc() { //Arrange double r = 4; double angle = 180; double expected = 12.566; Sector sector = new sector(); //Act sector.R = r; sector.Angle = angle; double actual = sector.GetArc(); //Assert Assert.AreEqual(expected, actual, 0.001, "Area wasn't calculated correctly"); }
private void btnUpdate_Click(object sender, EventArgs e) { try { if (lblerror1.Visible == true) { MessageBox.Show("Sector name is already in use!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtID.Text == string.Empty || txtID.Text == "(Auto Generated)") { MessageBox.Show("Please select user to update!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty) { MessageBox.Show("Please input Insitution type!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { sec = new sector(int.Parse(txtID.Text), txtTitle.Text); DBAccess.update_sector(sec); dgv_sector.DataSource = DBAccess.dataTableLoad("sp_load_sector"); logs = new auditTrail(frm_login.UserName, "Updated sector id " + txtID.Text); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Updated!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } // clear(); }
private void btnSave_Click(object sender, EventArgs e) { try { if (lblerror1.Visible == true) { MessageBox.Show("Sector title is already in use!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty) { MessageBox.Show("Please complete the required data!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { sec = new sector(txtTitle.Text); DBAccess.insert_sector(sec); dgv_sector.DataSource = DBAccess.dataTableLoad("sp_load_sector"); btnUpdate.Visible = true; btnAdd.Visible = true; btnUpdate.Visible = true; btnSave.Visible = false; btnCancel.Visible = false; dgv_sector.Enabled = true; logs = new auditTrail(frm_login.UserName, "Added a Sector "); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
void updatePointedSector() { if (placing) { pressure = Mathf.Lerp(pressure, 1, Time.deltaTime * 5); } else { pressure = Mathf.Lerp(pressure, 0, Time.deltaTime * 0.5f); } RaycastHit hit; if (_collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 9999)) { pressurePos = hit.textureCoord; Vector2 pos = hit.textureCoord * gridsize; pointedSector = grid[(int)pos.x, (int)pos.y]; } Shader.SetGlobalVector("_touchPoint", new Vector4(pressurePos.x, pressurePos.y, pressure, 0)); }
void Start() { if (!audioSource) { audioSource = gameObject.GetComponent <AudioSource>(); if (!audioSource) { audioSource = gameObject.AddComponent <AudioSource>(); } } int cnt = colors.Length; materials = new Material[colors.Length]; for (int i = 0; i < cnt; i++) { materials[i] = Instantiate(blockMaterial); materials[i].SetColor("_Color", colors[i]); } if (!LoadGame()) { grid = new sector[gridsize, gridsize]; for (int x = 0; x < gridsize; x++) { for (int y = 0; y < gridsize; y++) { grid[x, y] = new sector(x, y); } } StartGame(); } }
public bool nextTo(sector other) { return(((other.x == x) || (other.y == y)) && ((Mathf.Abs(x - other.x) == 1) || (Mathf.Abs(y - other.y) == 1))); }
bool groupEmpty(sector a, sector b) { return((a.myBlock == null) && (b.myBlock == null)); }
bool CompareColors(sector a, sector b) { return((a.myBlock != null) && (b.myBlock != null) && (a.myBlock.myColor == b.myBlock.myColor)); }
Vector3 sectorToPosition(sector sec) { float d = (gridsize - 1f) * 0.5f; return((Vector3.zero + Vector3.up * (d - sec.y) + Vector3.right * (d - sec.x)) * 2); }
return(new double[] { this.getElevations(sector, latLons, targetResolutions[0], elevations) });