private void SendButton_Click(object sender, RoutedEventArgs e)
{
var b = new Rect { Width = 640, Height = 480 };
var bound = MainCanvas.Strokes.GetBounds();
bound = b;
var dv = new DrawingVisual();
var dc = dv.RenderOpen();
dc.PushTransform(new TranslateTransform(-bound.X, -bound.Y));
dc.DrawRectangle(MainCanvas.Background, null, bound);
MainCanvas.Strokes.Draw(dc);
dc.Close();
var rtb = new RenderTargetBitmap((int)bound.Width, (int)bound.Height, 96, 96, PixelFormats.Default);
rtb.Render(dv);
var enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(rtb));
using (Stream s = File.Create("tegaki/" + fn))
{
enc.Save(s);
}
var d = new Dictionary<string, Stream>();
d.Add("image", new FileStream("tegaki/" + fn, FileMode.Open));
var stx = TweetDesc.Text + " " + (AddHash.IsChecked == true ? "#tdt_kbtter" : "");
if (IsReply.IsChecked == true)
{
long id = long.Parse(ReplyID.Text);
svc.SendTweetWithMedia(new SendTweetWithMediaOptions { InReplyToStatusId = id, Status = stx, Images = d });
}
else
{
svc.SendTweetWithMedia(new SendTweetWithMediaOptions { Status = stx, Images = d });
}
Close();
}