using System; using System.IO; 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; using System.Windows.Threading; using Microsoft.WindowsAPICodePack.Taskbar; using Microsoft.WindowsAPICodePack.Shell; using DominionOfAwesome; namespace SnapShooter { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { DispatcherTimer dt; StockIcon foundstuff; public MainWindow() { InitializeComponent(); dt = new DispatcherTimer(); foundstuff = new StockIcon(StockIconIdentifier.ImageFiles, StockIconSizes.ShellSize, false, false); } private void Window_Loaded(object sender, RoutedEventArgs e) { dt.Interval = new TimeSpan(0, 0, 1); dt.Tick += new EventHandler(dt_Tick); dt.Start(); } void dt_Tick(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { TaskbarManager.Instance.SetOverlayIcon(foundstuff.Icon, "Found Image"); BitmapSource b = Clipboard.GetImage(); System.Console.WriteLine(b.GetHashCode()); FileStream s = new FileStream("clipboard.jpg", FileMode.Create); JpegBitmapEncoder j = new JpegBitmapEncoder(); j.QualityLevel = 85; j.Frames.Add(BitmapFrame.Create(b)); j.Save(s); s.Close(); Transit t = new Transit(); t.Create(); 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 { Clipboard.SetText(t.Url); SnapShots.Items.Add(String.Format("Processed {0}x{1}\nUploaded to {2}", b.Width, b.Height, t.Url)); TaskbarManager.Instance.SetOverlayIcon(null, ""); }), null); }; t.UploadAsync("clipboard.jpg"); Clipboard.Clear(); } return; throw new NotImplementedException(); TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal); TaskbarManager.Instance.SetProgressValue(50, 100); } } }