private void __InitializeStations()
        {
            if (Stations == null)
            {
                Stations = new ObservableCollection <ESTWSelectionStationViewModel>();
            }
            else
            {
                Stations.Clear();
            }

            foreach (var Station in m_Estw.Stations)
            {
                if (!Station.HasScheduleFile)
                {
                    continue;
                }

                var VM = new ESTWSelectionStationViewModel(Station);
                VM.IsSelected       = Runtime.VisibleStations.Contains(Station);
                VM.PropertyChanged += __Station_PropertyChanged;
                Stations.Add(VM);
            }

            __RefreshSelection();
        }
Exemplo n.º 2
0
        protected override void PageUnloaded()
        {
            base.PageUnloaded();

            Messenger.Default.Unregister <PointOnMapMessage>(this);

            SearchResults.Clear();
            Stations.Clear();

            //PointA = null;
            //PointB = null;
        }
Exemplo n.º 3
0
        protected override void PageLoaded()
        {
            pageLoaded = true;

            Messenger.Default.Register <PointOnMapMessage>(this, (action) => SelectPointOnMap(action));

            ClearSearchTextBox();

            ShowLoader();

            if (isPointA)
            {
                PageTitleMessage.Send(AppResources.HeaderPointA);
            }
            else
            {
                PageTitleMessage.Send(AppResources.HeaderPointB);
            }

            base.PageLoaded();

            Stations.Clear();
            SearchResults.Clear();

            if (InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.AllowLocation).Value)
            {
                locationIsAllowed = true;

                if (user.IsLocationUptodate)
                {
                    UserLocationFound(new GpsWatcherResponseMessage(true, user.LastKnownGeneralLocation, GpsWatcherResponseMessageReason.Coordinate));
                }
                else
                {
                    RegisterWatcher();
                }
            }
            else
            {
                locationIsAllowed = false;

                if (isStopSearch)
                {
                    AddStations();
                }
                else
                {
                    AddSearchResultsNearby();
                }
            }

            pageLoaded = false;
        }
Exemplo n.º 4
0
        private void AddStations()
        {
            ShowLoader();
            Stations.Clear();
            SearchResults.Clear();

            cancellationTokenSource.Cancel();
            cancellationTokenSource = new CancellationTokenSource();

            Stations.AddRange(UnitOfWork.PublicStopRepository.GetNearby(30));

            timerMapMoved.Start();

            ShowStopsList();
        }
Exemplo n.º 5
0
        private void TimerTickSearch(object sender, EventArgs e)
        {
            timerSearch.Stop();

            ShowHeaderLoader();

            if (isStopSearch)
            {
                IEnumerable <PublicStop> stops = UnitOfWork.PublicStopRepository.GetByName(searchText);

                Stations.Clear();
                Stations.AddRange(stops);

                ShowStopsList();
                HideHeaderLoader();
            }
            else
            {
                cancellationTokenSource.Cancel();
                cancellationTokenSource = new CancellationTokenSource();

                Action search = async() =>
                {
                    try
                    {
                        SearchResults.Clear();
                        SearchResults.AddRange(await BumbleApiService.PlacesOfInterest(cancellationTokenSource.Token, user, SearchText, null));
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message != AppResources.ApiErrorTaskCancelled)
                        {
                            base.ShowPopup(CustomPopupMessageType.Error, ex.Message, AppResources.CustomPopupGenericOkMessage, null);
                        }

                        ClearSearchTextBox();
                    }

                    ShowSearchList();
                    HideHeaderLoader();
                };

                DispatcherHelper.CheckBeginInvokeOnUI(search);
            }
        }
