void site_Drop(object sender, DragEventArgs e) { var latLongCtl = (sender as Control).FindParent <LatLongInput>(); bool setX1Y1 = true; if (latLongCtl != null) { if (latLongCtl.Name == ctlX2.Name || latLongCtl.Name == ctlY2.Name) { setX1Y1 = false; } } var pinnable = e.Data.GetData(PinnableObject.DRAG_FORMAT_NAME) as PinnableObject; if (pinnable != null && pinnable.LookupType == LookupType.PlaceName) { PlaceName placeName = pinnable.GetState <PlaceName>(); if (!setX1Y1) { ctlY2.Value = placeName.Latitude; ctlX2.Value = placeName.Longitude; } else { ctlY1.Value = placeName.Latitude; ctlX1.Value = placeName.Longitude; UpdateLocality(placeName); } } e.Handled = true; }
private void DoSelect() { PlaceName result = null; if (optFindLatLong.IsChecked.GetValueOrDefault(false)) { result = _offsetControl.OffsetPlace; } if (result == null) { var selected = lstResults.SelectedItem as PlaceNameViewModel; if (selected != null) { result = selected.Model; } } if (result != null && _selectionCallback != null) { var selResult = new SelectionResult { ObjectID = null, DataObject = result, Description = result.Name }; _selectionCallback(selResult); } }
private void UpdateLocality(PlaceName placeName) { string place = placeName.Name; if (placeName.PlaceNameType == PlaceNameType.OffsetAndDirection) { place = string.Format("{0} {1} {2} of {3}", placeName.Offset, placeName.Units, placeName.Direction, placeName.Name); } var updateLocality = OptionalQuestions.UpdateLocalityQuestion.Ask(this.FindParentWindow(), _viewModel.Locality, place); if (updateLocality) { if (placeName.PlaceNameType == PlaceNameType.OffsetAndDirection) { optNearestPlace.IsChecked = true; _viewModel.Locality = placeName.Name; txtDistanceFrom.Text = string.Format("{0} {1}", placeName.Offset, placeName.Units); txtDirectionFrom.Text = placeName.Direction; } else { optLocality.IsChecked = true; } _viewModel.Locality = placeName.Name; } }
public MapMarker(IXivSubRow sRow, Map map) { SubKey = sRow.Key; MapKey = sRow.ParentKey; MapX = map.ToMapCoordinate2d((Int16)sRow["X"], map.OffsetX); MapY = map.ToMapCoordinate2d((Int16)sRow["Y"], map.OffsetY); IsRegion = ((byte)sRow["Type"]) == 1; DataType = (byte)sRow["Data{Type}"]; PlaceName = (PlaceName)sRow["PlaceName{Subtext}"]; }
public override int GetHashCode() { unchecked { var hashCode = (PlaceName != null ? PlaceName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PlaceAddress != null ? PlaceAddress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PlaceUrl != null ? PlaceUrl.GetHashCode() : 0); return(hashCode); } }
public List <PlaceName> FindPlaceNames(string find, int maxrows = 1000) { List <PlaceName> list = new List <PlaceName>(); try { string sql = "SELECT tPlace as Name, tType as PlaceType, tDivision as Division, tLatitude as LatitudeString, tLongitude as LongitudeString, dblLatitude as Latitude, dblLongitude as Longitude FROM tblGaz WHERE tPlace like @find ORDER BY tDivision, tPlace, tType LIMIT @limit"; SelectReader(sql, (reader) => { PlaceName place = new PlaceName(); MapperBase.ReflectMap(place, reader, null, null); list.Add(place); }, new SQLiteParameter("@find", find + "%"), new SQLiteParameter("@limit", maxrows)); } catch (Exception ex) { GlobalExceptionHandler.Handle(ex); } return(list); }
public string Validate(string propertyName) { string result = string.Empty; switch (propertyName) { case nameof(PlaceName): if (string.IsNullOrWhiteSpace(PlaceName) || !PlaceName.ValidateFileName()) { result = "Invalid filename."; } else if (File.Exists(GetPath())) { result = "A place with that name already exists."; } break; } return(result); }
void PositionControl_Drop(object sender, DragEventArgs e) { var pinnable = e.Data.GetData(PinnableObject.DRAG_FORMAT_NAME) as PinnableObject; if (pinnable != null && pinnable.LookupType == LookupType.PlaceName) { PlaceName placeName = pinnable.GetState <PlaceName>(); this.lat.Value = placeName.Latitude; lon.Value = placeName.Longitude; if (LocationChanged != null) { var locality = placeName.Name; if (placeName.PlaceNameType == PlaceNameType.OffsetAndDirection) { locality = string.Format("{0} {1} {2} of {3}", placeName.Offset, placeName.Units, placeName.Direction, placeName.Name); } LocationChanged(placeName.Latitude, placeName.Longitude, null, null, locality, "EGaz"); } } e.Handled = true; }
public List <PlaceName> GetPlacesInBoundedBox(double x1, double y1, double x2, double y2, string placeType) { var list = new List <PlaceName>(); try { string sql = "SELECT tPlace as Name, tType as PlaceType, tDivision as Division, tLatitude as LatitudeString, tLongitude as LongitudeString, dblLatitude as Latitude, dblLongitude as Longitude FROM tblGaz WHERE (dblLatitude BETWEEN @y1 AND @y2) AND (dblLongitude BETWEEN @x1 AND @x2)"; if (!string.IsNullOrEmpty(placeType)) { sql += " and tType = @div"; } SelectReader(sql, (reader) => { PlaceName place = new PlaceName(); MapperBase.ReflectMap(place, reader, null, null); list.Add(place); }, new SQLiteParameter("@y1", y1), new SQLiteParameter("@y2", y2), new SQLiteParameter("@x1", x1), new SQLiteParameter("@x2", x2), new SQLiteParameter("@div", placeType)); } catch (Exception ex) { GlobalExceptionHandler.Handle(ex); } return(list); }
void ReleaseDesignerOutlets() { if (PlaceName != null) { PlaceName.Dispose(); PlaceName = null; } if (PlaceAddress != null) { PlaceAddress.Dispose(); PlaceAddress = null; } if (PlaceDistance != null) { PlaceDistance.Dispose(); PlaceDistance = null; } if (PlaceOpenHours != null) { PlaceOpenHours.Dispose(); PlaceOpenHours = null; } if (PlacePhone != null) { PlacePhone.Dispose(); PlacePhone = null; } if (MapView != null) { MapView.Dispose(); MapView = null; } }
/// <summary> /// Save a place record to the database. Use this if you have a connection open. /// </summary> /// <param name="sUserUpdating">Name of the user who is saving the record.</param> public void Save(int iUserID) { MethodBase lmth = MethodBase.GetCurrentMethod(); string lsRoutineName = lmth.DeclaringType + "." + lmth.Name; if (RecordStatus == RecordStatuses.Delete) { if (CharacterPlaceID != -1) { SortedList sParam = new SortedList(); sParam.Add("@RecordID", CharacterPlaceID); sParam.Add("@UserID", iUserID); cUtilities.PerformNonQuery("uspDelCHCharacterPlaces", sParam, "LARPortal", iUserID.ToString()); } } else { SortedList sParam = new SortedList(); sParam.Add("@CharacterPlaceID", CharacterPlaceID); sParam.Add("@CharacterID", CharacterID); if (CampaignPlaceID.HasValue) { sParam.Add("@PlaceID", CampaignPlaceID.Value); } else { sParam.Add("@ClearCampaignPlaceID", 1); } sParam.Add("@CampaignID", CampaignID); sParam.Add("@PlaceName", PlaceName.ToString()); sParam.Add("@LocatedInPlaceID", LocaleID); sParam.Add("@StaffComments", StaffComments.ToString()); sParam.Add("@PlayerComments", Comments.ToString()); sParam.Add("@UserID", iUserID); cUtilities.PerformNonQuery("uspInsUpdCHCharacterPlaces", sParam, "LARPortal", iUserID.ToString()); } }
public FateTarget(Fate fate, PlaceName placeName) { Fate = fate; PlaceName = placeName; }
public override int GetHashCode() { return(PlaceName.GetHashCode()); }
private Item GetItem(long key, int requiredAmount) { Item item = _context.Items .Where(_item => key == _item.Key) .Select(_item => new Item { key = _item.Key, nameKo = _item.UINameKo, nameEn = _item.UINameEn, iconPath = _item.IconPath, requiredAmount = requiredAmount, recipes = _item.CraftRecipes.Select(recipe => new Recipe { key = recipe.Key, level = recipe.LevelView, totalCrafted = recipe.CraftNum, numStarsArray = new int[(int)recipe.LevelDiff], craftingJob = new Job { key = recipe.CraftJob.Key, nameKo = recipe.CraftJob.NameKo, nameEn = recipe.CraftJob.NameEn, iconPath = "/assets/ui/icon/062000/" + ((long)((recipe.CraftJob.Key) + 62100L)).ToString("D6") + ".tex.png" } }).ToArray(), gatherings = _item.Gatherings.Select(gathering => new Gathering { key = gathering.Key, gatheringJob = new Job { key = gathering.GatheringJob.Key, nameKo = gathering.GatheringJob.NameKo, nameEn = gathering.GatheringJob.NameEn, iconPath = "/assets/ui/icon/062000/" + ((long)(gathering.GatheringJob.Key + 62100L)).ToString("D6") + ".tex.png" }, numStarsArray = new int[(int)gathering.LevelDiff], isHidden = gathering.IsHidden, gatheringSubCategory = gathering.GatheringSubCategory != null ? new GatheringSubCategory { key = gathering.GatheringSubCategory.Key, nameKo = gathering.GatheringSubCategory.NameKo, nameEn = gathering.GatheringSubCategory.NameEn } : null, gatheringPoints = gathering.GatheringPoints .Where(gatheringPoint => gatheringPoint.Level != null) .Select(gatheringPoint => new GatheringPoint { key = gatheringPoint.Key, level = gatheringPoint.Level, placeKey = gatheringPoint.PlaceName.Key, placeNameKo = gatheringPoint.PlaceName.SGLKo, placeNameEn = gatheringPoint.PlaceName.SGLEn, children = new GatheringPoint[0] }).ToArray() }).ToArray(), shops = _item.ItemShops.Select(itemShop => itemShop.Shop) .Select(shop => new Shop { key = shop.Key, nameKo = shop.NameKo, nameEn = shop.NameEn, beastTribe = shop.BeastTribe != null ? new BeastTribe { key = shop.BeastTribe.Key, nameKo = shop.BeastTribe.SGLKo, nameEn = shop.BeastTribe.SGLEn } : null, quest = shop.Quest != null ? new Quest { key = shop.Quest.Key, nameKo = shop.Quest.NameKo, nameEn = shop.Quest.NameEn } : null, npcs = shop.ENpcShops.Select(eNpcShop => eNpcShop.ENpc) .Select(eNpc => new Npc { key = eNpc.Key, nameKo = eNpc.SGLKo, nameEn = eNpc.SGLEn }).ToArray() }).ToArray() }).FirstOrDefault(); if (item != null) { List <Gathering> gatherings = new List <Gathering>(); foreach (Gathering gathering in item.gatherings) { Gathering candidate = gatherings.Where(_gathering => _gathering.gatheringJob.key == gathering.gatheringJob.key && _gathering.numStarsArray.Length == gathering.numStarsArray.Length && _gathering.isHidden == gathering.isHidden && (_gathering.gatheringSubCategory == null ? gathering.gatheringSubCategory == null : _gathering.gatheringSubCategory.key == gathering.gatheringSubCategory.key)).FirstOrDefault(); if (candidate != null) { candidate.gatheringPoints = candidate.gatheringPoints.Concat(gathering.gatheringPoints).ToArray(); } else { gatherings.Add(gathering); } } item.gatherings = gatherings.ToArray(); foreach (Gathering gathering in item.gatherings) { while (gathering.gatheringPoints.Any(gatheringPoint => _context.GatheringPoints.Any(_gatheringPoint => _gatheringPoint.Key == gatheringPoint.key && _gatheringPoint.Parent != null))) { List <GatheringPoint> newGatheringPoints = new List <GatheringPoint>(); foreach (GatheringPoint gatheringPoint in gathering.gatheringPoints) { GatheringPoint existingGatheringPoint = FindGatheringPointRecursively(newGatheringPoints, gatheringPoint.placeKey); if (existingGatheringPoint != null) { if (existingGatheringPoint.level != null && gatheringPoint.level != null) { existingGatheringPoint.level = Math.Min((long)existingGatheringPoint.level, (long)gatheringPoint.level); } existingGatheringPoint.children = existingGatheringPoint.children.Concat(gatheringPoint.children).ToArray(); continue; } FFXIVTranslator.PorierFFXIV.GatheringPoint parentGatheringPoint = _context.GatheringPoints.Where(_gatheringPoint => _gatheringPoint.Key == gatheringPoint.key) .Select(_gatheringPoint => _gatheringPoint.Parent) .FirstOrDefault(); if (parentGatheringPoint == null) { newGatheringPoints.Add(gatheringPoint); } else { GatheringPoint newGatheringPoint = new GatheringPoint { key = parentGatheringPoint.Key, level = parentGatheringPoint.Level, children = new GatheringPoint[1] { gatheringPoint } }; PlaceName placeName = _context.GatheringPoints.Where(_gatheringPoint => _gatheringPoint.Key == parentGatheringPoint.Key) .Select(_gatheringPoint => _gatheringPoint.PlaceName) .FirstOrDefault(); if (placeName != null) { newGatheringPoint.placeKey = placeName.Key; newGatheringPoint.placeNameKo = placeName.SGLKo; newGatheringPoint.placeNameEn = placeName.SGLEn; } GatheringPoint candidate = FindGatheringPointRecursively(newGatheringPoints, newGatheringPoint.placeKey); if (candidate != null) { if (candidate.level != null && newGatheringPoint.level != null) { candidate.level = Math.Min((long)candidate.level, (long)newGatheringPoint.level); } candidate.children = candidate.children.Concat(newGatheringPoint.children).ToArray(); } else { newGatheringPoints.Add(newGatheringPoint); } } } gathering.gatheringPoints = newGatheringPoints.ToArray(); } } foreach (Gathering gathering in item.gatherings) { MergeNullPlaces(gathering.gatheringPoints); } foreach (Shop shop in item.shops) { foreach (Npc npc in shop.npcs) { ENpcPlaceName eNpcPlaceName = _context.ENpcs .Where(eNpc => eNpc.Key == npc.key) .SelectMany(eNpc => eNpc.ENpcPlaceNames) .Where(_eNpcPlaceName => _eNpcPlaceName.PlaceName != null) .FirstOrDefault(); if (eNpcPlaceName != null) { npc.x = eNpcPlaceName.X; npc.y = eNpcPlaceName.Y; npc.place = _context.ENpcPlaceNames .Where(_eNpcPlaceName => _eNpcPlaceName.Key == eNpcPlaceName.Key) .Select(_eNpcPlaceName => _eNpcPlaceName.PlaceName) .Select(placeName => new Place { key = placeName.Key, nameKo = placeName.SGLKo, nameEn = placeName.SGLEn }) .FirstOrDefault(); Place currentPlace = npc.place; while (true) { PlaceName region = _context.PlaceNames.Where(placeName => placeName.Key == currentPlace.key).Select(placeName => placeName.Region).FirstOrDefault(); if (region == null) { break; } currentPlace.parent = new Place { key = region.Key, nameKo = region.SGLKo, nameEn = region.SGLEn }; currentPlace = currentPlace.parent; } } } } } return(item); }
public GenericLocation(PlaceName placeName, double x, double y) { this.MapX = x; this.MapY = y; this.PlaceName = placeName; }
internal void Clear() { txtDistance.Clear(); OffsetPlace = null; }
private PlaceName OffsetLatLong(double offset, string Units, string Direction, PlaceName source) { // set degrees per unit as follows: // mean radius of earth is 3959 miles or 6371 kilometers. // circumference = 2 x Pi x radius. // DegsPerUnit = 360 / circumference. double DegsPerUnit = 0; if (Units.ToUpper()[0] == 'K') // Units = Kilometers { DegsPerUnit = 0.0089932; } else if (Units.ToUpper().Substring(0, 2) == "MI") // Units = Miles { DegsPerUnit = 0.0144722; } else // Units undefined { return(null); } double DirDeg = 0; // change compass directions into degrees. degrees are measured E & W from N and E & W from S. there are 32 compass points. 360/32 = 11.25 degrees each. switch (Direction) { case "N": case "S": DirDeg = 0 * 11.25; break; case "NbyE": case "NbyW": case "SbyE": case "SbyW": DirDeg = 1 * 11.25; break; case "NNE": case "NNW": case "SSE": case "SSW": DirDeg = 2 * 11.25; break; case "NEbyN": case "NWbyN": case "SEbyS": case "SWbyS": DirDeg = 3 * 11.25; break; case "NE": case "NW": case "SE": case "SW": DirDeg = 4 * 11.25; break; case "NEbyE": case "NWbyW": case "SEbyE": case "SWbyW": DirDeg = 5 * 11.25; break; case "ENE": case "WNW": case "ESE": case "WSW": DirDeg = 6 * 11.25; break; case "EbyN": case "WbyN": case "EbyS": case "WbyS": DirDeg = 7 * 11.25; break; case "E": case "W": DirDeg = 8 * 11.25; break; default: // error in direction return(null); } int NSHem = 0; int EWHem = 0; int NSDir = 0; int EWDir = 0; string InitLat = source.LatitudeString; string InitLong = source.LongitudeString; // find what hemisphere we're in & set to positive or negative if (InitLat.EndsWith("N")) { NSHem = 1; // set to positive } else { NSHem = -1; // set to negative } if (InitLong.EndsWith("E")) { EWHem = 1; // set to pos } else { EWHem = -1; // set to neg } // find what quadrant we're in & set to positive or negative if (Direction.Contains("N")) { NSDir = 1; // set to pos } else { NSDir = -1; // set to neg } if (Direction.Contains("E")) { EWDir = 1; // set to pos } else { EWDir = -1; // set to neg } int NSCor = NSHem * NSDir; // set correction (adjustment) to pos or neg int EWCor = EWHem * EWDir; // pos*pos=pos, neg*neg=pos, pos*neg=neg string ILatDir = InitLat.Substring(InitLat.Length - 1); // get lat direction string ILonDir = InitLong.Substring(InitLong.Length - 1); // get long direction string strError; double ILat = 0; double ILon = 0; if (!GeoUtils.DMSStrToDecDeg(InitLat, CoordinateType.Latitude, out ILat, out strError)) { ErrorMessage.Show(strError); return(null); } if (!GeoUtils.DMSStrToDecDeg(InitLong, CoordinateType.Longitude, out ILon, out strError)) { ErrorMessage.Show(strError); return(null); } ILon = Math.Abs(ILon); ILat = Math.Abs(ILat); double CosDir = Math.Cos(DirDeg * 0.017453292); // get cosine of direction (.017+ is Pi/180, and changes degrees to radians as required by basic) double LatOff = CosDir * offset; // Latitude adj in units double LatAdj = LatOff * DegsPerUnit * NSCor; // convert to degrees & make + or - double NewLat = ILat + LatAdj; // new latitude in degrees. a negative is minus if (NewLat < 0) // we've crossed the Equator { NewLat = Math.Abs(LatAdj) - ILat; // put remainder on other side if (ILatDir == "N") // change hemispheres { ILatDir = "S"; } else { ILatDir = "N"; } } double SinDir = Math.Sin(DirDeg * 0.017453292); // get sine of direction double LonOff = SinDir * offset; // Longitude adj in units double CosNewLat = Math.Cos(NewLat * 0.017453292); // get cosine of new latitude double NewDPU = DegsPerUnit / CosNewLat; // correct DPU for new latitude double LonAdj = LonOff * NewDPU * EWCor; // convert to degrees & make + or - double NewLon = ILon + LonAdj; // new longitude in degrees if (NewLon < 0 || NewLon > 180) // we've crossed 0 or 180 meridian { if (NewLon < 0) { NewLon = Math.Abs(LonAdj) - ILon; // put diff on other side } if (NewLon > 180) { NewLon = 180 - (NewLon - 180); // subtract overage fm } if (ILonDir == "E") // change hemispheres '180 { ILonDir = "W"; } else { ILonDir = "E"; } } int intLongSign = 1; if (ILonDir == "W") { intLongSign = -1; } int intLatSign = 1; if (ILatDir == "S") { intLatSign = -1; } var pn = new PlaceName(); pn.PlaceNameType = PlaceNameType.OffsetAndDirection; pn.Name = source.Name; pn.Division = source.Division; pn.PlaceType = source.PlaceType; pn.Latitude = NewLat * intLatSign; pn.Longitude = NewLon * intLongSign; pn.Offset = offset + ""; pn.Units = Units; pn.Direction = Direction; pn.LatitudeString = GeoUtils.DecDegToDMS(pn.Latitude, CoordinateType.Latitude); pn.LongitudeString = GeoUtils.DecDegToDMS(pn.Longitude, CoordinateType.Longitude); return(pn); }
public Location(PlaceName zonePlace, PlaceName locationPlace) { PlaceName = zonePlace; LocationPlaceName = locationPlace; }
public BNpcLocation(PlaceName regionPlaceName, PlaceName placeName, int minimumLevel, int maximumLevel) { this.RegionPlaceName = regionPlaceName; this.PlaceName = placeName; this.MinimumLevel = minimumLevel; this.MaximumLevel = maximumLevel; }