public async Task <int> AddWarehouseAsync(WarehouseDto warehouseDto) { using (var db = new CourierHelperDb(_connectionString)) { if (warehouseDto.Location == null) { throw new ArgumentException("Warehouse location is required!"); } ActivePoint location = new ActivePoint { Coordinates = new Point(warehouseDto.Location.Longitude, warehouseDto.Location.Latitude) }; Warehouse warehouse = new Warehouse { Location = location, Address = warehouseDto.Address, Name = warehouseDto.Name }; db.WarehousesRepo.Create(warehouse); await db.SaveAsync(); return(warehouse.Id); } }
private void ChangeTrack(Courier courier, CourierHelperDb db) { if (courier.State > CourierState.Idle) { Track currentTrack = courier.Tracks.FirstOrDefault(t => t.IsCurrent); ActivePoint newPoint = new ActivePoint { Coordinates = new Point(courier.Location.Coordinates.Longitude, courier.Location.Coordinates.Latitude) }; if (currentTrack == null) { currentTrack = new Track { IsCurrent = true }; currentTrack.Points.Add(newPoint); courier.Tracks.Add(currentTrack); } else { currentTrack.Points.Add(newPoint); db.TracksRepo.Update(currentTrack); } } }
private void PictureBox1_Click(object sender, MouseEventArgs e) { if (activeLine != null) { switch (ap) { case ParcourOverview.ActivePoint.A: { ap = ParcourOverview.ActivePoint.B; break; } case ParcourOverview.ActivePoint.B: { ap = ParcourOverview.ActivePoint.O; break; } case ParcourOverview.ActivePoint.O: { ap = ParcourOverview.ActivePoint.NONE; activeLine = null; break; } } } else { SetSelectedLine(hoverLine); } }
private void btnAddEnd_Click(object sender, EventArgs e) { SetSelectedLine(null); if (activeParcour.Line.Any(p => p.Type == (int)LineType.END)) { activeLine = activeParcour.Line.Single(p => p.Type == (int)LineType.END); } else { activeLine = new Line(); activeLine.Type = (int)LineType.END; activeParcour.Line.Add(activeLine); } ap = ActivePoint.A; }
private void btnAddLineOfNoReturn_Click(object sender, EventArgs e) { SetSelectedLine(null); if (activeParcour.Line.Any(p => p.Type == (int)LineType.NOBACKTRACKLINE)) { activeLine = activeParcour.Line.Single(p => p.Type == (int)LineType.NOBACKTRACKLINE); } else { activeLine = new Line(); activeLine.Type = (int)LineType.NOBACKTRACKLINE; activeParcour.Line.Add(activeLine); } ap = ActivePoint.A; }
public void BuildSuffixTree(string inputStr) { this.str = inputStr + '$'; this.root = new SuffixNode(-1, null, -1, this.root); remSuffix = 0; globalEnd = new End(-1); active = new ActivePoint(this.root, -1, 0); for (int i = 0; i < str.Length; i++) { this.StartPhase(i); } }
public override int GetHashCode() { // We are fortunate enough to have 3 interesting points here. If you xor an even number of snapshot point hashcodes // together, the snapshot component gets cancelled out. // However, the common case is that ActivePoint and InsertionPoint are exactly equal, so we need to do something to change that. // Invert the bytes in InsertionPoint.GetHashCode(). var insertionHash = (uint)InsertionPoint.GetHashCode(); insertionHash = (((0x0000FFFF & insertionHash) << 16) | ((0xFFFF0000 & insertionHash) >> 16)); int pointHashes = AnchorPoint.GetHashCode() ^ ActivePoint.GetHashCode() ^ (int)insertionHash; // InsertionPointAffinity.GetHashCode() returns either 0 or 1 which can get stomped on by the rest of the hash codes. // Generate more interesting hash code values below: int affinityHash = InsertionPointAffinity == PositionAffinity.Predecessor ? affinityHash = 04122013 : affinityHash = 10172014; return(pointHashes ^ affinityHash); }
public async Task <Guid> AddCourierAsync(CourierDto courierDto) { if (string.IsNullOrWhiteSpace(courierDto.PhoneNumber)) { throw new ArgumentException("Phone number is required"); //todo: better exception } using (var db = new CourierHelperDb(_connectionString)) { Courier courier = new Courier { FirstName = courierDto.FirstName, LastName = courierDto.LastName, MiddleName = courierDto.MiddleName, Email = courierDto.Email, PhoneNumber = courierDto.PhoneNumber, State = (CourierState)courierDto.State }; if (courierDto.Location != null) { ActivePoint location = new ActivePoint { Coordinates = new Point(courierDto.Location.Longitude, courierDto.Location.Latitude) }; courier.Location = location; } db.CouriersRepo.Create(courier); await db.SaveAsync(); courierDto.Id = courier.Id; return(courier.Id); } }
private void btnAddLineOfNoReturn_Click(object sender, EventArgs e) { SetSelectedLine(null); if (activeParcour.Line.Any(p => p.Type == (int)LineType.LINEOFNORETURN)) { activeLine = activeParcour.Line.Single(p => p.Type == (int)LineType.LINEOFNORETURN); } else { activeLine = new Line(); activeLine.Type = (int)LineType.LINEOFNORETURN; activeParcour.Line.Add(activeLine); } ap = ActivePoint.A; }
private void PictureBox1_Click(object sender, MouseEventArgs e) { if (activeLine != null) { switch (ap) { case ParcourGen.ActivePoint.A: { ap = ParcourGen.ActivePoint.B; break; } case ParcourGen.ActivePoint.B: { ap = ParcourGen.ActivePoint.O; break; } case ParcourGen.ActivePoint.O: { ap = ParcourGen.ActivePoint.NONE; activeLine = null; break; } } } else { SetSelectedLine(hoverLine); } }
///<summary> /// Generate a point at given location ///</summary> void CreatePoint(Vector3 center, int row, int column) { float r = rectTransform.rect.width * pointSize; Color32 color = colors[row % colorCount, 1]; switch (point) { case PointType.CIRCLE: { Vector3 p1 = new Vector3(r, 0, 0); ActivePoint ap = new ActivePoint(); ap.firstVertex = vertices.Count; ap.quadsCount = 36; ap.row = row; ap.column = column; ap.rect = new Rect(center.x - r, center.y + r, r * 2, r * 2); points.Add(ap); for (int j = 0; j < 36; j++) { Vector3 p = p1; Vector3 p0 = Quaternion.Euler(0, 0, -(360 / 72)) * p; p1 = Quaternion.Euler(0, 0, -(360 / 72)) * p0; AddQuad(center, center + p, center + p0, center + p1, color); } } break; case PointType.RECTANGLE: { ActivePoint ap = new ActivePoint(); ap.firstVertex = vertices.Count; ap.quadsCount = 1; ap.row = row; ap.column = column; ap.rect = new Rect(center.x - r, center.y + r, r * 2, r * 2); points.Add(ap); Vector3 p0 = center + new Vector3(-r, -r, 0); Vector3 p1 = center + new Vector3(-r, r, 0); Vector3 p2 = center + new Vector3(r, r, 0); Vector3 p3 = center + new Vector3(r, -r, 0); AddQuad(p0, p1, p2, p3, color); } break; case PointType.TRIANGLE: { ActivePoint ap = new ActivePoint(); ap.firstVertex = vertices.Count; ap.quadsCount = 1; ap.row = row; ap.column = column; ap.rect = new Rect(center.x - r, center.y + r, r * 2, r * 2); points.Add(ap); Vector3 p0 = center + new Vector3(0, r, 0); Vector3 p1 = center + new Vector3(r, -r, 0); Vector3 p2 = center + new Vector3(0, -r, 0); Vector3 p3 = center + new Vector3(-r, -r, 0); AddQuad(p0, p1, p2, p3, color); } break; case PointType.NONE: { ActivePoint ap = new ActivePoint(); ap.firstVertex = 0; ap.quadsCount = 0; ap.row = row; ap.column = column; ap.rect = new Rect(center.x - r, center.y + r, r * 2, r * 2); points.Add(ap); } break; } }