async protected override void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.Protocol)
            {
                var protocol_args = args as ProtocolActivatedEventArgs;
                var path          = protocol_args.Uri.Host.ToLower();
                await InitializeAppAsync();

                if (path == "street")
                {
                    StreetSideViewPage street_view = new StreetSideViewPage();
                    var center_point = new Geopoint(new BasicGeoposition
                    {
                        Latitude  = App.State.NextEvent.Latitude.Value,
                        Longitude = App.State.NextEvent.Longitude.Value,
                    });
                    await street_view.InitializeAsync(center_point);

                    Window.Current.Content = street_view;
                }
                else
                {
                    Window.Current.Content = new ApplicationHostPage();
                }
                Window.Current.Activate();
            }
        }
        async protected override void OnActivated(IActivatedEventArgs args)
        {
            await InitializeAppAsync();

            if (args.Kind == ActivationKind.Protocol)
            {
                var protocol_args = args as ProtocolActivatedEventArgs;
                var query         = protocol_args.Uri.Query.ToLower();
                var reader        = QueryReader.Load(query);



                var target_page = reader["page"];



                if (target_page == "street")
                {
                    StreetSideViewPage street_view = new StreetSideViewPage();
                    var center_point = new Geopoint(new BasicGeoposition
                    {
                        Latitude  = App.State.NextEvent.Latitude.Value,
                        Longitude = App.State.NextEvent.Longitude.Value,
                    });
                    await street_view.InitializeAsync(center_point);

                    Window.Current.Content = street_view;
                }
                else if (target_page == "main")
                {
                    Window.Current.Content = new ApplicationHostPage();
                }
                else if (target_page == "counter")
                {
                    Window.Current.Content = new PatronCounter();
                }
                else if (target_page == "test")
                {
                    Window.Current.Content = new TestPage();
                }
                else
                {
                    Window.Current.Content = new PageNotFound();
                }
            }
            else if (args.Kind == ActivationKind.ProtocolForResults)
            {
                var protocol_args = args as ProtocolForResultsActivatedEventArgs;
                Window.Current.Content = new LaunchResponsePage(protocol_args);
            }
            Window.Current.Activate();
        }
        async private void OnShowStreetView(object sender, RoutedEventArgs e)
        {
            var view_id      = 0;
            var supported    = true;
            var center_point = map.Center;

            if (_core_streetside_view != null)
            {
                await _core_streetside_view.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    _core_streetside_view.CoreWindow.Close();
                });
            }

            _core_streetside_view = CoreApplication.CreateNewView();
            await _core_streetside_view.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                var app_view = ApplicationView.GetForCurrentView();
                view_id      = app_view.Id;

                StreetSideViewPage street_view = new StreetSideViewPage();
                await street_view.InitializeAsync(center_point);

                street_view.Close += () =>
                {
                    _core_streetside_view.CoreWindow.Close();
                    _core_streetside_view = null;
                };
                street_view.NotSupported += () => supported = false;

                Window.Current.Content = street_view;
                Window.Current.Activate();
            });

            if (supported)
            {
                await ApplicationViewSwitcher.TryShowAsStandaloneAsync(view_id);
            }
            else
            {
                await new MessageDialog("StreetSide View is not supported.").ShowAsync();
            }
        }
Example #4
0
        async protected override void OnFileActivated(FileActivatedEventArgs args)
        {
            var target_file = args.Files.FirstOrDefault() as StorageFile;
            var query       = await target_file.ReadTextAsync();

            var reader      = QueryReader.Load(query);
            var target_page = reader["page"];

            if (target_page == "street")
            {
                StreetSideViewPage street_view = new StreetSideViewPage();
                var center_point = new Geopoint(new BasicGeoposition
                {
                    Latitude  = App.State.NextEvent.Latitude.Value,
                    Longitude = App.State.NextEvent.Longitude.Value,
                });
                await street_view.InitializeAsync(center_point);

                Window.Current.Content = street_view;
            }
            else if (target_page == "main")
            {
                Window.Current.Content = new ApplicationHostPage();
            }
            else if (target_page == "counter")
            {
                Window.Current.Content = new PatronCounter();
            }
            else if (target_page == "test")
            {
                Window.Current.Content = new TestPage();
            }
            else
            {
                Window.Current.Content = new PageNotFound();
            }
            Window.Current.Activate();
        }
