Esempio n. 1
0
        public async Task <ObservableCollection <MenuItem> > getMenuItems()
        {
            var    loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            string type   = loader.GetString("type");

            Uri         menuUri = new Uri("ms-appx:///DataModel/MenuItems-" + type + ".json");
            StorageFile file    = await StorageFile.GetFileFromApplicationUriAsync(menuUri);

            /*List<MenuItem> movie1 = JsonConvert.DeserializeObject<List<MenuItem>>(await FileIO.ReadLinesAsync(file));*/

            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText.ToString());
            JsonArray  jsonArray  = jsonObject["MenuItems"].GetArray();

            foreach (JsonValue groupValue in jsonArray)
            {
                JsonObject groupObject       = groupValue.GetObject();
                MenuItem   _sampleDataSource = new MenuItem(groupObject["name"].GetString(),
                                                            groupObject["description"].GetString(),
                                                            LocalProperties.LoadFromToLP(LocalProperties.LP_theme) == LocalProperties.theme_light ? groupObject["img_black"].GetString() : groupObject["img_white"].GetString(),
                                                            groupObject["position"].GetString());
                MenuList.Add(_sampleDataSource);
            }
            return(MenuList);
        }
Esempio n. 2
0
        private async void LoadSettings()
        {
            if (!isLoadedSettings)
            {
                Toggle_Theme.IsOn             = LocalProperties.LoadFromToLP(LocalProperties.LP_theme) == LocalProperties.theme_light;
                Settings_Latest_Database.Text = LocalProperties.LoadFromToLP(LocalProperties.LP_current_version);

                New_Goes.CommonAPI.Metadata.StatusMetaData metadata = await Metadata.Get_MetaData();

                if (metadata.obj != null)
                {
                    string city    = LocalProperties.LoadFromToLP(LocalProperties.LP_selected_city);
                    int    version = 0;

                    switch (city)
                    {
                    case "brest":
                        version = metadata.obj.cities_versions.brest;
                        break;

                    case "vitebsk":
                        version = metadata.obj.cities_versions.vitebsk;
                        break;

                    case "grodno":
                        version = metadata.obj.cities_versions.grodno;
                        break;

                    case "gomel":
                        version = metadata.obj.cities_versions.gomel;
                        break;

                    case "mogilev":
                        version = metadata.obj.cities_versions.mogilev;
                        break;

                    case "minsk":
                        version = metadata.obj.cities_versions.minsk;
                        break;
                    }
                    Settings_Newest_Database.Text = version.ToString();
                    if (version > Int32.Parse(LocalProperties.LoadFromToLP(LocalProperties.LP_current_version)))
                    {
                        Constant.ShowNotification("Доступно обновление расписания");
                    }
                }
            }

            isLoadedSettings = true;
        }
Esempio n. 3
0
        private async Task LoadStopNames()
        {
            SQLiteConnection connection = new SQLiteConnection(dbPath);

            Transport = new List <StopNameAllSQL>();
            var items = connection.Query <StopNameSQL>(
                "SELECT s.n_id as id, REPLACE(sn.name,'ул. ','') as name FROM stop AS s LEFT JOIN stopname as sn ON s.n_id = sn.id GROUP BY s.n_id ORDER BY name");

            List <StopNameSQL> buses = connection.Query <StopNameSQL>(
                "SELECT s.n_id as id, REPLACE(sn.name,'ул. ','') as name,r.type as type FROM stop AS s LEFT JOIN stopname as sn ON s.n_id = sn.id LEFT JOIN route as r ON s.r_id = r.id WHERE r.type= 0 GROUP BY s.n_id ORDER BY name");

            List <StopNameSQL> trolls = connection.Query <StopNameSQL>(
                "SELECT s.n_id as id, REPLACE(sn.name,'ул. ','') as name,r.type as type FROM stop AS s LEFT JOIN stopname as sn ON s.n_id = sn.id LEFT JOIN route as r ON s.r_id = r.id WHERE r.type= 1 GROUP BY s.n_id ORDER BY name");

            List <StopNameSQL> tramms = connection.Query <StopNameSQL>(
                "SELECT s.n_id as id, REPLACE(sn.name,'ул. ','') as name,r.type as type FROM stop AS s LEFT JOIN stopname as sn ON s.n_id = sn.id LEFT JOIN route as r ON s.r_id = r.id WHERE r.type= 2 GROUP BY s.n_id ORDER BY name");

            foreach (var item in items)
            {
                Transport.Add(new StopNameAllSQL()
                {
                    id      = item.id,
                    isBus   = buses.Find(x => x.name == item.name) != null ? (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) != LocalProperties.theme_light ? "/Assets/MenuItemsLogo/ic_bus_white.png" : "/Assets/MenuItemsLogo/ic_bus_black.png") : null,
                    isTroll = trolls.Find(x => x.name == item.name) != null ? (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) != LocalProperties.theme_light ? "/Assets/MenuItemsLogo/ic_troll_white.png" : "/Assets/MenuItemsLogo/ic_troll_black.png") : null,
                    isTramm = tramms.Find(x => x.name == item.name) != null ? (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) != LocalProperties.theme_light ? "/Assets/MenuItemsLogo/ic_tram_white.png" : "/Assets/MenuItemsLogo/ic_tram_black.png") : null,
                    name    = item.name,
                    width   = screenWidth
                });
            }

            List <StopNameAllSQL> New_Transport = new List <StopNameAllSQL>();
            var tt = Transport.GroupBy(item => item.name)
                     .Select(group => new { name = group.Key, width = screenWidth, id = group.ToList()[0].id, isBus = group.ToList()[0].isBus, isTroll = group.ToList()[0].isTroll, isTramm = group.ToList()[0].isTramm })
                     .ToList();

            this.DefaultViewModel["Transport"] = tt;

            /*await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
             * () =>
             *  {
             *      if (Buses.Count == 0)
             *          PivotMain.Items.RemoveAt(PivotMain.Items.IndexOf(PItemBus));
             *      if (Trolls.Count == 0)
             *          PivotMain.Items.RemoveAt(PivotMain.Items.IndexOf(PItemTroll));
             *      if (Tramms.Count == 0)
             *          PivotMain.Items.RemoveAt(PivotMain.Items.IndexOf(PItemTramm));
             *  }
             * );*/
        }
