/// <summary> /// Gets the bearing. /// </summary> /// <param name="item">The item.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <returns>System.String.</returns> public static string GetBearing(StationItem item, double clientLat, double clientLon) { double lat = Convert.ToDouble(item.Latitude); double lon = Convert.ToDouble(item.Longitude); return(GeoAngle.FromDouble(GeoUtils.BearingTo(clientLat, lat, clientLon, lon)).ToString()); }
public void Try_GetStationInfo() { //var res = GetStationInfo("ON4NL"); //Assert.IsNotNull(res); //PrintInfo(res); //res = GetStationInfo("ON8RL"); //Assert.IsNotNull(res); //PrintInfo(res); //res = GetStationInfo("ON3NL"); //Assert.IsNotNull(res); //PrintInfo(res); //res = GetStationInfo("A61BK"); //Assert.IsNotNull(res); //PrintInfo(res); StationItem res = GetStationInfo("ON3rl"); Assert.IsNotNull(res); PrintInfo(res); }
/// <summary> /// Gets the call sign information. /// </summary> /// <param name="id">The identifier.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <param name="unit">The unit.</param> /// <returns>CallSignInfo.</returns> public CallSignInfo GetCallSignInfo(string id, double clientLat, double clientLon, string unit) { id = id.ToUpper(); CallSignInfo res = null; StationItem it = HamRadioProvider.HamRadio .GetStationInfo(id); if (it.SessionId == "UNKNOWN") { res = it.ToUnknown(); } else { res = it.ToCallSignInfo(); res.LongPath = GetLongPath(it, clientLat, clientLon, unit); res.ShortPath = GetShortPath(it, clientLat, clientLon, unit); res.Bearing = GetBearing(it, clientLat, clientLon); res.DisplayLatitude = GeoAngle.FromDouble(Convert.ToDouble(it.Latitude)).ToString(LocationFormat.Latitude); res.DisplayLongitude = GeoAngle.FromDouble(Convert.ToDouble(it.Longitude)).ToString(LocationFormat.Longtitude); } res.YourDisplayLatitude = GeoAngle.FromDouble(clientLat).ToString(LocationFormat.Latitude); res.YourDisplayLongitude = GeoAngle.FromDouble(clientLon).ToString(LocationFormat.Longtitude); res.YourGrid = CalculateGrid(clientLat, clientLon); return(res); }
private static string FindAppropriateArtistName(SongMetadata songMetadata, StationItem stationItem) { //This method tries to find a localized name for the artist, if applicable. This makes speech sound more natural. var builtInArtist = NepApp.MetadataManager.FindBuiltInArtist(songMetadata.Artist, stationItem.PrimaryLocale ?? "jp"); if (builtInArtist == null) { return(songMetadata.Artist); } //prefer native language over english name, if possible. if (builtInArtist.AltNames?.Length > 0) { foreach (var name in builtInArtist.AltNames.Where(x => x.NameLanguage.ToLower() != "en")) { if (CheckIfLocaleVoiceIsAvailable(name.NameLanguage) && name.NameLanguage.ToLower().Equals(stationItem.PrimaryLocale.ToLower() ?? "jp")) { return(name.Name); } } } //if no native language names are available, check if theres a specific way to pronounce their name. if (!string.IsNullOrWhiteSpace(builtInArtist.NameSayAs)) { return(builtInArtist.NameSayAs); } return(songMetadata.Artist); //fallback }
public bool CheckIfStationTilePinned(StationItem stationItem) { if (Crystal3.DeviceInformation.GetDevicePlatform() == Crystal3.Core.Platform.Xbox) { return(false); //not supported } return(SecondaryTile.Exists(GetStationItemTileId(stationItem))); }
public DetailsViewModel(StationItem selectedStationItem = null) { SelectedStationItem = selectedStationItem ?? StationItem.Empty; TimeTableRowItems = new ObservableCollection <TimeTableRowItem>(); SelectStationCommand = new Command(() => OnStationSelected()); }
public void AddStation(StationItem item) { if (m_lStationItemList.Contains(item)) { Debug.LogError("contains item!"); return; } m_lStationItemList.Add(item); }
internal string GetStationItemTileId(StationItem stationItem) { if (stationItem == null) { throw new ArgumentNullException(nameof(stationItem)); } return(stationItem.Name.GetHashCode().ToString()); }
public override void alignEdition(TypeEditor interfaceType, GlobalItem ownParent) { if (interfaceType == TypeEditor.ROUTECONFIG) { setEditable(); asMetadata = true; } parentStation = (StationItem)ownParent; }
public async Task <bool> UpdateItemAsync(StationItem item) { var oldItem = items.Where((StationItem arg) => arg.ID == item.ID).FirstOrDefault(); items.Remove(oldItem); items.Add(item); return(await Task.FromResult(true)); }
public StationDisplay(StationItem item) { int countPaths = 0; station = item; InitializeComponent(); SuspendLayout(); tablePaths.SuspendLayout(); StationName.Text = station.nameStation; ClearTable(); int cntPath = this.tablePaths.RowCount; foreach (var pointArea in item.stationArea) { if (pointArea.IsInterface()) { countPaths += pointArea.getStationConnector().stationPaths.getPaths().Count; } } if (countPaths > 0 && countPaths != item.StationPathsHelper.DefinedPath.Count) { this.label7.Text = "Please Load Paths:"; } else { label7.Text = "List of Paths seems OK:"; } foreach (var originPoint in station.StationPathsHelper.DefinedPath) { foreach (var destinPoint in originPoint.Value) { foreach (var possibility in destinPoint.Value) { AddPathData(originPoint.Key, possibility.Value); } } } tablePaths.ResumeLayout(false); tablePaths.PerformLayout(); ResumeLayout(false); #if false foreach (var pointArea in item.stationArea) { if (pointArea.IsInterface() && pointArea.getStationConnector().stationPaths.getPaths().Count > 0) { AddPathData(pointArea.stationConnector.getLabel(), pointArea.stationConnector.stationPaths); } } foreach (AEBufferItem buffer in item.insideBuffers) { AddPathData(buffer.NameBuffer, buffer.stationPaths); } #endif }
/// <summary> /// Called when [get all endpoints async completed]. /// </summary> /// <param name="items">The items.</param> public void OnGetStationInfoAsyncCompleted(StationItem items) { RaisePropertyChanged(Property.StationInfo); IsBusy = false; tmr.Start(); _swRequest.Stop(); RaisePropertyChanged(Property.RequestDuration); _swRequest.Reset(); }
private bool IsHostedStationProgramBeginning(SongMetadata songMetadata, StationItem currentStation, out StationProgram stationProgram) { try { //this function checkes for "hosted" programs which rely on metadata matching to activate. Func <StationProgram, bool> getStationProgram = x => { if (x.Style != StationProgramStyle.Hosted) { return(false); } if (!string.IsNullOrWhiteSpace(x.Host)) { if (x.Host.ToLower().Equals(songMetadata.Artist.Trim().ToLower())) { return(true); } } if (!string.IsNullOrWhiteSpace(x.HostRegexExpression)) { if (Regex.IsMatch(songMetadata.Artist, x.HostRegexExpression)) { return(true); } } return(false); }; if (currentStation?.Programs != null) { if (currentStation.Programs.Any(getStationProgram)) { //we're tuning into a special radio program. this may be a DJ playing remixes, for exmaple. stationProgram = currentStation.Programs?.First(getStationProgram); return(true); } } } catch (Exception) { #if DEBUG if (Debugger.IsAttached) { Debugger.Break(); } #endif } stationProgram = null; return(false); }
/// <summary> /// Gets the short path. /// </summary> /// <param name="item">The item.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <param name="unit">The unit.</param> /// <returns>System.String.</returns> public static string GetShortPath(StationItem item, double clientLat, double clientLon, string unit) { double lat = Convert.ToDouble(item.Latitude); double lon = Convert.ToDouble(item.Longitude); var res = Convert.ToString( unit == "mi" ? GeoUtils.DistanceTo(clientLat, lat, clientLon, lon, DistanceType.Miles) : GeoUtils.DistanceTo(clientLat, lat, clientLon, lon, DistanceType.Kilometers)); return(String.Format(unit == "mi" ? "{0} Mi" : "{0} km", res)); }
public bool CheckDecreaseIngredientAmount(StationItem pItem, int pAmount) { if (pItem == null) { return(false); } if (pItem.Amount > pAmount) { return(true); } return(false); }
void DrawIngredient(StationItem pItem) { CraftingItemUI itemUI = Instantiate(ItemUIPrefab, IngredientContainer); itemUI.Button.onClick.AddListener(delegate { Station.RemoveItem(pItem.ContainedItem); }); itemUI.IncreaseButton.onClick.AddListener(delegate { Station.IncreaseIngredientAmount(pItem); }); itemUI.DecreaseButton.onClick.AddListener(delegate { Station.DecreaseIngredientAmount(pItem); }); if (itemUI.Button != null) { itemUI.Button.interactable = false; } if (pItem != null) { if (itemUI.Button != null) { itemUI.Button.interactable = true; } itemUI.ItemIcon.color = Color.white; itemUI.ItemIcon.sprite = pItem.ContainedItem.Icon; itemUI.ItemAmount.text = "x" + pItem.Amount.ToString(); if (itemUI.ItemNameText != null) { itemUI.ItemNameText.text = pItem.ContainedItem.Name; } } else { if (itemUI.ItemNameText != null) { itemUI.ItemNameText.text = "No Recipe Selected"; } itemUI.ItemIcon.color = new Color(0, 0, 0, 0); itemUI.ItemAmount.text = ""; } DrawnItems.Add(itemUI); }
public virtual IActionResult AddStation([FromBody] StationItem body) { //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(201); //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(400); //TODO: Uncomment the next line to return response 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(409); throw new NotImplementedException(); }
public StationItem GetStationItem(string id) { StationItem item = null; for (int i = 0; i < m_lStationItemList.Count; i++) { if (m_lStationItemList[i].Index.ToString() == id) { item = m_lStationItemList[i]; } } return(item); }
/// <summary> /// To the call sign information. /// </summary> /// <param name="item">The item.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <returns>CallSignInfo.</returns> public static CallSignInfo ToCallSignInfo(this StationItem item) { return(new CallSignInfo { BioUrl = item.Bio, CallSign = item.CallId, DisplayLocation = String.Format("{0}, {1} {2}", item.Country, item.Address2, item.State), DisplayName = String.Format("{0} {1}", item.FirstName, item.LastName), Grid = item.Grid, ImageUrl = item.ImageUrl, Latitude = Convert.ToDouble(item.Latitude), Longitude = Convert.ToDouble(item.Longitude) }); }
private SongMetadata GetUnknownSongMetadata(StationItem stationPlaying = null, string radioProgram = null) { SongMetadata unknown = new SongMetadata() { Track = "Unknown Song", Artist = "Unknown Artist", RadioProgram = radioProgram, StationPlayedOn = (stationPlaying ?? CurrentStation)?.Name, StationLogo = (stationPlaying ?? CurrentStation)?.StationLogoUrl, IsUnknownMetadata = true }; return(unknown); }
public StationItem GetById(string urlSafeStopId) { StationItem result = new StationItem { ApplicationVersion = this.GetType().Assembly.GetName().Version.ToString(), StationName = null, UrlSafeStopId = urlSafeStopId }; using (var db = TrackerDb) { var dl = db.Downloads .OrderByDescending(d => d.download_date) .First(); var pred = db.Predictions .OrderByDescending(p => p.prediction_time) .First(); var trips = db.TripsByStations .Where(t => t.url_safe_stop_id == urlSafeStopId) .OrderBy(t => t.sched_dep_dt) .ThenBy(t => t.trip_direction) .ToList(); result.ScheduleTimeStamp = dl.download_date; result.PredictionTimeStamp = pred.prediction_time; var trains = new List <StationTrainItem>(); foreach (var trip in trips) { if (result.StationName == null) { result.StationName = trip.stop_name; } trains.Add(new StationTrainItem { Train = trip.trip_shortname, Direction = StationTrainItem.DirectionFromInt(trip.trip_direction), Destination = trip.trip_headsign, ControlCar = trip.vehicle_id, Scheduled = trip.sched_dep_dt, Predicted = trip.pred_dt }); } result.Trains = trains; } return(result); }
public bool AddItem(ItemBase pItem) { if (HasItem(pItem)) { return(false); } if (ChosenItems.Count >= Slots) { return(false); } StationItem newItem = new StationItem(); newItem.ContainedItem = pItem; newItem.Amount = 1; ChosenItems.Add(newItem); IngredientsChanged(); return(true); }
public bool CheckIncreaseIngredientAmount(StationItem pItem, int pAmount) { if (pItem == null) { return(false); } InventoryItemStack stack = GameManager.Instance.Player.GetComponent <PlayerInventory>().FindItemStack(pItem.ContainedItem); if (stack == null) { return(false); } if (stack.Amount >= pItem.Amount + pAmount) { return(true); } return(false); }
/// <summary> /// Gets the station information. /// </summary> private void GetStationInfo() { try { StationInfo = new StationItem(); _swRequest.Start(); tmr.Stop(); IsBusy = true; StationInfo = ManageQsoPortal .Agent .GetStationInfo(CallId); } catch { IsBusy = false; IsEmpty = true; } }
/// <summary> /// Unknowns the specified item. /// </summary> /// <param name="item">The item.</param> /// <returns>CallSignInfo.</returns> public static CallSignInfo ToUnknown(this StationItem item) { return(new CallSignInfo { BioUrl = "", CallSign = item.CallId.ToUpper(), DisplayLocation = "Unknown", DisplayName = String.Format("{0} not found.", item.CallId.ToUpper()), Grid = "", ImageUrl = "", Latitude = 0.0, Longitude = 0.0, LongPath = "", ShortPath = "", Bearing = "", DisplayLatitude = "", DisplayLongitude = "" }); }
//public void ChangeSelectedStationItem(StationItem selectedStationItem) => // SelectedStationItem = selectedStationItem; void ChangeTiemTable(StationItem selectedStationItem) { TimeTableRowItems.Clear(); Enumerable.Range(6, 14).ForEach ( async x => { var rowItem = new TimeTableRowItem( "Dammy", selectedStationItem.ID, x, string.Empty ); (await timeTableItemDataStore.GetItemsEachHourAsync(selectedStationItem.ID, x)).ForEach(y => rowItem.RowText += $"{y.Minute} "); TimeTableRowItems.Add(rowItem); } ); }
/// <summary> /// Gets the station information. /// </summary> /// <param name="callId">The call identifier.</param> /// <returns>StationItem.</returns> public StationItem GetStationInfo(string callId) { try { callId = callId.ToUpper(); StationItem si = null; logger.Info("Saving {0}.", callId); CallSign res = QrzDotComPortal .Proxy .GetCallSign(callId); si = res != null?res.ToStationItem() : CreateUnknownStationItem(callId); return(Provider <StationItem> .Save(si)); } catch (Exception exception) { logger.Error(exception.GetCombinedMessages()); return(null); } }
public bool DecreaseIngredientAmount(StationItem pItem) { if (pItem == null) { return(false); } if (pItem.Amount > 0) { pItem.Amount -= 1; if (pItem.Amount <= 0) { RemoveItem(pItem.ContainedItem); } IngredientsChanged(); return(true); } return(false); }
internal void ShowErrorToastNotification(StationItem currentStation, string title, string message) { ToastContent content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title, HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = message, HintStyle = AdaptiveTextStyle.Subtitle }, } } } }; if (currentStation != null) { content.Visual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = currentStation.StationLogoUrl.ToString(), }; } var notification = new ToastNotification(content.GetXml()); notification.Tag = "error"; notification.NotificationMirroring = NotificationMirroring.Disabled; toastNotifier.Show(notification); }
public void GetById_NoScheduledTrains() { DateTime downloadDate = new DateTime(2016, 9, 1); DateTime predictionTimeStamp = downloadDate .AddMonths(1) .AddHours(12) .AddMinutes(13) .ToUniversalTime(); string stationName = null; string urlSafeStopId = "StationOneId"; var db = new WebApiTestMbtaTrackerDb(); Download dl = new Download { download_id = 1, download_date = downloadDate, download_file_name = "foo.zip" }; db.Downloads.Add(dl); db.Predictions.Add(new Prediction { prediction_id = 1, prediction_time = predictionTimeStamp }); StationController target = new StationController { TrackerDb = db }; StationItem result = target.GetById(urlSafeStopId); Assert.AreEqual(downloadDate, result.ScheduleTimeStamp, "checking schedule time stamp"); Assert.AreEqual(predictionTimeStamp, result.PredictionTimeStamp, "checking prediction time stamp"); Assert.AreEqual(stationName, result.StationName, "checking StationName"); Assert.AreEqual(urlSafeStopId, result.UrlSafeStopId, "checking UrlSafeStopId"); Assert.AreEqual(0, result.Trains.Count(), "checking trains count"); }
/// <summary> /// Gets the short path. /// </summary> /// <param name="item">The item.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <param name="unit">The unit.</param> /// <returns>System.String.</returns> public static string GetShortPath(StationItem item, double clientLat, double clientLon, string unit) { double lat = Convert.ToDouble(item.Latitude); double lon = Convert.ToDouble(item.Longitude); var res = Convert.ToString( unit == "mi" ? GeoUtils.DistanceTo(clientLat, lat, clientLon, lon, DistanceType.Miles) : GeoUtils.DistanceTo(clientLat, lat, clientLon, lon, DistanceType.Kilometers)); return String.Format(unit == "mi" ? "{0} Mi" : "{0} km", res); }
private void PrintInfo(StationItem res) { Console.WriteLine(""); Console.WriteLine("Hello, {0} {1}", res.FirstName, res.LastName); Console.WriteLine("\t@Long: {0,8}\tLat: {1,8}", res.Longitude, res.Latitude); }
/// <summary> /// Gets the bearing. /// </summary> /// <param name="item">The item.</param> /// <param name="clientLat">The client lat.</param> /// <param name="clientLon">The client lon.</param> /// <returns>System.String.</returns> public static string GetBearing(StationItem item, double clientLat, double clientLon) { double lat = Convert.ToDouble(item.Latitude); double lon = Convert.ToDouble(item.Longitude); return GeoAngle.FromDouble(GeoUtils.BearingTo(clientLat, lat, clientLon, lon)).ToString(); }