Example #5
0
        async protected override void OnActivated(IActivatedEventArgs args)
        {
            await InitializeAppAsync();

            if (args.Kind == ActivationKind.Protocol)
            {
                var protocol_args = args as ProtocolActivatedEventArgs;
                var query         = WebUtility.UrlDecode(protocol_args.Uri.Query.ToLower());
                var reader        = QueryReader.Load(query);

                if (reader.Contains("launchcontext"))
                {
                    var context = reader["launchcontext"];
                    if (context == "all_events")
                    {
                        Window.Current.Content = new ListEventsPage(App.State.Events);
                    }
                    else if (context == "event")
                    {
                        var event_id   = Guid.Parse(reader["event_id"]);
                        var event_list = App.State.Events.Where(i => i.EventID == event_id).ToList();
                        Window.Current.Content = new ListEventsPage(event_list);
                    }
                }
                else if (reader.Contains("page"))
                {
                    var target_page = reader["page"];

                    if (target_page == "street")
                    {
                        StreetSideViewPage street_view = new StreetSideViewPage();
                        var center_point = new Geopoint(new BasicGeoposition
                        {
                            Latitude  = App.State.NextEvent.Latitude.Value,
                            Longitude = App.State.NextEvent.Longitude.Value,
                        });
                        await street_view.InitializeAsync(center_point);

                        Window.Current.Content = street_view;
                    }
                    else if (target_page == "main")
                    {
                        Window.Current.Content = new ApplicationHostPage();
                    }
                    else if (target_page == "counter")
                    {
                        Window.Current.Content = new PatronCounter();
                    }
                    else if (target_page == "test")
                    {
                        Window.Current.Content = new TestPage();
                    }
                    else
                    {
                        Window.Current.Content = new PageNotFound();
                    }
                }
            }
            else if (args.Kind == ActivationKind.ProtocolForResults)
            {
                var protocol_args = args as ProtocolForResultsActivatedEventArgs;
                Window.Current.Content = new LaunchResponsePage(protocol_args);
            }
            else if (args.Kind == ActivationKind.VoiceCommand)
            {
                var command_args = args as VoiceCommandActivatedEventArgs;
                if (command_args != null)
                {
                    var rule_path = command_args.Result.RulePath[0];
                    var location  = command_args.Result.SemanticInterpretation.Properties["location"][0].ToLower();

                    var events = App.State.Events;

                    switch (rule_path)
                    {
                    case "show-events-today":
                    {
                        var today = DateTime.Now.Date;
                        events = (from evt in events
                                  where evt.StartDateTime.Date == today &&
                                  evt.Address.ToLower().Contains(location)
                                  select evt).ToList();
                    }
                    break;

                    case "show-events-tomorrow":
                    {
                        var tomorrow = DateTime.Now.Date.Add(TimeSpan.FromDays(1));
                        events = (from evt in events
                                  where evt.StartDateTime.Date == tomorrow &&
                                  evt.Address.ToLower().Contains(location)
                                  select evt).ToList();
                    }
                    break;

                    case "show-events-thisweek":
                    {
                        var today         = DateTime.Now.Date;
                        var week_starting = today.Subtract(TimeSpan.FromDays((int)today.DayOfWeek));
                        var week          = Math.Floor(week_starting.DayOfYear / 7.0);

                        events = (from evt in events
                                  let evt_day = evt.StartDateTime
                                                let evt_dow = (int)evt_day.DayOfWeek
                                                              let days_to_subtract = TimeSpan.FromDays(evt_dow)
                                                                                     let evt_week_starting = evt_day.Subtract(days_to_subtract)
                                                                                                             let evt_week = Math.Floor(evt_week_starting.DayOfYear / 7.0)
                                                                                                                            where week == evt_week &&
                                                                                                                            evt.Address.ToLower().Contains(location)
                                                                                                                            select evt).ToList();
                    }
                    break;

                    case "show-events-thismonth":
                    {
                        var today = DateTime.Now;
                        events = (from evt in events
                                  where evt.StartDateTime.Month == today.Month &&
                                  evt.Address.ToLower().Contains(location)
                                  select evt).ToList();
                    }
                    break;
                    }
                    Window.Current.Content = new ListEventsPage(events);
                }
            }
            Window.Current.Activate();
        }