protected override async void OnNavigatedTo(NavigationEventArgs e)
{
if (AppList.getMyAppList().myappList.Count > 0)
btnMyApps.Visibility = Visibility.Visible;
else btnMyApps.Visibility = Visibility.Collapsed;
int fa = 6, fc = 4;
try
{
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values.ContainsKey("Featured_Categories"))
{Int32.TryParse(localSettings.Values["Featured_Categories"].ToString(),out fc); }
else localSettings.Values.Add("Featured_Categories", "4");
if (localSettings.Values.ContainsKey("Featured_Apps"))
{ Int32.TryParse(localSettings.Values["Featured_Apps"].ToString(), out fa); }
else localSettings.Values.Add("Featured_Apps", "6");
}
catch (Exception ex)
{ }
Random rnd = new Random();
featuredCategories.Clear();
featuredApps.Clear();
int l = AppList.getAppList().appList.Count;
for (int i = 0; i < fa; i++)
{
while (true)
{
int x = rnd.Next(0, l);
Apps ob = AppList.getAppList().appList.ElementAt(x);
if (!nofeaturedApps.Contains(x))
{ featuredApps.Add(ob);nofeaturedApps.Add(x); break;}
}
}
rnd = new Random();
for (int i = 0; i < fc; i++)
{
while (true)
{
int x = rnd.Next(0, 10);
Categories ob = Models.Resources.getCategoriesList().ElementAt(x);
if (!nofeaturedCategories.Contains(x))
{ featuredCategories.Add(ob); nofeaturedCategories.Add(x); break; }
}
}
GridFeaturedApps.ItemsSource = featuredApps;
GridFeaturedCategories.ItemsSource = featuredCategories;
if(e.Parameter!=null)
if (!String.IsNullOrWhiteSpace(e.Parameter.ToString()))
{
string appName = e.Parameter.ToString();
foreach (Apps app in featuredApps)
{
if (app.Name.Equals(appName))
{
AppInstance.app = app;
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{ Frame.Navigate(typeof(StartPage),"remove"); });
}
}
}
if(Frame.BackStack.Count>0)
Frame.BackStack.Clear();
}