From 4913cdfcfb443050b9f388ae6fe4e14a711160bd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Dec 2009 03:55:33 -0600 Subject: [PATCH] Add more detailed and useful listing of output --- SnapShooter/MainWindow.xaml | 12 +++++++++- SnapShooter/MainWindow.xaml.cs | 34 ++++++++++++++++++++++------ SnapShooter/SnapShooter.csproj | 22 +++++++++++++++--- SnapShooter/SnapShotItem.xaml | 19 ++++++++++++++++ SnapShooter/SnapShotItem.xaml.cs | 38 ++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 SnapShooter/SnapShotItem.xaml create mode 100644 SnapShooter/SnapShotItem.xaml.cs diff --git a/SnapShooter/MainWindow.xaml b/SnapShooter/MainWindow.xaml index 4c1bc1c..da80cf1 100644 --- a/SnapShooter/MainWindow.xaml +++ b/SnapShooter/MainWindow.xaml @@ -4,6 +4,16 @@ Title="SnapShooter" Height="300" Width="600" Loaded="Window_Loaded"> - + + + + + + Enabled + + Help + + + diff --git a/SnapShooter/MainWindow.xaml.cs b/SnapShooter/MainWindow.xaml.cs index c01c051..ea5aca5 100644 --- a/SnapShooter/MainWindow.xaml.cs +++ b/SnapShooter/MainWindow.xaml.cs @@ -41,9 +41,14 @@ namespace SnapShooter { if (Clipboard.ContainsImage()) { TaskbarManager.Instance.SetOverlayIcon(foundstuff.Icon, "Found Image"); + string filename = System.IO.Path.Combine( + Environment.GetEnvironmentVariable("TEMP"), + "SnapShoot.jpg" + ); + BitmapSource b = Clipboard.GetImage(); System.Console.WriteLine(b.GetHashCode()); - FileStream s = new FileStream("clipboard.jpg", FileMode.Create); + FileStream s = new FileStream(filename, FileMode.Create); JpegBitmapEncoder j = new JpegBitmapEncoder(); j.QualityLevel = 85; j.Frames.Add(BitmapFrame.Create(b)); @@ -58,20 +63,35 @@ namespace SnapShooter { t.TransferComplete += delegate { TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress); Dispatcher.Invoke(new Action(delegate { + File.Delete(filename); + Clipboard.SetText(t.Url); - SnapShots.Items.Add(String.Format("Processed {0}x{1}\nUploaded to {2}", b.Width, b.Height, t.Url)); + + SnapShotItem i = new SnapShotItem(); + i.TransitURL = t.Url; + SnapShots.Items.Add(i); + TaskbarManager.Instance.SetOverlayIcon(null, ""); }), null); }; - t.UploadAsync("clipboard.jpg"); + t.UploadAsync(filename); Clipboard.Clear(); } - return; + } + + private void Enabled_Checked(object sender, RoutedEventArgs e) { + if (dt == null) return; + + System.Console.WriteLine("Enabled"); + dt.Start(); + } + + private void Enabled_Unchecked(object sender, RoutedEventArgs e) { + if (dt == null) return; - throw new NotImplementedException(); - TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal); - TaskbarManager.Instance.SetProgressValue(50, 100); + System.Console.WriteLine("Disabled"); + dt.Stop(); } } } diff --git a/SnapShooter/SnapShooter.csproj b/SnapShooter/SnapShooter.csproj index 3de7f2b..790474b 100644 --- a/SnapShooter/SnapShooter.csproj +++ b/SnapShooter/SnapShooter.csproj @@ -52,9 +52,18 @@ - - - + + 3.0 + + + 3.0 + + + 3.0 + + + 3.0 + @@ -65,6 +74,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + App.xaml Code @@ -88,6 +101,9 @@ Settings.settings True + + SnapShotItem.xaml + ResXFileCodeGenerator Resources.Designer.cs diff --git a/SnapShooter/SnapShotItem.xaml b/SnapShooter/SnapShotItem.xaml new file mode 100644 index 0000000..33bf9b8 --- /dev/null +++ b/SnapShooter/SnapShotItem.xaml @@ -0,0 +1,19 @@ + + + + + + + + + 12/7/2009 00:55:32 AM + + + Transit Link + + + + diff --git a/SnapShooter/SnapShotItem.xaml.cs b/SnapShooter/SnapShotItem.xaml.cs new file mode 100644 index 0000000..0e32d6e --- /dev/null +++ b/SnapShooter/SnapShotItem.xaml.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SnapShooter { + /// + /// Interaction logic for SnapShotItem.xaml + /// + public partial class SnapShotItem : UserControl { + public string TransitURL; + + public SnapShotItem() { + InitializeComponent(); + } + + private void UserControl_Loaded(object sender, RoutedEventArgs e) { + DateTimeLabel.Text = DateTime.Now.ToString(); + } + + private void Hyperlink_Click(object sender, RoutedEventArgs e) { + System.Diagnostics.Process.Start(TransitURL); + } + + private void Button_Click(object sender, RoutedEventArgs e) { + Clipboard.SetText(TransitURL); + } + } +} -- 2.25.1