public void PreviewSnip(Snip toPreview) { if (toPreview is null) { return; } _selectedSnip = toPreview; if (_readyToExport) { Cursor = Cursors.Wait; _readyToExport = false; return; } Clipboard.SetDataObject(toPreview.BitmapImageScreenshot); var previewWindow = new PreviewWindow(toPreview) { Owner = GetWindow(this), WindowClosed = window => _previews.Remove(window) }; _previews.Add(previewWindow); previewWindow.Show(); }
private async void ImgurExport(object sender, ExecutedRoutedEventArgs e) { if (_snips.Count < 0) { return; } _readyToExport = true; CustomMessageBox.ShowOK("Select a snip to export", "Export", "OK"); while (_selectedSnip is null) { await Task.Delay(25); } var url = await _selectedSnip.ImgurExport(); Cursor = Cursors.Arrow; _selectedSnip = null; var result = CustomMessageBox.ShowYesNo( $"Image exported successfully. URL is {url}", "Success!", "Copy URL", "Don't copy URL" ); if (result == MessageBoxResult.Yes) { Clipboard.SetDataObject(url); } }
private void Apend(Snip logged) { using (StreamWriter sw = File.AppendText(filepath)) { sw.WriteLine(logged.ToString()); } }
public PreviewWindow(Snip toPreview) { InitializeComponent(); Title = "Previewing Snip"; _toPreview = toPreview; _showingDecoration = true; MouseDown += DragToMove; MouseDoubleClick += ToggleDecoration; Preview.Source = toPreview.BitmapImageScreenshot; Closing += OnClosing; }
private PreviewWindow(Snip toPreview, double x, double y, bool shouldShowDecoration) : this(toPreview) { if (shouldShowDecoration) { WindowStyle = WindowStyle.SingleBorderWindow; AllowsTransparency = false; } else { WindowStyle = WindowStyle.None; AllowsTransparency = true; } _showingDecoration = shouldShowDecoration; Left = x; Top = y; }
public ScreenshotTaker(Snip snip) { InitializeComponent(); for (var r = 0; r < MainGrid.RowDefinitions.Count; ++r) { for (var c = 0; c < MainGrid.ColumnDefinitions.Count; ++c) { var border = new Border { Opacity = 0.5, Background = new SolidColorBrush(Colors.White), BorderBrush = new SolidColorBrush(Colors.Red), BorderThickness = new Thickness(0) }; border.SetValue(Grid.RowProperty, r); border.SetValue(Grid.ColumnProperty, c); if (r == 1 && c == 1) { _center = border; } MainGrid.Children.Add(border); } } _snip = snip; BackgroundImage.Source = _snip.BitmapImageScreenshot; MainGrid.Cursor = Cursors.Cross; _timer = new Timer(1) { Enabled = false, AutoReset = true, }; _timer.Elapsed += UpdateRect; WindowState = WindowState.Maximized; Activate(); }
public static void Information(string text) { Snip log = ToLog(text); new Log().Apend(log); }
protected void Button1_Click(object sender, EventArgs e) { try { var _db = new SnipContext(); var newsnip = new Snip(); if (TextBox1.Text == "") newsnip.SnipTitle = "Untitled"; else newsnip.SnipTitle = TextBox1.Text; newsnip.SnipLanguage = langitems[DropDownList1.SelectedIndex].Text; newsnip.SnipCreatedTime = DateTime.Now; if (DropDownList2.SelectedIndex == 6) newsnip.SnipExpirationTime = DateTime.MaxValue; else { TimeSpan result; TimeSpan.TryParse(timeitems[DropDownList2.SelectedIndex].Value, out result); newsnip.SnipExpirationTime = newsnip.SnipCreatedTime.Add(result); } if (User.Identity.IsAuthenticated) { var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); newsnip.SnipCreatedBy = manager.GetEmail(User.Identity.GetUserId()); } else { newsnip.SnipCreatedBy = "*****@*****.**"; } if(DropDownList3.SelectedIndex == 2 && !User.Identity.IsAuthenticated) { err.Text = "You cannot create Private Snips!"; return; } else newsnip.SnipAccessType = DropDownList3.SelectedIndex; if(DropDownList3.SelectedIndex == 1 && TextBox2.Text == "") { err.Text = "Password cannot be left empty for Protected mode!"; } else { newsnip.SnipAccessPass = TextBox2.Text; if (TextArea1.Text == "") { err.Text = "Textbox cannot be left empty!"; } else { newsnip.SnipContent = TextArea1.Text; _db.Snips.Add(newsnip); _db.SaveChanges(); string s = Codec.Encode(newsnip.SnipID); TextBox1.Text = s; Response.Redirect(GetRouteUrl("ViewByID", new { snipid = s }),false); } } } catch { err.Text = "Sorry! Something went wrong."; } }