Skip to content

Instantly share code, notes, and snippets.

View svstoichkov's full-sized avatar

Svetlozar Stoichkov svstoichkov

  • @ggCircuit
  • Bulgaria
View GitHub Profile
if (e.Key == startKey)
{
if (handler != null)
{
this.isScanning = true;
e.Handled = true;
}
}
else if (this.isScanning && e.Key == endKey)
{
private IEnumerable<Cookie> ReadCookies(string cookiesPath, string hostName)
{
using (var conn = new SqliteConnection("Data Source=" + cookiesPath))
{
using (var cmd = conn.CreateCommand())
{
var prm = cmd.CreateParameter();
prm.ParameterName = "hostName";
prm.Value = hostName;
cmd.Parameters.Add(prm);
private Image DrawText(String text, Font font, Color textColor, Color backColor)
{
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(1, 1);
Graphics drawing = Graphics.FromImage(img);
//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);
//free up the dummy image and old graphics object
public override int SaveChanges()
{
try
{
return base.SaveChanges();
}
catch (DbEntityValidationException ex)
{
// Retrieve the error messages as a list of strings.
var errorMessages = ex.EntityValidationErrors