private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (rect == null) { return; } if (rect.Width * rect.Height > 4) { //imgCapture.Source = null; var dt = new System.Windows.Threading.DispatcherTimer(); //ToggleWindow(); var x = RectStart.X; var y = RectStart.Y; var w = RectSize.Width; var h = RectSize.Height; var location = BitmapLocation; ToggleWindow(); Task.Delay(5).ContinueWith(task => { DoTakeScreenShot(x, y, w, h, location); // Maybe set a timer to minimize and reactivate window for a few millisecs _counter++; }).Wait(); //TODO Clean shit up var oldOp = this.Opacity; this.Opacity = 0.0f; ToggleWindow(); BitmapImage img = new BitmapImage(); img.BeginInit(); img.CacheOption = BitmapCacheOption.OnLoad; img.UriSource = new Uri(location); img.EndInit(); ctxCanvas.Children.Remove(rect); rect = null; var win = new SnippWindow(this); win.imgSrc.Source = img; win.Width = img.Width; win.Height = img.Height; win.Show(); win.Focus(); ((DraggableViewModel)win.DataContext).BitmapImage = img; ((DraggableViewModel)win.DataContext).Image64 = BitmapImageToBase64(img); ((DraggableViewModel)win.DataContext).UniqueIdentifier = ((DraggableViewModel)win.DataContext).Image64.GetHashCode(); ((DraggableViewModel)win.DataContext).ImageSource = location; ((DraggableViewModel)win.DataContext).ImgHeight = img.Height; ((DraggableViewModel)win.DataContext).ImgWidth = img.Width; win.tagName.Focus(); _windows.Add(win); ToggleWindow(); this.Opacity = oldOp; //CurrentImage = img; } }
public MainWindow() { InitializeComponent(); this.DataContext = this; _windows = new List <Window>(); _searchResult = new List <Window>(); if (File.Exists(SnippWriter.HistoryFile)) { var text = File.ReadAllText(SnippWriter.HistoryFile); var jobj = JArray.Parse(text); foreach (var item in jobj) { SnippWindow win = createWindowFromJSON(item); win.Show(); win.Focus(); _windows.Add(win); Console.WriteLine(); } } }