protected override async Task Do(FileInfo file) { Task haveLockObj = null, haventLockObj = null; try { if (HaveSize(EditImage.LoadBitmap(file.FullName))) { if (!viewModel.Have.IsDo) { return; } haveLockObj = CopyMoveFiles.Current.ToFolder(file, viewModel.Have.Dest.FullName, viewModel.Have.IsCopy); } else if (viewModel.Havent.IsDo) { haventLockObj = CopyMoveFiles.Current.ToFolder(file, viewModel.Havent.Dest.FullName, viewModel.Havent.IsCopy); } } catch { } await haveLockObj.ToNotNull(); await haventLockObj.ToNotNull(); }
private bool UpLoadImageFile(FileInfo info) { try { /// /// striming image /// byte[] byteContent = new byte[info.Length]; FileStream objFileStream = info.OpenRead(); objFileStream.Read(byteContent, 0, byteContent.Length); objFileStream.Close(); /// /// Processing image /// byteContent = EditImage.GetThumbNail(byteContent, 124, 90, true); byteContent = EditImage.SetWatermark(byteContent, WebConfig.GetValues("FName"), 50, true, 36); /// /// DataBase operation starts /// HF_SSID.Value = getSucessID(); //DateTime dateTemp = DateTime.Parse(DDL_dobMonth.SelectedIndex.ToString() + "/" + DDL_dobDay.SelectedValue + "/" + DDL_dobYear.SelectedValue); return(MatrimonialSuccessStoryManager.AddSuccessStory(HF_SSID.Value, TB_SucessStory.Text, L_MatID.Text, TB_Bride.Text, TB_Groom.Text, DateTime.Parse(DDL_dobMonth.SelectedIndex.ToString() + "/" + DDL_dobDay.SelectedValue + "/" + DDL_dobYear.SelectedValue), byteContent)); } catch (Exception ex) { return(false); } }
/* Mode édition */ private void modeEdition_CheckedChanged(object sender, System.EventArgs e) { if (modeEdition.Checked) { if (editImage == null) { editImage = new EditImage(); } editImage.Show(); editImage.evtChangeZoom += ChangeZoom; editImage.evtChangePen += ChangePen; editImage.evtClose += CloseEditImage; editImage.SetPenColor(bitmapCpc.GetPaletteColor(numCol)); } else { if (editImage != null) { editImage.Hide(); editImage.evtChangeZoom -= ChangeZoom; editImage.evtChangePen -= ChangePen; editImage.evtClose -= CloseEditImage; editImage = null; ChangeZoom(1); } } }
/// <summary> /// 添加图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addImage_Click(object sender, RoutedEventArgs e) { //添加图片控件 EditImage img = new EditImage(); img.Width = img.Height = 40; this.container.Children.Add(img); }
private void EditMapping(object obj) { var typeImageRecord = ImageMappings.ElementAt(SelectedIndex); if (typeImageRecord != null) { EditImage.Edit(typeImageRecord); } }
void MessageControl_Observers(object sender, EditImage msg) { if (IsActive) { if (msg.CurrentShapImage == null) { EditImage(); } else { shapeControl.Invalidate(); } } }
public string editImage(EditImage model) { try { using (var client = new WebClient()) { //CONVERTO IL BASE64 IN IMMAGINE StringBuilder sbText = new StringBuilder(model.Image, model.Image.Length); sbText.Replace("\r\n", String.Empty); sbText.Replace(" ", String.Empty); Byte[] bitmapData = Convert.FromBase64String(sbText.ToString().Replace("data:image/jpeg;base64,", String.Empty)); MemoryStream streamBitmap = new MemoryStream(bitmapData); Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap)); //SCALO LE DIMENSIONI DELL'IMMAGINE Bitmap b = new Bitmap(256, 256); Graphics g = Graphics.FromImage((Image)b); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(bitImage, 0, 0, 256, 256); g.Dispose(); MemoryStream ms = new MemoryStream(); b.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] byteImage = ms.ToArray(); var SigBase64 = Convert.ToBase64String(byteImage); //CARICO L'IMMAGINE RIMPICCIOLITA var values = new NameValueCollection(); values["api_method"] = "setImage"; values["api_data"] = JsonConvert.SerializeObject(new { mobile = model.Mobile, img = SigBase64 }); var response = client.UploadValues(model.ip, values); var responseString = Encoding.Default.GetString(response); dynamic result = JsonConvert.DeserializeObject(responseString); if (!(bool)result.IsError) { this.isError = false; this.errorMessage = result.Message; } else { this.isError = true; this.errorMessage = result.Message; } } } catch (Exception e) { this.isError = true; this.errorMessage = e.Message; } return(JsonConvert.SerializeObject(new { isError = this.isError, errorMessage = this.errorMessage })); }
protected override Task Do(FileInfo src) { try { string destPath = Path.Combine(viewModel.Dest.FullName, src.Name); EditImage img = viewModel.CreateEditImage(src.FullName); SavePicture(img.GetEditBitmap(), destPath); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Editor.Do"); System.Diagnostics.Debug.WriteLine(e.ToString()); } return(Task.CompletedTask); }
private bool UpLoadImageFile() { /// striming image try { byte[] byteContent = File_Upload.FileBytes; //Insert Image into session Session.Add("ImageToCrop", EditImage.GetThumbNail(byteContent, 600, 600, true)); byteContent = null; //retruning Values return(true); } catch (Exception) { return(false); } }
protected void IB_Crop_Click(object sender, ImageClickEventArgs e) { try { ///GetImage byte[] byteArray = (byte[])Session["ImageToCrop"]; // Removing image from session Session.Remove("ImageToCrop"); /// Get Application String HttpCookieCollection objHttpCookieCollection = Request.Cookies; HttpCookie objHttpCookie = objHttpCookieCollection.Get("MatRegInfo"); string strApplicationID = Crypto.DeCrypto(objHttpCookie.Values["ApplicationID"]); /// crop image byteArray = EditImage.CropImageFile(byteArray, Convert.ToInt32(HiddenW.Value), Convert.ToInt32(HiddenH.Value), Convert.ToInt32(HiddenX.Value), Convert.ToInt32(HiddenY.Value)); /// make thumbnail byteArray = EditImage.GetThumbNail(byteArray, 128, 128, false); /// water mark image byteArray = EditImage.SetWatermark(byteArray, WebConfig.GetValues("FName"), 80, true, 16); /// upload into database if (MatrimonialAlbumManager.InsertPhoto(strApplicationID, byteArray, MatrimonialAlbumManager.ImageType.Photo)) { Response.Redirect("../Extras/Sucess.aspx"); } else { Response.Redirect("image.aspx?id=Error"); } } catch (Exception) { } }
private async Task <Tuple <string, BitmapImage> > GetTupleAsync(int index, int offset) { int startIndex = index; if (pictures.Count == 0) { return(null); } index = (index + offset + pictures.Count) % pictures.Count; try { string path = pictures[index].FullName; BitmapImage bmp = await EditImage.LoadBitmapAsync(path); return(new Tuple <string, BitmapImage>(path, bmp)); } catch { } return(null); }
public async Task <BitmapImage> TryGetImageAsync(string path) { if (path == CurrentPath) { return(Current); } if (path == PreviousPath) { return(Previous); } if (path == NextPath) { return(Next); } try { return(await EditImage.LoadBitmapAsync(path)); } catch { } return(null); }
private bool UpLoadImageFile(FileInfo info) { /* * UserAlbum_UpdateHoroscope * UserAlbum_InsertImage * * @ApplicationID varchar(15) * @Horoscope image * @HoroPassword Varchar(25) */ try { /// /// striming image /// byte[] byteContent = new byte[info.Length]; FileStream objFileStream = info.OpenRead(); objFileStream.Read(byteContent, 0, byteContent.Length); objFileStream.Close(); /// /// Processing image /// byteContent = EditImage.GetThumbNail(byteContent, 600, 600, true); byteContent = EditImage.SetWatermark(byteContent, WebConfig.GetValues("FName"), 50, true, 36); /// /// DataBase operation starts /// HttpCookieCollection objHttpCookieCollection = Request.Cookies; HttpCookie objHttpCookie = objHttpCookieCollection.Get("MatCookie5639sb"); string strApplicationID = Crypto.DeCrypto(objHttpCookie.Values["ApplicationID"]); using (SqlConnection objConnection = DBConnection.GetSqlConnection()) { SqlCommand objCommand = new SqlCommand("UserAlbum_InsertImage", objConnection); if (MatrimonialAlbumManager.IsAlbumExists(strApplicationID)) { objCommand = new SqlCommand("UserAlbum_UpdateHoroscope", objConnection); } objCommand.CommandType = CommandType.StoredProcedure; /// Inserting parameters objCommand.Parameters.Add(new SqlParameter("@ApplicationID", SqlDbType.VarChar)); objCommand.Parameters["@ApplicationID"].Value = strApplicationID; objCommand.Parameters.Add(new SqlParameter("@Horoscope", SqlDbType.Image)); objCommand.Parameters["@Horoscope"].Value = byteContent; if (!RB_H_No.Checked) { objCommand.Parameters.Add(new SqlParameter("@HoroPassword", SqlDbType.VarChar)); objCommand.Parameters["@HoroPassword"].Value = TB_Password.Text; } /// Execute Sql Query objConnection.Open(); objCommand.ExecuteNonQuery(); objConnection.Close(); } return(true); } catch (Exception ex) { // ErrorLog return(false); } }
private bool UpLoadImageFile(FileInfo info) { /* * UserAlbum_UpdateHoroscope * UserAlbum_InsertImage * * @ApplicationID varchar(15) * @Horoscope image */ try { /// /// striming image /// byte[] byteContent = new byte[info.Length]; FileStream objFileStream = info.OpenRead(); objFileStream.Read(byteContent, 0, byteContent.Length); objFileStream.Close(); /// /// Processing image /// byteContent = EditImage.GetThumbNail(byteContent, 600, 600, true); byteContent = EditImage.SetWatermark(byteContent, WebConfig.GetValues("FName"), 50, true, 36); /// /// DataBase operation starts /// string strApplicationID = MatrimonialMemberShip.GetApplicationID(TB_MatrimonialID.Text); using (SqlConnection objConnection = DBConnection.GetSqlConnection()) { SqlCommand objCommand = new SqlCommand("UserAlbum_InsertImage", objConnection); if (MatrimonialAlbumManager.IsAlbumExists(strApplicationID)) { objCommand = new SqlCommand("UserAlbum_UpdateHoroscope", objConnection); } objCommand.CommandType = CommandType.StoredProcedure; /// Inserting parameters objCommand.Parameters.Add(new SqlParameter("@ApplicationID", SqlDbType.VarChar)); objCommand.Parameters["@ApplicationID"].Value = strApplicationID; objCommand.Parameters.Add(new SqlParameter("@Horoscope", SqlDbType.Image)); objCommand.Parameters["@Horoscope"].Value = byteContent; /// Execute Sql Query objConnection.Open(); objCommand.ExecuteNonQuery(); objConnection.Close(); } return(true); } catch (Exception Ex) { ErrorLog.WriteErrorLog("Admin_Protected_DeleteHoroscope", Ex); return(false); } }
protected void Page_Load(object sender, EventArgs e) { if ((Request.QueryString["matid"] == null) || (Request.QueryString["id"] == null)) { Server.Transfer("../extras/ErrorReport.aspx"); } else { string strApplicationID; //get image byte[] byteImageArray = null; switch (Request.QueryString["id"]) { case "1": // member photo strApplicationID = MatrimonialMemberShip.GetApplicationID(Request.QueryString["matid"]); if (strApplicationID != null) { byteImageArray = MatrimonialAlbumManager.GetImage(strApplicationID, MatrimonialAlbumManager.ImageType.Photo); } break; case "2": //Album1 strApplicationID = MatrimonialMemberShip.GetApplicationID(Request.QueryString["matid"]); if (strApplicationID != null) { byteImageArray = MatrimonialAlbumManager.GetImage(strApplicationID, MatrimonialAlbumManager.ImageType.Album1); } break; case "3": //Album2 strApplicationID = MatrimonialMemberShip.GetApplicationID(Request.QueryString["matid"]); if (strApplicationID != null) { byteImageArray = MatrimonialAlbumManager.GetImage(strApplicationID, MatrimonialAlbumManager.ImageType.Album2); } break; case "4": //Album3 strApplicationID = MatrimonialMemberShip.GetApplicationID(Request.QueryString["matid"]); if (strApplicationID != null) { byteImageArray = MatrimonialAlbumManager.GetImage(strApplicationID, MatrimonialAlbumManager.ImageType.Album3); } break; case "5": //Horoscope strApplicationID = MatrimonialMemberShip.GetApplicationID(Request.QueryString["matid"]); if (strApplicationID != null) { byteImageArray = MatrimonialAlbumManager.GetImage(strApplicationID, MatrimonialAlbumManager.ImageType.Horoscope); } break; case "6": //SucessStory byteImageArray = MatrimonialAlbumManager.GetImage(Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.SucessStory); break; default: byteImageArray = null; return; } // if image present if (byteImageArray != null) { //resize image if needed switch (Request.QueryString["type"]) { case "124": byteImageArray = EditImage.GetThumbNail(byteImageArray, 124, 124, false); break; case "98": byteImageArray = EditImage.GetThumbNail(byteImageArray, 98, 98, false); break; case "75": byteImageArray = EditImage.GetThumbNail(byteImageArray, 75, 75, false); break; } //displaying image Response.ContentType = "text/HTML"; Response.BinaryWrite(byteImageArray); } else { DisplayError(); } } }
protected void IB_Crop_Click(object sender, ImageClickEventArgs e) { try { MatrimonialAlbumManager.ImageType enuImageType = MatrimonialAlbumManager.ImageType.Photo; switch (Convert.ToSByte(Session["ImageID"])) { case 1: enuImageType = MatrimonialAlbumManager.ImageType.Photo; break; case 2: enuImageType = MatrimonialAlbumManager.ImageType.Album1; break; case 3: enuImageType = MatrimonialAlbumManager.ImageType.Album2; break; case 4: enuImageType = MatrimonialAlbumManager.ImageType.Album3; break; default: Response.Redirect("image.aspx?id=Error"); break; } ///GetImage byte[] byteArray = (byte[])Session["ImageToCrop"]; // Removing image from session Session.Remove("ImageToCrop"); /// Get Application String HttpCookieCollection objHttpCookieCollection = Request.Cookies; HttpCookie objHttpCookie = objHttpCookieCollection.Get("MatCookie5639sb"); string strApplicationID = Crypto.DeCrypto(objHttpCookie.Values["ApplicationID"]); /// crop image byteArray = EditImage.CropImageFile(byteArray, Convert.ToInt32(HiddenW.Value), Convert.ToInt32(HiddenH.Value), Convert.ToInt32(HiddenX.Value), Convert.ToInt32(HiddenY.Value)); /// make thumbnail if (enuImageType == MatrimonialAlbumManager.ImageType.Photo) { byteArray = EditImage.GetThumbNail(byteArray, 128, 128, false); } else { byteArray = EditImage.GetThumbNail(byteArray, 600, 600, true); } /// water mark image byteArray = EditImage.SetWatermark(byteArray, WebConfig.GetValues("FName"), 80, true, 16); //Which image is to be uploaded ? /// Add new image(Insert) or change newimage (Update) ? switch (MatrimonialAlbumManager.IsAlbumExists(strApplicationID)) { case false: // Insert Image into database if (MatrimonialAlbumManager.InsertPhoto(strApplicationID, byteArray, enuImageType)) { Response.Redirect("../Extras/Sucess.aspx"); } else { Response.Redirect("image.aspx?id=Error"); } break; case true: // Update Image if (MatrimonialAlbumManager.InsertPhoto(strApplicationID, byteArray, enuImageType)) { Response.Redirect("../Extras/Sucess.aspx"); } else { Response.Redirect("image.aspx?id=Error"); } break; default: Response.Redirect("imaxge.aspx?id=Error"); break; } } catch (Exception) { } }
private bool UpLoadImageFile(FileInfo info) { /* * UserSuccessStory_InsertStory * * @SStoryID varchar(15) = NULL, * @MatrimonialID varchar(10) = NULL, * @Bride varchar(50) = NULL, * @Groom varchar(50) = NULL, * @WeddingDate smalldatetime = NULL, * @Photo image = NULL */ try { /// /// striming image /// byte[] byteContent = new byte[info.Length]; FileStream objFileStream = info.OpenRead(); objFileStream.Read(byteContent, 0, byteContent.Length); objFileStream.Close(); /// /// Processing image /// byteContent = EditImage.GetThumbNail(byteContent, 124, 90, true); byteContent = EditImage.SetWatermark(byteContent, WebConfig.GetValues("FName"), 50, true, 36); /// /// DataBase operation starts /// using (SqlConnection objConnection = DBConnection.GetSqlConnection()) { SqlCommand objCommand = new SqlCommand("UserSuccessStory_InsertStory", objConnection); objCommand.CommandType = CommandType.StoredProcedure; /// Inserting parameters string strTemp = getSucessID(); objCommand.Parameters.Add(new SqlParameter("@SStoryID", SqlDbType.VarChar)); objCommand.Parameters["@SStoryID"].Value = strTemp; objCommand.Parameters.Add(new SqlParameter("@SucessStory", SqlDbType.VarChar)); objCommand.Parameters["@SucessStory"].Value = TB_SucessStory.Text; objCommand.Parameters.Add(new SqlParameter("@MatrimonialID", SqlDbType.VarChar)); objCommand.Parameters["@MatrimonialID"].Value = TB_MatID.Text; objCommand.Parameters.Add(new SqlParameter("@Bride", SqlDbType.VarChar)); objCommand.Parameters["@Bride"].Value = TB_Bride.Text; objCommand.Parameters.Add(new SqlParameter("@Groom", SqlDbType.VarChar)); objCommand.Parameters["@Groom"].Value = TB_Groom.Text; /// <<<<<<<<<<<< ForTesting >>>>>>>>>>>> objCommand.Parameters.Add(new SqlParameter("@WeddingDate", SqlDbType.SmallDateTime)); objCommand.Parameters["@WeddingDate"].Value = DateTime.Parse(TB_Date.Text); objCommand.Parameters.Add(new SqlParameter("@Photo", SqlDbType.Image)); objCommand.Parameters["@Photo"].Value = byteContent; /// Execute Sql Query objConnection.Open(); objCommand.ExecuteNonQuery(); objConnection.Close(); //Setting SuccessPannel PN_Success.Visible = true; SuccessPannel1.Bind(strTemp); } return(true); } catch (Exception) { // ErrorLog return(false); } }
protected void Page_Load(object sender, EventArgs e) { if ((Request.QueryString["matid"] == null) || (Request.QueryString["id"] == null)) { } else { HttpCookieCollection objHttpCookieCollection = Request.Cookies; HttpCookie objHttpCookie = objHttpCookieCollection.Get("MatCookie5639sb"); string strMatID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]); //get image byte[] byteImageArray = null; switch (Request.QueryString["id"]) { case "1": // member photo if (strMatID != null) { byteImageArray = MatrimonialAlbumManager.GetProtectedImage(strMatID, Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.Photo); } break; case "2": //Album1 if (strMatID != null) { byteImageArray = MatrimonialAlbumManager.GetProtectedImage(strMatID, Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.Album1); } break; case "3": //Album2 if (strMatID != null) { byteImageArray = MatrimonialAlbumManager.GetProtectedImage(strMatID, Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.Album2); } break; case "4": //Album3 if (strMatID != null) { byteImageArray = MatrimonialAlbumManager.GetProtectedImage(strMatID, Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.Album3); } break; case "5": //Horoscope if (strMatID != null) { byteImageArray = MatrimonialAlbumManager.GetProtectedImage(strMatID, Request.QueryString["matid"], MatrimonialAlbumManager.ImageType.Horoscope); } break; default: byteImageArray = null; return; } // if image present if (byteImageArray != null) { //resize image if needed if (Request.QueryString["type"] == "124") { byteImageArray = EditImage.GetThumbNail(byteImageArray, 124, 124, false); } //displaying image Response.ContentType = "text/HTML"; Response.BinaryWrite(byteImageArray); } else { DisplayError(); //Write ErrorLog ErrorLog.WriteLog("ImagePro byteImageArray=Null"); } } }