summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/Classes/AccountManager.cs15
-rw-r--r--Juick/Juick.csproj1
-rw-r--r--Juick/LoginView.xaml.cs12
-rw-r--r--Juick/MainPage.xaml.cs93
-rw-r--r--Juick/NewPostView.xaml10
-rw-r--r--Juick/NewPostView.xaml.cs42
-rw-r--r--Juick/Properties/WMAppManifest.xml5
7 files changed, 114 insertions, 64 deletions
diff --git a/Juick/Classes/AccountManager.cs b/Juick/Classes/AccountManager.cs
index f7fcc75..82fc446 100644
--- a/Juick/Classes/AccountManager.cs
+++ b/Juick/Classes/AccountManager.cs
@@ -27,7 +27,7 @@ namespace Juick.Classes
{
return new NetworkCredential
{
- UserName = IsolatedStorageSettings.ApplicationSettings.Contains("user") ?
+ UserName = IsolatedStorageSettings.ApplicationSettings.Contains("user") ?
IsolatedStorageSettings.ApplicationSettings["user"] as string : null,
Password = IsolatedStorageSettings.ApplicationSettings.Contains("password") ?
IsolatedStorageSettings.ApplicationSettings["password"] as string : null,
@@ -40,26 +40,27 @@ namespace Juick.Classes
{
IsolatedStorageSettings.ApplicationSettings["user"] = value.UserName;
IsolatedStorageSettings.ApplicationSettings["password"] = value.Password;
- } else
+ }
+ else
{
IsolatedStorageSettings.ApplicationSettings["user"] = null;
IsolatedStorageSettings.ApplicationSettings["password"] = null;
- }
+ }
}
}
- public void SignIn(Page page, string login, string pass)
+ public void SignIn(Page page, string login, string pass, Uri nextUri)
{
Credentials = new NetworkCredential(login, pass);
- page.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
- page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
+ page.NavigationService.Navigate(nextUri);
+ page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
}
public void SignOut(Page page)
{
Credentials = null;
page.NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative));
- page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
+ page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
}
}
}
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
index 5265fce..01b0392 100644
--- a/Juick/Juick.csproj
+++ b/Juick/Juick.csproj
@@ -51,6 +51,7 @@
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Controls" />
<Reference Include="Microsoft.Phone.Interop" />
+ <Reference Include="Microsoft.Xna.Framework" />
<Reference Include="RestSharp.WindowsPhone, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.104.1\lib\sl4-wp71\RestSharp.WindowsPhone.dll</HintPath>
</Reference>
diff --git a/Juick/LoginView.xaml.cs b/Juick/LoginView.xaml.cs
index 43aa8f7..5e86959 100644
--- a/Juick/LoginView.xaml.cs
+++ b/Juick/LoginView.xaml.cs
@@ -1,6 +1,7 @@
using System.Linq;
using System.Windows;
using Microsoft.Phone.Controls;
+using System;
namespace Juick
{
@@ -12,9 +13,18 @@ namespace Juick
DataContext = App.Account.Credentials;
}
+ private Uri nextUri;
+
+ protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
+ {
+ nextUri = NavigationContext.QueryString.ContainsKey("FileId") ?
+ new Uri(string.Format("/NewPostView.xaml?FileId={0}", NavigationContext.QueryString["FileId"]), UriKind.Relative)
+ : new Uri("/MainPage.xaml", UriKind.Relative);
+ }
+
private void button1_Click(object sender, RoutedEventArgs e)
{
- App.Account.SignIn(this, textBox1.Text, textBox2.Password);
+ App.Account.SignIn(this, textBox1.Text, textBox2.Password, nextUri);
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
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)
diff --git a/Juick/NewPostView.xaml b/Juick/NewPostView.xaml
index 75bfd19..1065488 100644
--- a/Juick/NewPostView.xaml
+++ b/Juick/NewPostView.xaml
@@ -27,11 +27,11 @@
</StackPanel>
<!--ContentPanel - place additional content here-->
- <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
- <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,34,0,0" Name="textBlock1" Text="Write a message" VerticalAlignment="Top" />
- <TextBox Height="333" HorizontalAlignment="Left" Margin="0,70,0,0" Name="textBox1" Text="" VerticalAlignment="Top" Width="450" TextWrapping="Wrap" MaxWidth="Infinity" InputScope="Chat" />
- <Image Height="150" HorizontalAlignment="Left" Margin="12,504,0,0" Name="image1" Stretch="Uniform" VerticalAlignment="Top" Width="425" />
- </Grid>
+ <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="5">
+ <TextBlock Height="30" HorizontalAlignment="Left" Margin="5" Name="textBlock1" Text="Write a message" VerticalAlignment="Top" />
+ <TextBox Height="333" HorizontalAlignment="Left" Margin="5" Name="textBox1" Text="" VerticalAlignment="Top" Width="450" TextWrapping="Wrap" MaxWidth="Infinity" InputScope="Chat" />
+ <Image Height="150" HorizontalAlignment="Left" Margin="10" Name="image1" Stretch="Uniform" VerticalAlignment="Top" Width="425" />
+ </StackPanel>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
diff --git a/Juick/NewPostView.xaml.cs b/Juick/NewPostView.xaml.cs
index d50b45a..e883597 100644
--- a/Juick/NewPostView.xaml.cs
+++ b/Juick/NewPostView.xaml.cs
@@ -20,6 +20,7 @@ using Juick.Classes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using RestSharp;
+using Microsoft.Xna.Framework.Media;
namespace Juick
{
@@ -35,34 +36,51 @@ namespace Juick
// When page is navigated to set data context to selected item in list
protected override void OnNavigatedTo(NavigationEventArgs e)
{
- string _rid, _mid;
- if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
+ // Get a dictionary of query string keys and values.
+ IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
+
+ // Ensure that there is at least one key in the query string, and check
+ // whether the "FileId" key is present.
+ if (queryStrings.ContainsKey("FileId"))
{
- PageTitle.Text = "reply";
- textBox1.Text = "#" + _mid;
+ App.Client.Authenticator = new HttpBasicAuthenticator(App.Account.Credentials.UserName, App.Account.Credentials.Password);
+ // Retrieve the picture from the media library using the FileID
+ // passed to the application.
+ MediaLibrary library = new MediaLibrary();
+ Picture picture = library.GetPictureFromToken(queryStrings["FileId"]);
+ _attachedPhoto.SetSource(picture.GetImage());
+ image1.Source = new WriteableBitmap(_attachedPhoto);
}
- if (NavigationContext.QueryString.TryGetValue("rid", out _rid))
+ else
{
- textBox1.Text += "/" + _rid;
+ string _rid, _mid;
+ if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
+ {
+ PageTitle.Text = "reply";
+ textBox1.Text = "#" + _mid;
+ }
+ if (NavigationContext.QueryString.TryGetValue("rid", out _rid))
+ {
+ textBox1.Text += "/" + _rid;
+ }
}
}
private void Publish(object sender, EventArgs e)
{
-
+
var request = new RestRequest("/post", Method.POST);
request.AddParameter("body", textBox1.Text);
-
if (_attachedPhoto.PixelHeight > 0)
{
using (var ms = new MemoryStream())
{
var wb = new WriteableBitmap(_attachedPhoto);
- wb.SaveJpeg(ms, 1024, 768, 0, 100);
+ wb.SaveJpeg(ms, _attachedPhoto.PixelWidth, _attachedPhoto.PixelHeight, 0, 100);
request.AddFile("attach", ms.ToArray(), "file.jpg");
}
-
-
+
+
}
App.Client.ExecuteAsync(request, response =>
{
@@ -79,7 +97,7 @@ namespace Juick
private void AttachFile(object sender, EventArgs e)
{
- _chooser = new PhotoChooserTask {ShowCamera = true};
+ _chooser = new PhotoChooserTask { ShowCamera = true };
_chooser.Completed += (o, result) =>
{
if (result.TaskResult == TaskResult.OK)
diff --git a/Juick/Properties/WMAppManifest.xml b/Juick/Properties/WMAppManifest.xml
index 33fd6ef..8f7b6da 100644
--- a/Juick/Properties/WMAppManifest.xml
+++ b/Juick/Properties/WMAppManifest.xml
@@ -19,7 +19,7 @@
<Capability Name="ID_CAP_APPOINTMENTS" />
</Capabilities>
<Tasks>
- <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
+ <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="JuickToken" TaskName="_default">
@@ -30,5 +30,8 @@
</TemplateType5>
</PrimaryToken>
</Tokens>
+ <Extensions>
+ <Extension ExtensionName="Photos_Extra_Share" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
+ </Extensions>
</App>
</Deployment> \ No newline at end of file