From: unknown Date: Mon, 7 Dec 2009 22:16:59 +0000 (-0600) Subject: Add help window, adjust window sizes, add error handling for when Transit is down X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=33fe743473bd0659f50a67ad53f9b8e819f23955;hp=988e801c46e91156acba9273520d1a6435d19e12;p=SnapShooter.git Add help window, adjust window sizes, add error handling for when Transit is down --- diff --git a/SnapShooter/HelpWindow.xaml b/SnapShooter/HelpWindow.xaml new file mode 100644 index 0000000..27793ef --- /dev/null +++ b/SnapShooter/HelpWindow.xaml @@ -0,0 +1,45 @@ + + + + + + Operation + + SnapShooter automatically grabs images off of the clipboard and uploads them + for easy sharing with friends. + + + While the "enable" box is checked, SnapShooter will check periodically + for image data on the clipboard. When SnapShooter finds image data, it + converts it to JPEG, then uploads it to + Transit. After uploading, + SnapShooter copies the Transit URL to the clipboard so that you can immediately + paste the result into a conversation, blog, or other communication. + + + A log is kept in the SnapShooter window of recent uploads. Each + item shows a timestamp, a handy link to the Transit URL, and a button + to copy the Transit URL to the clipboard. + + Notes + + + + Be careful – while enabled, SnapShooter will upload and then destroy + any image data on the clipboard. Other kinds of data will not be affected. + + + + + SnapShooter does not (yet) save the output list on exit. Save any links + you want to keep before you exit the program. + + + + + + + diff --git a/SnapShooter/HelpWindow.xaml.cs b/SnapShooter/HelpWindow.xaml.cs new file mode 100644 index 0000000..3d3183d --- /dev/null +++ b/SnapShooter/HelpWindow.xaml.cs @@ -0,0 +1,31 @@ +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.Shapes; + +namespace SnapShooter { + /// + /// Interaction logic for HelpWindow.xaml + /// + public partial class HelpWindow : Window { + public HelpWindow() { + InitializeComponent(); + } + + private void button1_Click(object sender, RoutedEventArgs e) { + Close(); + } + + private void TransitLink_Click(object sender, RoutedEventArgs e) { + System.Diagnostics.Process.Start("http://dominionofawesome.com/transit/"); + } + } +} diff --git a/SnapShooter/MainWindow.xaml b/SnapShooter/MainWindow.xaml index da80cf1..96f4fee 100644 --- a/SnapShooter/MainWindow.xaml +++ b/SnapShooter/MainWindow.xaml @@ -1,7 +1,7 @@  @@ -11,7 +11,7 @@ Enabled - Help + Help diff --git a/SnapShooter/MainWindow.xaml.cs b/SnapShooter/MainWindow.xaml.cs index ea5aca5..45d8d83 100644 --- a/SnapShooter/MainWindow.xaml.cs +++ b/SnapShooter/MainWindow.xaml.cs @@ -2,7 +2,9 @@ using System.IO; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Text; +using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -28,7 +30,7 @@ namespace SnapShooter { public MainWindow() { InitializeComponent(); dt = new DispatcherTimer(); - foundstuff = new StockIcon(StockIconIdentifier.ImageFiles, StockIconSizes.ShellSize, false, false); + foundstuff = new StockIcon(StockIconIdentifier.Info, StockIconSizes.ShellSize, false, false); } private void Window_Loaded(object sender, RoutedEventArgs e) { @@ -46,8 +48,12 @@ namespace SnapShooter { "SnapShoot.jpg" ); + Action localCleanup = new Action(delegate { + File.Delete(filename); + TaskbarManager.Instance.SetOverlayIcon(null, ""); + }); + BitmapSource b = Clipboard.GetImage(); - System.Console.WriteLine(b.GetHashCode()); FileStream s = new FileStream(filename, FileMode.Create); JpegBitmapEncoder j = new JpegBitmapEncoder(); j.QualityLevel = 85; @@ -56,22 +62,27 @@ namespace SnapShooter { s.Close(); Transit t = new Transit(); - t.Create(); + try { + t.Create(); + } catch (WebException we) { + MessageBox.Show("Could not connect to Transit: " + we.Message + "\nThe Clipboard has been cleared.", "FFFFFFFUUUUUUUUUUUUUU-"); + Clipboard.Clear(); + localCleanup(); + return; + } + t.TransferProgress += delegate(object sender2, TransferProgressArgs tpe) { TaskbarManager.Instance.SetProgressValue((int)tpe.PercentComplete, 100); }; t.TransferComplete += delegate { TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress); Dispatcher.Invoke(new Action(delegate { - File.Delete(filename); - Clipboard.SetText(t.Url); + localCleanup(); SnapShotItem i = new SnapShotItem(); i.TransitURL = t.Url; SnapShots.Items.Add(i); - - TaskbarManager.Instance.SetOverlayIcon(null, ""); }), null); }; t.UploadAsync(filename); @@ -83,15 +94,18 @@ namespace SnapShooter { 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; - System.Console.WriteLine("Disabled"); dt.Stop(); } + + private void Help_Click(object sender, RoutedEventArgs e) { + HelpWindow helpWindow = new HelpWindow(); + helpWindow.ShowDialog(); + } } } diff --git a/SnapShooter/SnapShooter.csproj b/SnapShooter/SnapShooter.csproj index 790474b..2cffca2 100644 --- a/SnapShooter/SnapShooter.csproj +++ b/SnapShooter/SnapShooter.csproj @@ -70,6 +70,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -88,6 +92,9 @@ + + HelpWindow.xaml + Code