Add more detailed and useful listing of output
authorunknown <chip@.(none)>
Mon, 7 Dec 2009 09:55:33 +0000 (03:55 -0600)
committerunknown <chip@.(none)>
Mon, 7 Dec 2009 09:55:33 +0000 (03:55 -0600)
SnapShooter/MainWindow.xaml
SnapShooter/MainWindow.xaml.cs
SnapShooter/SnapShooter.csproj
SnapShooter/SnapShotItem.xaml [new file with mode: 0644]
SnapShooter/SnapShotItem.xaml.cs [new file with mode: 0644]

index 4c1bc1c..da80cf1 100644 (file)
@@ -4,6 +4,16 @@
     Title="SnapShooter" Height="300" Width="600"
     Loaded="Window_Loaded">
     <Grid>
-        <ListBox Name="SnapShots" />
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="*" />
+        </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>
+            </TextBlock>
+        </StackPanel>
+        <ListBox Name="SnapShots" Grid.Row="1" HorizontalContentAlignment="Stretch" />
     </Grid>
 </Window>
index c01c051..ea5aca5 100644 (file)
@@ -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();
         }
     }
 }
index 3de7f2b..790474b 100644 (file)
     </Reference>
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
-    <Reference Include="WindowsBase" />
-    <Reference Include="PresentationCore" />
-    <Reference Include="PresentationFramework" />
+    <Reference Include="UIAutomationProvider">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="PresentationCore">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="PresentationFramework">
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <ApplicationDefinition Include="App.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="SnapShotItem.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
       <DependentUpon>Settings.settings</DependentUpon>
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
+    <Compile Include="SnapShotItem.xaml.cs">
+      <DependentUpon>SnapShotItem.xaml</DependentUpon>
+    </Compile>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
diff --git a/SnapShooter/SnapShotItem.xaml b/SnapShooter/SnapShotItem.xaml
new file mode 100644 (file)
index 0000000..33bf9b8
--- /dev/null
@@ -0,0 +1,19 @@
+<UserControl x:Class="SnapShooter.SnapShotItem"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    Loaded="UserControl_Loaded" Margin="0,4,4,4">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="140"/>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="*"/>
+        </Grid.ColumnDefinitions>
+        <TextBlock Name="DateTimeLabel" Grid.Column="0" Margin="4">
+            12/7/2009 00:55:32 AM
+        </TextBlock>
+        <TextBlock Grid.Column="1" Margin="4">
+            <Hyperlink Name="TransitLink" Click="Hyperlink_Click">Transit Link</Hyperlink>
+        </TextBlock>
+        <Button Grid.Column="2" Click="Button_Click">Copy Link</Button>
+    </Grid>
+</UserControl>
diff --git a/SnapShooter/SnapShotItem.xaml.cs b/SnapShooter/SnapShotItem.xaml.cs
new file mode 100644 (file)
index 0000000..0e32d6e
--- /dev/null
@@ -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 {
+    /// <summary>
+    /// Interaction logic for SnapShotItem.xaml
+    /// </summary>
+    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);
+        }
+    }
+}