Add help window, adjust window sizes, add error handling for when Transit is down
+<Window x:Class="SnapShooter.HelpWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="Help" Height="320" Width="460">
+ <Grid>
+ <Button HorizontalAlignment="Right" Margin="0,0,12,12" Name="button1" VerticalAlignment="Bottom" Width="75" Height="30" Click="button1_Click">OK</Button>
+ <FlowDocumentScrollViewer Margin="12,12,12,48" Name="textBlock1">
+ <FlowDocument FontSize="10pt" FontFamily="sans-serif">
+ <Paragraph FontSize="12pt" FontWeight="Bold" Margin="0">Operation</Paragraph>
+ <Paragraph Margin="0,6pt,0,10pt">
+ SnapShooter automatically grabs images off of the clipboard and uploads them
+ for easy sharing with friends.
+ </Paragraph>
+ <Paragraph>
+ 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
+ <Hyperlink Click="TransitLink_Click">Transit</Hyperlink>. 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.
+ </Paragraph>
+ <Paragraph>
+ 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.
+ </Paragraph>
+ <Paragraph FontSize="12pt" FontWeight="Bold" Margin="0">Notes</Paragraph>
+ <List>
+ <ListItem>
+ <Paragraph>
+ Be careful – while enabled, SnapShooter will upload and then destroy
+ any image data on the clipboard. Other kinds of data will not be affected.
+ </Paragraph>
+ </ListItem>
+ <ListItem>
+ <Paragraph>
+ SnapShooter does not (yet) save the output list on exit. Save any links
+ you want to keep before you exit the program.
+ </Paragraph>
+ </ListItem>
+ </List>
+ </FlowDocument>
+ </FlowDocumentScrollViewer>
+ </Grid>
+</Window>
+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 {
+ /// <summary>
+ /// Interaction logic for HelpWindow.xaml
+ /// </summary>
+ 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/");
+ }
+ }
+}
<Window x:Class="SnapShooter.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="SnapShooter" Height="300" Width="600"
+ Title="SnapShooter" Height="300" Width="350"
Loaded="Window_Loaded">
<Grid>
<Grid.RowDefinitions>
<StackPanel Name="Menu" HorizontalAlignment="Right" Orientation="Horizontal">
<CheckBox Margin="4" Name="Enabled" Checked="Enabled_Checked" Unchecked="Enabled_Unchecked" IsChecked="True">Enabled</CheckBox>
<TextBlock Margin="4">
- <Hyperlink>Help</Hyperlink>
+ <Hyperlink Click="Help_Click">Help</Hyperlink>
</TextBlock>
</StackPanel>
<ListBox Name="SnapShots" Grid.Row="1" HorizontalContentAlignment="Stretch" />
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;
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) {
"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;
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);
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();
+ }
}
}
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Page Include="HelpWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
+ <Compile Include="HelpWindow.xaml.cs">
+ <DependentUpon>HelpWindow.xaml</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>