Exemplo n.º 6
0
        private void AddSearchResultsNearby()
        {
            ShowLoader();
            Stations.Clear();
            SearchResults.Clear();

            cancellationTokenSource.Cancel();
            cancellationTokenSource = new CancellationTokenSource();

            Action search = async() =>
            {
                try
                {
                    SearchResults.Clear();

                    string[] categories = UnitOfWork.PlaceOfInterestCategoryRepository.GetAll().Where(x => x.Category != "Unknown").Select(x => x.Category).ToArray();

                    // Only search if we have user location
                    if (locationIsAllowed && user.LastKnownGeneralLocation != null && user.LastKnownGeneralLocation.IsValid())
                    {
                        SearchResults.AddRange(await BumbleApiService.PlacesOfInterest(cancellationTokenSource.Token, user, String.Empty, categories));

                        timerMapMoved.Start();
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message != AppResources.ApiErrorTaskCancelled)
                    {
                        base.ShowPopup(CustomPopupMessageType.Error, ex.Message, AppResources.CustomPopupGenericOkMessage, null);
                    }
                }

                ShowSearchList();
                HideHeaderLoader();
            };

            DispatcherHelper.CheckBeginInvokeOnUI(search);
        }
        private void LoadStrategy()
        {
            SlideHeaders.Clear();
            SourcePrograms.Clear();
            Lengths.Clear();
            Stations.Clear();
            CustomDemos.Clear();
            Dayparts.Clear();
            Times.Clear();

            if (ResourceManager.Instance.MediaListsFile.ExistsLocal())
            {
                var document = new XmlDocument();
                document.Load(ResourceManager.Instance.MediaListsFile.LocalPath);

                XmlNode node = document.SelectSingleNode(String.Format(@"/{0}Strategy", XmlRootPrefix));
                if (node != null)
                {
                    foreach (XmlNode childeNode in node.ChildNodes)
                    {
                        switch (childeNode.Name)
                        {
                        case "SlideHeader":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value))
                                    {
                                        SlideHeaders.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "FlexFlightDatesAllowed":
                        {
                            bool temp;
                            if (Boolean.TryParse(childeNode.InnerText, out temp))
                            {
                                FlexFlightDatesAllowed = temp;
                            }
                        }
                        break;

                        case "Daypart":
                            var daypart = new Daypart();
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Name":
                                    daypart.Name = attribute.Value;
                                    break;

                                case "Code":
                                    daypart.Code = attribute.Value;
                                    break;
                                }
                            }
                            if (!string.IsNullOrEmpty(daypart.Name))
                            {
                                Dayparts.Add(daypart);
                            }
                            break;

                        case "CustomDemo":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!CustomDemos.Contains(attribute.Value))
                                    {
                                        CustomDemos.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "Lenght":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value))
                                    {
                                        Lengths.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "Station":
                            var station = new Station();
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Name":
                                    station.Name = attribute.Value;
                                    break;

                                case "Logo":
                                    if (!string.IsNullOrEmpty(attribute.Value))
                                    {
                                        station.Logo = new Bitmap(new MemoryStream(Convert.FromBase64String(attribute.Value)));
                                    }
                                    break;
                                }
                            }
                            if (!string.IsNullOrEmpty(station.Name))
                            {
                                Stations.Add(station);
                            }
                            break;

                        case "Program":
                            var sourceProgram = new SourceProgram();
                            GetProgramProperties(childeNode, ref sourceProgram);
                            if (!string.IsNullOrEmpty(sourceProgram.Name))
                            {
                                SourcePrograms.Add(sourceProgram);
                            }
                            break;

                        case "Status":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!Statuses.Contains(attribute.Value))
                                    {
                                        Statuses.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "BroadcastMonthTemplate":
                            var monthTemplate = new MediaMonthTemplate();
                            monthTemplate.Deserialize(childeNode);
                            MonthTemplatesMondayBased.Add(monthTemplate);
                            MonthTemplatesSundayBased.Add(monthTemplate);
                            break;

                        case "DefaultWeeklyScheduleSettings":
                            DefaultWeeklyScheduleSettings.Deserialize(childeNode);
                            break;

                        case "DefaultMonthlyScheduleSettings":
                            DefaultMonthlyScheduleSettings.Deserialize(childeNode);
                            break;

                        case "DefaultSnapshotSettings":
                            DefaultSnapshotSettings.Deserialize(childeNode);
                            break;

                        case "DefaultSnapshotSummarySettings":
                            DefaultSnapshotSummarySettings.Deserialize(childeNode);
                            break;

                        case "DefaultOptionsSettings":
                            DefaultOptionsSettings.Deserialize(childeNode);
                            break;

                        case "DefaultOptionsSummarySettings":
                            DefaultOptionsSummarySettings.Deserialize(childeNode);
                            break;

                        case "DefaultBroadcastCalendarSettings":
                            DefaultBroadcastCalendarSettings.Deserialize(childeNode);
                            break;

                        case "DefaultCustomCalendarSettings":
                            DefaultCustomCalendarSettings.Deserialize(childeNode);
                            break;
                        }
                    }
                }
            }

            if (SourcePrograms.Count > 0)
            {
                Times.AddRange(SourcePrograms.Select(x => x.Time).Distinct().ToArray());
                Days.AddRange(SourcePrograms.Select(x => x.Day).Distinct().ToArray());
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Removes all irrelevant or doubled up stations from the stations list.
 /// </summary>
 public void RemoveIrrelevantStations()
 {
     Stations.Clear();
     Stations.AddRange(GetBestStationsDistChecked(true));
 }
Exemplo n.º 9
0
        public virtual void Deserialize(XmlNode rootNode)
        {
            var node = rootNode.SelectSingleNode(@"BusinessName");

            if (node != null)
            {
                BusinessName = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"DecisionMaker");
            if (node != null)
            {
                DecisionMaker = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"ClientType");
            if (node != null)
            {
                ClientType = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"AccountNumber");
            if (node != null)
            {
                AccountNumber = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"Status");
            if (node != null)
            {
                Status = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"PresentationDate");
            DateTime tempDateTime;

            if (node != null)
            {
                if (DateTime.TryParse(node.InnerText, out tempDateTime))
                {
                    PresentationDate = tempDateTime;
                }
            }

            node = rootNode.SelectSingleNode(@"FlightDateStart");
            if (node != null)
            {
                if (DateTime.TryParse(node.InnerText, out tempDateTime))
                {
                    FlightDateStart = tempDateTime;
                }
            }

            node = rootNode.SelectSingleNode(@"FlightDateEnd");
            if (node != null)
            {
                if (DateTime.TryParse(node.InnerText, out tempDateTime))
                {
                    FlightDateEnd = tempDateTime;
                }
            }

            node = rootNode.SelectSingleNode(@"UserFlightDateStart");
            if (node != null)
            {
                if (DateTime.TryParse(node.InnerText, out tempDateTime))
                {
                    _userFlightDateStart = tempDateTime;
                }
            }
            if (!_userFlightDateStart.HasValue)
            {
                _userFlightDateEnd = FlightDateStart;
            }

            node = rootNode.SelectSingleNode(@"UserFlightDateEnd");
            if (node != null)
            {
                if (DateTime.TryParse(node.InnerText, out tempDateTime))
                {
                    _userFlightDateEnd = tempDateTime;
                }
            }
            if (!_userFlightDateEnd.HasValue)
            {
                _userFlightDateEnd = FlightDateEnd;
            }

            node = rootNode.SelectSingleNode(@"UseDemo");
            bool tempBool;

            if (node != null)
            {
                if (bool.TryParse(node.InnerText, out tempBool))
                {
                    UseDemo = tempBool;
                }
            }

            node = rootNode.SelectSingleNode(@"ImportDemo");
            if (node != null)
            {
                if (bool.TryParse(node.InnerText, out tempBool))
                {
                    ImportDemo = tempBool;
                }
            }

            node = rootNode.SelectSingleNode(@"DemoType");
            int tempInt;

            if (node != null)
            {
                if (int.TryParse(node.InnerText, out tempInt))
                {
                    DemoType = (DemoType)tempInt;
                }
            }

            node = rootNode.SelectSingleNode(@"MondayBased");
            if (node != null)
            {
                bool temp;
                if (Boolean.TryParse(node.InnerText, out temp))
                {
                    MondayBased = temp;
                }
            }

            node = rootNode.SelectSingleNode(@"Demo");
            if (node != null)
            {
                Demo = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"Source");
            if (node != null)
            {
                Source = node.InnerText;
            }

            node = rootNode.SelectSingleNode(@"SelectedSpotType");
            if (node != null)
            {
                if (int.TryParse(node.InnerText, out tempInt))
                {
                    SelectedSpotType = (SpotType)tempInt;
                }
            }

            node = rootNode.SelectSingleNode(@"Dayparts");
            if (node != null)
            {
                Dayparts.Clear();
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    var daypart = new Daypart();
                    daypart.Deserialize(childNode);
                    Dayparts.Add(daypart);
                }
            }

            node = rootNode.SelectSingleNode(@"Stations");
            if (node != null)
            {
                Stations.Clear();
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    var station = new Station();
                    station.Deserialize(childNode);
                    Stations.Add(station);
                }
            }

            node = rootNode.SelectSingleNode(@"ViewSettings");
            if (node != null)
            {
                ViewSettings.Deserialize(node);
            }
        }