summaryrefslogtreecommitdiff
path: root/Juick/MainPage.xaml.cs
diff options
context:
space:
mode:
authorGravatar vitalyster2012-10-15 00:58:48 +0400
committerGravatar vitalyster2012-10-15 00:58:48 +0400
commit1ebf0adc26fd3377b50aacaed798f9866a7ea2eb (patch)
tree6fc54fe6e62ae68c2bc22c61a41f7b907cbca54f /Juick/MainPage.xaml.cs
parent04736e99cac9969bd212bba7a2e8cd35e7ef1cd5 (diff)
Photos_Extra_Share, attach image in original size, reformat code
Diffstat (limited to 'Juick/MainPage.xaml.cs')
-rw-r--r--Juick/MainPage.xaml.cs93
1 files changed, 55 insertions, 38 deletions
diff --git a/Juick/MainPage.xaml.cs b/Juick/MainPage.xaml.cs
index 6ea6e04..783265e 100644
--- a/Juick/MainPage.xaml.cs
+++ b/Juick/MainPage.xaml.cs
@@ -13,6 +13,8 @@ using System.Windows.Shapes;
using Juick.Classes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Notification;
+using Microsoft.Xna.Framework.Media;
+using System.Windows.Media.Imaging;
namespace Juick
{
@@ -29,42 +31,42 @@ namespace Juick
InitializeComponent();
- /* // Try to find the push channel.
- pushChannel = HttpNotificationChannel.Find(channelName);
+ /* // Try to find the push channel.
+ pushChannel = HttpNotificationChannel.Find(channelName);
- // If the channel was not found, then create a new connection to the push service.
- if (pushChannel == null)
- {
- pushChannel = new HttpNotificationChannel(channelName);
+ // If the channel was not found, then create a new connection to the push service.
+ if (pushChannel == null)
+ {
+ pushChannel = new HttpNotificationChannel(channelName);
- // Register for all the events before attempting to open the channel.
- pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
- pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
+ // Register for all the events before attempting to open the channel.
+ pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
+ pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
- // Register for this notification only if you need to receive the notifications while your application is running.
- pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
+ // Register for this notification only if you need to receive the notifications while your application is running.
+ pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
- pushChannel.Open();
+ pushChannel.Open();
- // Bind this new channel for toast events.
- pushChannel.BindToShellToast();
+ // Bind this new channel for toast events.
+ pushChannel.BindToShellToast();
- }
- else
- {
- // The channel was already open, so just register for all the events.
- pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
- pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
+ }
+ else
+ {
+ // The channel was already open, so just register for all the events.
+ pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
+ pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
- // Register for this notification only if you need to receive the notifications while your application is running.
- pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
+ // Register for this notification only if you need to receive the notifications while your application is running.
+ pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
- // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
- System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
- MessageBox.Show(String.Format("Channel Uri is {0}",
- pushChannel.ChannelUri.ToString()));
+ // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
+ System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
+ MessageBox.Show(String.Format("Channel Uri is {0}",
+ pushChannel.ChannelUri.ToString()));
- }*/
+ }*/
// Set the data context of the listbox control to the sample data
Home.DataContext = App.MyFeedView;
@@ -72,22 +74,37 @@ namespace Juick
Loaded += MainPage_Loaded;
}
+ protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
+ {
+ var loginUriPart = "/LoginView.xaml";
+ var newPostUriPart = "/NewPostView.xaml";
+ var navigateUri = string.Empty;
+ var FileId = string.Empty;
+ // Get a dictionary of query string keys and values.
+ IDictionary<string, string> queryStrings = NavigationContext.QueryString;
+
+ // Ensure that there is at least one key in the query string, and check
+ // whether the "FileId" key is present.
+
+ navigateUri = string.IsNullOrEmpty(App.Account.Credentials.UserName) ? loginUriPart : newPostUriPart;
+ if (queryStrings.ContainsKey("FileId"))
+ {
+ FileId = queryStrings["FileId"];
+ navigateUri = string.Format("{0}?FileId={1}", navigateUri, FileId);
+ }
+ if (!string.IsNullOrEmpty(FileId) || navigateUri.StartsWith(loginUriPart))
+ {
+ NavigationService.Navigate(new Uri(navigateUri, UriKind.Relative));
+ }
+ }
+
// Load data for the _viewModelBase Items
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
if (!App.MyFeedView.IsDataLoaded)
{
- if (string.IsNullOrEmpty(App.Account.Credentials.UserName))
- {
- NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative));
- }
-
- else
- {
- App.MyFeedView.LoadData();
- App.LastView.LoadData();
- }
-
+ App.MyFeedView.LoadData();
+ App.LastView.LoadData();
}
}
void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)