private void MenuItem_Click(object sender, RoutedEventArgs e) { ItemViewModel item = null; if (myPanorama.SelectedIndex == 0) { ListBoxItem selectedListBoxItem = lstPinned.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; item = lstPinned.ItemContainerGenerator.ItemFromContainer(selectedListBoxItem) as ItemViewModel; } else { ListBoxItem selectedListBoxItem = lstApplications.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; item = lstApplications.ItemContainerGenerator.ItemFromContainer(selectedListBoxItem) as ItemViewModel; } item.IsPinned = !item.IsPinned; if (myPanorama.SelectedIndex == 0) { foreach (var it in viewModel.Items) { if (it.Title == item.Title) { it.IsPinned = false; } } } FavoriteItemCollection.Flush(); viewModel.LoadPinnedItemList(); }
private void btnMoveDown_Click(object sender, RoutedEventArgs e) { ItemViewModel item = null; if (myPanorama.SelectedIndex == 0) { ListBoxItem selectedListBoxItem = lstPinned.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; item = lstPinned.ItemContainerGenerator.ItemFromContainer(selectedListBoxItem) as ItemViewModel; } if (item != null) { FavoriteItemCollection.MoveDown("fav" + item.Hash); } FavoriteItemCollection.Flush(); viewModel.LoadPinnedItemList(); }
private static List <ItemViewModel> GetActualPinnedItemList() { FavoriteItemCollection.Ping(); List <ItemViewModel> list = new List <ItemViewModel>(); var lines = FavoriteItemCollection.Items(); if (lines != null) { int x = 0; foreach (var line in lines) { var item = ItemFactory.Create(line.Replace("fav", ""), x); if (item != null) { list.Add(item); x++; } } } return(list); }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { InteropSvc.InteropLib.Initialize(); if (InteropSvc.InteropLib.Instance.HasRootAccess() == false) { MessageBox.Show(LocalizedResources.NoRootAccess, LocalizedResources.Error, MessageBoxButton.OK); throw new Exception("Quit"); } if (!IsolatedStorageSettings.ApplicationSettings.Contains("notFirstRun")) { FavoriteItemCollection.Add("favPhone"); FavoriteItemCollection.Add("favBluetooth"); FavoriteItemCollection.Add("favWifi"); FavoriteItemCollection.Add("favDataConnection"); FavoriteItemCollection.Add("favBatterySaving"); FavoriteItemCollection.Add("favSearch"); FavoriteItemCollection.Add("fav" + "{0be0455c-c8d5-df11-a844-00237de2db9e}"); IsolatedStorageSettings.ApplicationSettings.Add("notFirstRun", ""); FavoriteItemCollection.Flush(); } viewModel.BusyStateChanged += new EventHandler(viewModel_BusyStateChanged); viewModel.LoadItemListAsync(); }