Exemplo n.º 1
0
        /// <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());
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        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
        }
Exemplo n.º 5
0
 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());
        }
Exemplo n.º 7
0
 public void AddStation(StationItem item)
 {
     if (m_lStationItemList.Contains(item))
     {
         Debug.LogError("contains item!");
         return;
     }
     m_lStationItemList.Add(item);
 }
Exemplo n.º 8
0
        internal string GetStationItemTileId(StationItem stationItem)
        {
            if (stationItem == null)
            {
                throw new ArgumentNullException(nameof(stationItem));
            }

            return(stationItem.Name.GetHashCode().ToString());
        }
Exemplo n.º 9
0
 public override void alignEdition(TypeEditor interfaceType, GlobalItem ownParent)
 {
     if (interfaceType == TypeEditor.ROUTECONFIG)
     {
         setEditable();
         asMetadata = true;
     }
     parentStation = (StationItem)ownParent;
 }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        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
        }
Exemplo n.º 12
0
 /// <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();
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        /// <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));
        }
Exemplo n.º 15
0
 public bool CheckDecreaseIngredientAmount(StationItem pItem, int pAmount)
 {
     if (pItem == null)
     {
         return(false);
     }
     if (pItem.Amount > pAmount)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 16
0
    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);
    }
Exemplo n.º 17
0
        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();
        }
Exemplo n.º 18
0
    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);
    }
Exemplo n.º 19
0
 /// <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)
     });
 }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
    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);
    }
Exemplo n.º 23
0
    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);
    }
Exemplo n.º 24
0
        /// <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;
            }
        }
Exemplo n.º 25
0
 /// <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);
            }
            );
        }
Exemplo n.º 27
0
        /// <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);
            }
        }
Exemplo n.º 28
0
    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);
    }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        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");
        }
Exemplo n.º 31
0
 /// <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 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;
            }

        }
Exemplo n.º 34
0
 /// <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();
 }
 /// <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();
 }