summaryrefslogtreecommitdiff
path: root/Juick/NewPostView.xaml.cs
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2012-03-13 02:47:51 +0400
committerGravatar Vitaly Takmazov2012-03-13 02:47:51 +0400
commitea1bc13e7a6bbef3d16fb630ed7cd348d8a9e67c (patch)
tree04362f97bac727c5d35053be0d1db9c0fcad30f1 /Juick/NewPostView.xaml.cs
parentadfdd7c1afd794fab5013fdad95aad8654326d3f (diff)
add push notifications stub
fix refreshing fix images fix orientation
Diffstat (limited to 'Juick/NewPostView.xaml.cs')
-rw-r--r--Juick/NewPostView.xaml.cs28
1 files changed, 14 insertions, 14 deletions
diff --git a/Juick/NewPostView.xaml.cs b/Juick/NewPostView.xaml.cs
index 68b7efb..e044fbe 100644
--- a/Juick/NewPostView.xaml.cs
+++ b/Juick/NewPostView.xaml.cs
@@ -26,7 +26,8 @@ namespace Juick
{
public partial class NewPostView : PhoneApplicationPage
{
- private PhotoChooserTask chooser;
+ private readonly BitmapImage _attachedPhoto = new BitmapImage();
+ private PhotoChooserTask _chooser;
public NewPostView()
{
InitializeComponent();
@@ -39,7 +40,6 @@ namespace Juick
if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
{
PageTitle.Text = "reply";
- button1.Content = "reply";
textBox1.Text = "#" + _mid;
}
if (NavigationContext.QueryString.TryGetValue("rid", out _rid))
@@ -48,21 +48,23 @@ namespace Juick
}
}
- private void button1_Click(object sender, RoutedEventArgs e)
+ private void Publish(object sender, EventArgs e)
{
var request = new RestRequest("/post", Method.POST);
request.AddParameter("body", textBox1.Text);
- if (image1.Source != null)
+
+ if (_attachedPhoto.PixelHeight > 0)
{
using (var ms = new MemoryStream())
{
- var wb = new WriteableBitmap(image1, null);
- wb.SaveJpeg(ms, (int) image1.Width, (int) image1.Height, 0, 100);
+ var wb = new WriteableBitmap(_attachedPhoto);
+ wb.SaveJpeg(ms, 1024, 768, 0, 100);
request.AddFile("attach", ms.ToArray(), "file.jpg");
}
+
+
}
-
App.Client.ExecuteAsync(request, response =>
{
if (response.StatusCode != HttpStatusCode.OK)
@@ -76,20 +78,18 @@ namespace Juick
}
- private void button2_Click(object sender, RoutedEventArgs e)
+ private void AttachFile(object sender, EventArgs e)
{
- chooser = new PhotoChooserTask {ShowCamera = true};
- chooser.Completed += (o, result) =>
+ _chooser = new PhotoChooserTask {ShowCamera = true};
+ _chooser.Completed += (o, result) =>
{
if (result.TaskResult == TaskResult.OK)
{
-
- BinaryReader reader = new BinaryReader(result.ChosenPhoto);
+ _attachedPhoto.SetSource(result.ChosenPhoto);
image1.Source = new BitmapImage(new Uri(result.OriginalFileName));
-
}
};
- chooser.Show();
+ _chooser.Show();
}
}
} \ No newline at end of file