using System; using System.Device.Location; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using MahTweets.Mobile.Core; using MahTweets.Mobile.TwitterPlugin.ViewModels; using Microsoft.Phone.Controls.Maps; namespace MahTweets.Mobile.TwitterPlugin.Views { public partial class SingleTweetView { public SingleTweetViewModel vm { get; set; } public SingleTweetView() { InitializeComponent(); this.Loaded += new RoutedEventHandler(SingleTweetView_Loaded); } void SingleTweetView_Loaded(object sender, RoutedEventArgs e) { if (vm.Update == null || vm.Update.Location == null) return; map.Center = new GeoCoordinate(vm.Update.Location.Latitude, vm.Update.Location.Longitude); map.Visibility = Visibility.Visible; map.Children.Add(new Pushpin() { Location = map.Center }); } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { vm = (DataContext as SingleTweetViewModel); var UpdatesCollectionView = Resources["UpdatesCollectionView"] as CollectionViewSource; UpdatesCollectionView.Source = vm.Conversation; base.OnNavigatedTo(e); } private void AbibReplyClick(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/Views/CompositionView.xaml?ID=" + vm.Update.ID, UriKind.RelativeOrAbsolute)); } private void AbibReplyAllClick(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/Views/CompositionView.xaml?Mode=All&ID=" + vm.Update.ID, UriKind.RelativeOrAbsolute)); } private void AbibRtClick(object sender, EventArgs e) { vm.Retweet(); } private void AbibFavClick(object sender, EventArgs e) { vm.Favourite(); } private void AbmiBlockClick(object sender, EventArgs e) { vm.Block(); } private void AbmiDmClick(object sender, EventArgs e) { NavigationService.Navigate(new Uri(String.Format("/Views/CompositionView.xaml?Text=d {0}%20", vm.Update.Contact.Name), UriKind.RelativeOrAbsolute)); } private void AbmiViewProfileClick(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/MahTweets.Mobile.TwitterPlugin;component/Views/ProfileView.xaml?Name=" + vm.Update.Contact.Name, UriKind.RelativeOrAbsolute)); } private void AbmiInstapaperClick(object sender, EventArgs e) { vm.InstapaperTweet(); } private AbstractStatusUpdate _oldSelection; private void LbEverythingSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(lbEverything.SelectedItem is AbstractStatusUpdate)) return; var update = (AbstractStatusUpdate)lbEverything.SelectedItem; update.IsSelected = update.IsSelected != true; if (update != _oldSelection && _oldSelection != null) { _oldSelection.IsSelected = false; } _oldSelection = update; } } }