Exemplo n.º 1
0
 public void CheckImages(int bet, Image_Info imageOne, Image_Info imageTwo, Image_Info imageThree)
 {
     imageOne.Image   = pictureBox1.Image;
     imageTwo.Image   = pictureBox2.Image;
     imageThree.Image = pictureBox3.Image;
     //if one == two or one == three
     if (imageOne.Path.Equals(imageTwo.Path) || imageOne.Path.Equals(imageThree.Path))
     {
         int win = bet * 2;
         //if one == two or one == three AND two == three
         if (imageTwo.Path.Equals(imageThree.Path))
         {
             win = bet * 3;
             MessageBox.Show("Congradulations you've won 3x your bet! " + win.ToString());
             return;
         }
         MessageBox.Show("Congradulations you've won 2x your bet! Total: " + win.ToString());
         return;
     }
     //if two == three
     if (imageTwo.Path.Equals(imageThree.Path))
     {
         int win = bet * 2;
         //if one == three
         if (imageOne.Path.Equals(imageThree.Path))
         {
             win = bet * 3;
             MessageBox.Show("Congradulations you've won 3x your bet! " + win.ToString());
             return;
         }
         MessageBox.Show("Congradulations you've won 2x your bet! Total: " + win.ToString());
         return;
     }
 }
Exemplo n.º 2
0
        public void DeleteImage(int id)
        {
            Image_Info  img    = GetSingleImgInfo(id);
            Image_Color imgClr = GetSingleImgClr(Convert.ToInt32(img.ColorID));
            Image_Shape imgShp = GetSingleImgShp(Convert.ToInt32(img.ShapeID));

            ImageData.Image_Info.DeleteOnSubmit(img);
            ImageData.Image_Color.DeleteOnSubmit(imgClr);
            ImageData.Image_Shape.DeleteOnSubmit(imgShp);

            ImageData.SubmitChanges();
        }
Exemplo n.º 3
0
        public void UpdateImageInfo(int id, string name, int cid, int pid, int mid, string intro)
        {
            Image_Info img = GetSingleImgInfo(id);

            img.Tag            = name;
            img.Image_Category = ImageData.Image_Category.Single(c => c.ID == cid);
            img.Image_Period   = ImageData.Image_Period.Single(p => p.ID == pid);
            img.Image_Museum   = ImageData.Image_Museum.Single(m => m.ID == mid);
            img.Intro          = intro;

            ImageData.SubmitChanges();
        }
