Ejemplo n.º 1
0
 public void addToActiveImages(ImageObject img)
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         using (MySqlConnection c = new MySqlConnection(DBPATH))
         {
             c.Open();
             string query = "INSERT into activeimages(image, x, y, istext) VALUES('" + img.getBase64String() +
                 "'," + prevX + ", " + prevY + ", -1)";
             prevY += 50;
             MySqlCommand mCmd = new MySqlCommand(query, c);
             mCmd.ExecuteNonQuery();
         }
     });
 }
Ejemplo n.º 2
0
 public void addImage(ImageObject img)
 {
     dbManager.addToActiveImages(img);
 }
Ejemplo n.º 3
0
        public List<ImageObject> getActiveImages()
        {
            List<ImageObject> retVal = new List<ImageObject>();
            using (MySqlConnection c = new MySqlConnection(DBPATH))
            {
                c.Open();
                MySqlCommand mCmd = new MySqlCommand(string.Format("SELECT * FROM activeimages ORDER BY id ASC;"), c);

                using (MySqlDataReader r = mCmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        switch (r.GetInt32("istext"))
                        {
                            case -1:
                                String s = r.GetString("image");
                                Byte[] bitmapData = new Byte[s.Length];
                                bitmapData = Convert.FromBase64String(FixBase64ForImage(s));
                                System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
                                streamBitmap.Seek(0, SeekOrigin.Begin);
                                Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));

                                using (var stream = new MemoryStream(bitmapData))
                                {
                                    var bitmap = new BitmapImage();
                                    bitmap.BeginInit();
                                    bitmap.StreamSource = stream;
                                    bitmap.CacheOption = BitmapCacheOption.OnLoad;
                                    bitmap.EndInit();
                                    bitmap.Freeze();

                                    ImageObject imgObj = new ImageObject(bitmap, s, r.GetInt32("x"), r.GetInt32("y"),
                                                                        r.GetInt32("id"));
                                    retVal.Add(imgObj);
                                }

                                streamBitmap.Close();
                                break;

                            case 1:
                                ImageObject textObj = new ImageObject(r.GetString("text"), r.GetInt32("x"), r.GetInt32("y"),
                                                                        r.GetInt32("id"));
                                retVal.Add(textObj);
                                break;

                            default: break;
                        }

                    }

                }
            }
            return retVal;
        }
Ejemplo n.º 4
0
        public List<ImageObject> getGalleryUpdatedImages(int latestId)
        {
            List<ImageObject> retVal = new List<ImageObject>();
            using (MySqlConnection c = new MySqlConnection(DBPATH))
            {
                c.Open();
                MySqlCommand mCmd = new MySqlCommand(string.Format("SELECT * FROM galleryimages  WHERE id > " + latestId + " ORDER BY id ASC;"), c);
                using (MySqlDataReader r = mCmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        String s = r.GetString("image");
                        Byte[] bitmapData = new Byte[s.Length];
                        bitmapData = Convert.FromBase64String(FixBase64ForImage(s));
                        System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
                        streamBitmap.Seek(0, SeekOrigin.Begin);
                        Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));

                        using (var stream = new MemoryStream(bitmapData))
                        {
                            var bitmap = new BitmapImage();
                            bitmap.BeginInit();
                            bitmap.StreamSource = stream;
                            bitmap.CacheOption = BitmapCacheOption.OnLoad;
                            bitmap.EndInit();
                            bitmap.Freeze();

                            ImageObject obj = new ImageObject(bitmap, s, r.GetInt32("x"), r.GetInt32("y"),
                                                                r.GetInt32("id"));
                            retVal.Add(obj);
                        }

                        streamBitmap.Close();
                    }

                }
            }

            return retVal;
        }