Esempio n. 4
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     Constant.Loader(this.resourceLoader.GetString("GlobalLoading"), true);
     if (LocalProperties.LoadFromToLP(LocalProperties.LP_active_premium) != "true")
     {
         MessageDialog msg = new MessageDialog(this.resourceLoader.GetString("MessageDialogPremiumContent"), this.resourceLoader.GetString("MessageDialogPremiumTitle"));
         msg.Commands.Add(new UICommand(this.resourceLoader.GetString("StaticButtonCancel"), new UICommandInvokedHandler(CommandHandlers)));
         msg.Commands.Add(new UICommand(this.resourceLoader.GetString("StaticButtonBuy"), new UICommandInvokedHandler(CommandHandlers)));
         msg.ShowAsync();
     }
     else
     {
         await Task.Run(() => GetRoutes());
     }
     Constant.Loader(this.resourceLoader.GetString("GlobalLoading"), false);
 }
Esempio n. 5
0
 private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (isLoadedSettings)
     {
         TextBlock_ReloadApp.Visibility = Visibility.Visible;
         TextBlock_ReloadApp.Text       = this.resourceLoader.GetString("Reload_Application");
         if (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) == LocalProperties.theme_light)
         {
             LocalProperties.SaveToLP(LocalProperties.LP_theme, LocalProperties.theme_dark);
         }
         else
         {
             LocalProperties.SaveToLP(LocalProperties.LP_theme, LocalProperties.theme_light);
         }
     }
 }
Esempio n. 6
0
 private void ListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (LocalProperties.LoadFromToLP(LocalProperties.LP_active_premium) != "true")
     {
         MessageDialog msg = new MessageDialog(this.resourceLoader.GetString("MessageDialogPremiumContent"), this.resourceLoader.GetString("MessageDialogPremiumTitle"));
         msg.Commands.Add(new UICommand(this.resourceLoader.GetString("StaticButtonCancel"), new UICommandInvokedHandler(CommandHandlers)));
         msg.Commands.Add(new UICommand(this.resourceLoader.GetString("StaticButtonBuy"), new UICommandInvokedHandler(CommandHandlers)));
         msg.ShowAsync();
     }
     else
     {
         if (!Frame.Navigate(typeof(Views.Taxi.Cities.First), JsonConvert.SerializeObject(e.ClickedItem as StaticFBusesData)))
         {
             throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage"));
         }
     }
 }
Esempio n. 7
0
 private void LoadValues()
 {
     if (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) == null)
     {
         this.RequestedTheme = ApplicationTheme.Light;
         LocalProperties.SaveToLP(LocalProperties.LP_theme, LocalProperties.theme_light);
     }
     else
     if (LocalProperties.LoadFromToLP(LocalProperties.LP_theme) == LocalProperties.theme_light)
     {
         this.RequestedTheme = ApplicationTheme.Light;
     }
     else
     {
         this.RequestedTheme = ApplicationTheme.Dark;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active.
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page.
                rootFrame = new Frame();

                // Associate the frame with a SuspensionManager key.
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                // TODO: Change this value to a cache size that is appropriate for your application.
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate.
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue.
                    }
                }

                // Place the frame in the current Window.
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter.
                if (LocalProperties.LoadFromToLP(LocalProperties.LP_selected_city) == null)
                {
                    if (!rootFrame.Navigate(typeof(Loading), e.Arguments))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }
                else
                if (!rootFrame.Navigate(typeof(HubPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active.
            Window.Current.Activate();
        }
Esempio n. 9
0
        private async Task <Status> updateSchedule()
        {
            Schedule scedule = new Schedule();

            return(await scedule.GetSchedule(LocalProperties.LoadFromToLP(LocalProperties.LP_selected_city)));
        }