Exemplo n.º 4
0
 private void spinButton_Click(object sender, EventArgs e)
 {
     try
     {
         int        bet        = Int32.Parse(inputTextBox.Text);
         Image_Info imageOne   = new Image_Info();
         Image_Info imageTwo   = new Image_Info();
         Image_Info imageThree = new Image_Info();
         DisplayImages(imageOne, imageTwo, imageThree);
         CheckImages(bet, imageOne, imageTwo, imageThree);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 5
0
        public void DisplayImages(Image_Info imageOne, Image_Info imageTwo, Image_Info imageThree)
        {
            string[] images     = Directory.GetFiles("img");
            string[] to_display = new string[3];
            var      rand       = new Random();

            for (int i = 0; i < 3; i++)
            {
                int img = rand.Next(1, images.Length);
                to_display[i] = images[img];
            }
            imageOne.Path     = to_display[0];
            imageTwo.Path     = to_display[1];
            imageThree.Path   = to_display[2];
            pictureBox1.Image = Image.FromFile(to_display[0]);
            pictureBox2.Image = Image.FromFile(to_display[1]);
            pictureBox3.Image = Image.FromFile(to_display[2]);
        }
Exemplo n.º 6
0
        public ActionResult Save(IEnumerable <HttpPostedFileBase> files)
        {
            try
            {
                List <Image_Info> list     = new List <Image_Info>();
                List <string>     listPath = new List <string>();
                foreach (var file in files)
                {
                    string idref    = currentUser.UserName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    var    fileName = Path.GetFileNameWithoutExtension(file.FileName);

                    var img           = Image.FromStream(file.InputStream, true, true);
                    var listType      = new List <BIBIAM.Core.Entities.Parameters>();
                    var listExtension = listType;
                    using (IDbConnection db = OrmliteConnection.openConn())
                    {
                        listType      = db.Select <BIBIAM.Core.Entities.Parameters>(s => s.Type == "IMGResizeType");
                        listExtension = db.Select <BIBIAM.Core.Entities.Parameters>(s => s.Type == "IMGResizeFormat");
                    }
                    if (listType.Count == 0)
                    {
                        return(Json(new { success = false, message = "Không tìm thấy cấu hình" }));
                    }
                    foreach (BIBIAM.Core.Entities.Parameters type in listType)
                    {
                        var        refix = idref;
                        Image_Info item  = new Image_Info();
                        img = AutoResize(img, type.ParamID);
                        if (img == null)
                        {
                            return(Json(new { success = false, message = "Không tìm thấy cấu hình" }));
                        }
                        var    i = 0;
                        var    destinationPath = Path.Combine(Server.MapPath("~/Images/Image_Info"), refix);
                        var    lastRefix       = "_" + img.Width.ToString() + "x" + img.Height.ToString();
                        string extension       = ".jpg";
                        foreach (var ex in listExtension)
                        {
                            if (ex.ParamID == type.ParamID)
                            {
                                extension = ex.Value;
                                break;
                            }
                        }
                        while (System.IO.File.Exists(destinationPath + i.ToString() + lastRefix + extension))
                        {
                            i++;
                        }
                        destinationPath += i.ToString() + lastRefix + extension;
                        img.Save(destinationPath);
                        listPath.Add(destinationPath);
                        item.url              = refix + i.ToString() + lastRefix + extension;
                        item.ma_anh_goc       = idref;
                        item.chieu_rong       = img.Width;
                        item.chieu_cao        = img.Height;
                        item.dung_luong       = new FileInfo(destinationPath).Length;
                        item.loai             = Int16.Parse(type.ParamID);
                        item.trang_thai       = "Active";
                        item.trang_thai_duyet = "New";
                        item.ten_anh          = fileName + lastRefix;
                        item.mo_ta            = item.mo_ta_khong_dau = "";
                        list.Add(item);
                    }
                }
                string result = new Image_Info_DAO().UpSert(list, currentUser.UserName, "Insert");
                if (result != "true")
                {
                    foreach (var path in listPath)
                    {
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    return(Json(new { success = false, message = result }));
                }
                else
                {
                    return(Json(new { success = true, message = "Thành công" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
        }
Exemplo n.º 7
0
        //Insert one image record into database
        public void InsertImage(string tag, int caid, int pid, int mid, string intro, string id)
        {
            const int num = 128;

            Image_Info newImg = new Image_Info();

            newImg.ID         = GetNewId();
            newImg.Tag        = tag;
            newImg.CategoryID = caid;
            newImg.PeriodID   = pid;
            newImg.MuseumID   = mid;
            newImg.Intro      = intro;
            newImg.Url        = id;

            ImageProc myImage = new ImageProc(System.Web.HttpContext.Current.Server.MapPath("~/image/temp/") + id);

            myImage.SaveImage(System.Web.HttpContext.Current.Server.MapPath("~/image/repo/") + id);
            myImage.SaveMiniImage(System.Web.HttpContext.Current.Server.MapPath("~/image/repo/mini/") + id, 200);

            //计算图像中已标定的文物目标的特征值
            ImageProc roiImg = new ImageProc(System.Web.HttpContext.Current.Server.MapPath("~/image/roi/") + id);

            int[] hist_hsv = new int[num];
            roiImg.GetHSVHistogram(hist_hsv);
            string      str_hsv  = GetCharaStr(hist_hsv, num); //color descriptor
            Image_Color newColor = new Image_Color();

            double[] shape_hu = new double[7];
            roiImg.GetShapeFeature(ref shape_hu);     //Shape descriptor
            Image_Shape newShape = new Image_Shape();


            int newId;

            if (ImageData.Image_Color.Count() == 0)
            {
                newId = 0;
            }
            else
            {
                newId = ImageData.Image_Color.Max(cid => cid.ID) + 1;
            }

            newColor.ID    = newId;
            newImg.ColorID = newId;
            newColor.HSV   = str_hsv;

            newShape.ID    = newId;
            newImg.ShapeID = newId;
            newShape.s1    = shape_hu[0];
            newShape.s2    = shape_hu[1];
            newShape.s3    = shape_hu[2];
            newShape.s4    = shape_hu[3];
            newShape.s5    = shape_hu[4];
            newShape.s6    = shape_hu[5];
            newShape.s7    = shape_hu[6];

            ImageData.Image_Shape.InsertOnSubmit(newShape);
            ImageData.Image_Color.InsertOnSubmit(newColor);
            ImageData.Image_Info.InsertOnSubmit(newImg);
            ImageData.SubmitChanges();
        }
Exemplo n.º 8
0
        public Image_Info GetSingleImgInfo(int id)
        {
            Image_Info img = ImageData.Image_Info.Single(c => c.ID == id);

            return(img);
        }
Exemplo n.º 9
0
        public ActionResult Save(List <HttpPostedFileBase> files, string FolderName, string ma_website)
        {
            try
            {
                List <Image_Info> list     = new List <Image_Info>();
                List <string>     listPath = new List <string>();

                if (String.IsNullOrEmpty(FolderName.Trim()))
                {
                    FolderName = "Sản Phẩm";
                    cms_Merchant_Folder_Info item = new cms_Merchant_Folder_Info();
                    item.ma_gian_hang   = "All";
                    item.ten_thu_muc    = FolderName;
                    item.nguoi_tao      = currentUser.name;
                    item.nguoi_cap_nhat = currentUser.name;
                    string a = new cms_Merchant_Folder_Info_DAO().Insert(item);
                }

                foreach (var file in files)
                {
                    string idref    = currentUser.name + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    var    fileName = Path.GetFileNameWithoutExtension(file.FileName);

                    var img           = Image.FromStream(file.InputStream, true, true);
                    var listType      = new List <Code_Master>();
                    var listExtension = listType;
                    using (IDbConnection db = Helpers.OrmliteConnection.openConn())
                    {
                        listType      = db.Select <Code_Master>(s => s.Type == "IMGResizeType");
                        listExtension = db.Select <Code_Master>(s => s.Type == "IMGResizeFormat");
                    }
                    if (listType.Count == 0)
                    {
                        return(Json(new { success = false, message = "Không tìm thấy cấu hình" }));
                    }
                    foreach (Code_Master type in listType)
                    {
                        var        refix = idref;
                        Image_Info item  = new Image_Info();
                        img = AutoResize(img, type.Value);
                        if (img == null)
                        {
                            return(Json(new { success = false, message = "Không tìm thấy cấu hình" }));
                        }
                        var    i               = 0;
                        string FolderPath      = Server.MapPath("~/Images/Merchant_Image_Info/All" + "/" + FolderName + "/");
                        var    destinationPath = Path.Combine(FolderPath, refix);

                        if (!Directory.Exists(FolderPath))
                        {
                            Directory.CreateDirectory(FolderPath);
                        }
                        var    lastRefix = "_" + img.Width.ToString() + "x" + img.Height.ToString();
                        string extension = ".jpg";
                        foreach (var ex in listExtension)
                        {
                            if (ex.Value == type.Value)
                            {
                                extension = ex.Name;
                                break;
                            }
                        }
                        while (System.IO.File.Exists(destinationPath + i.ToString() + lastRefix + extension))
                        {
                            i++;
                        }
                        destinationPath += i.ToString() + lastRefix + extension;
                        img.Save(destinationPath);

                        listPath.Add(destinationPath);
                        item.url        = refix + i.ToString() + lastRefix + extension;
                        item.ma_anh_goc = idref;
                        item.chieu_rong = img.Width;
                        item.chieu_cao  = img.Height;
                        item.dung_luong = new FileInfo(destinationPath).Length;
                        item.thu_muc    = "All" + "/" + FolderName + "/";
                        //item.duong_dan_day_du = FolderPath + item.url;
                        item.duong_dan_day_du = new AzureHelper().UploadFile("All", item.url, destinationPath);
                        item.loai             = Int16.Parse(type.Value);
                        item.trang_thai       = "Active";
                        item.trang_thai_duyet = "New";
                        item.ten_anh          = fileName;
                        item.mo_ta            = item.mo_ta_khong_dau = "";
                        item.ma_website       = ma_website;
                        list.Add(item);
                    }
                }
                string result = new Image_Info().UpSert(list, currentUser.name);

                if (result != "true")
                {
                    foreach (var path in listPath)
                    {
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    return(Json(new { success = false, message = result }));
                }
                else
                {
                    return(Json(new { success = true, message = "Thành công" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
        }