public void Create(ImagePath item) { string sql = string.Format("Insert Into ImagePath" + "(Id, Weather, Path)" + "Values(@Id, @Weather, @Path"); using (var cmd = new SqlCommand(sql, _connection)) { cmd.Parameters.AddWithValue("@Id", item.Id); cmd.Parameters.AddWithValue("@Weather", item.Weather); cmd.Parameters.AddWithValue("@Path", item.Path); _connection.Open(); try { cmd.ExecuteNonQuery(); } catch (SqlException ex) { throw new Exception("Insert operation wasn`t successful." + ex.Message, ex); } finally { _connection.Close(); } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); if (String.IsNullOrEmpty(ImagePath)) { ImagePath = DEFAULT_IMAGE_PATH; } ImagePath = ImagePath.TrimEnd('/') + "/"; if (String.IsNullOrEmpty(CSSPath)) { CSSPath = DEFAULT_CSS_PATH; } CSSPath = CSSPath.TrimEnd('/') + "/"; if (String.IsNullOrEmpty(ScriptPath)) { ScriptPath = DEFAULT_JS_PATH; } ScriptPath = ScriptPath.TrimEnd('/') + "/"; _status = UploadManager.Instance.Status; UploadManager.Instance.Status = null; }
/*! * \brief 确认上传图像,检查是否上传了文件。 */ protected void confirmUpload_Click(object sender, EventArgs e) { if (!imgFileUploadBtn.HasFile) { WarningNoImageUploaded(); return; } string oldImgName = renameImgTextBox.Text; // 如果用户没有填写重命名的 if (oldImgName == "") { // 则使用图片原来的名字。 oldImgName = imgFileUploadBtn.FileName; } string newImgID = m_imgDB.GenerateImgID(); // 在图片ID后面添加扩展名 newImgID += ImagePath.GetExtensionNameWithDot(imgFileUploadBtn.FileName); if (m_imgDB.AddTo(newImgID, m_sUserID, oldImgName)) { UploadImgSuccess(newImgID); } else { throw new Exception("图片上传失败"); } }
private void AddImageClick_Click(object sender, EventArgs e) { using (OpenFileDialog open = new OpenFileDialog()) { open.Title = "select Image"; open.Filter = "Image Files (*.bmp;* .jpg;*.jpeg , * .png) | * .BMP ;*.JPG; * .JPEG ; * .PNG "; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { ImagePath = openFileDialog1.FileName; var ImagePathPart = ImagePath.Split('\\').ToList(); if (ImagePathPart != null && ImagePathPart.Any()) { string strImageName = ImagePathPart.Last(); lblImagePath.Text = strImageName; } pictureBook.Image = Infrastructure.ImageUtils.GetThumbnailByImagePath(ImagePath, 135, 135); pictureBook.Visible = true; AddImageClick.Text = "Change Image"; } else { MessageBox.Show("An Error accrued in Selecting Image File ! try agin !", "Error In Selecting Image", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public ActionResult Create([Bind(Include = "Id,Title,Description,UserID,Images")] Advert advert) { advert.UserID = User.Identity.GetUserId(); if (ModelState.IsValid) { List <ImagePath> imagePaths = new List <ImagePath>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); ImagePath imagePath = new ImagePath() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid() }; imagePaths.Add(imagePath); var path = Path.Combine(Server.MapPath("~/App_Data/Upload/"), imagePath.Id + imagePath.Extension); file.SaveAs(path); } } advert.ImagePaths = imagePaths; db.Adverts.Add(advert); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(advert)); }
/// <summary> /// Get the Image that the Sprite is using /// </summary> /// <returns>An Image</returns> public Texture2D getImage() { if (getRenderer() == null) { return(null); } if (ImagePath == null) { ImagePath = PIXEL; } if (image == null && ImagePath != null || newImage) { newImage = false; if (ImagePath.Equals(PIXEL)) { image = getRenderer().getPixel(); } else { image = getResources().loadImage(ImagePath); } Center(); } return(image); }
public JsonResult DeleteFile(string id) { if (String.IsNullOrEmpty(id)) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Result = "Error" })); } try { Guid guid = new Guid(id); ImagePath fileDetail = db.ImagePaths.Find(guid); if (fileDetail == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(new { Result = "Error" })); } db.ImagePaths.Remove(fileDetail); db.SaveChanges(); var path = Path.Combine(Server.MapPath("~/App_Data/Upload/"), fileDetail.Id + fileDetail.Extension); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
protected override void Execute(NativeActivityContext context) { try { //ThreadInvoker.Instance.RunByUiThread(() => //{ string ScreenPath = ImagePath.Get(context); if ((ScreenPath != null) && (ScreenPath != string.Empty)) { if (File.Exists(ScreenPath)) { string sValue = SetText.Get(context); GetSetClick getSetClick = new GetSetClick(); ImageRecognition imgRecognition = new ImageRecognition(); getSetClick = GetSetClick.Set; bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, sValue, 10000, accuracy); Result.Set(context, result); } } //}); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndSetText", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
private void cutZones() { CutImagePath = string.Empty; var newImagePath = ImagePath.Replace(".jpg", "__.jpg"); var drawing = new Leptonica.Drawing.PixDrawing(); using (var pix = new Pix(ImagePath)) { using (Boxa boxa = new Boxa(Zones.Count)) { foreach (var zone in Zones) { boxa.AddBox(new Box((int)zone.X, (int)zone.Y, (int)zone.ActualWidth, (int)zone.ActualHeight)); } int height = (int)(Zones.Max(z => z.Y + z.Height) - Zones.Min(z => z.Y)); int width = (int)(Zones.Max(z => z.X + z.Width) - Zones.Min(z => z.X)); using (var newPix = new Pix(pix.Width, pix.Height, pix.Depth)) { using (var mask = new Pix(pix.Width, pix.Height, 1)) { drawing.MaskBoxa(mask, mask, boxa, GraphicPixelSetting.SET_PIXELS); if (!drawing.CombineMaskedGeneral(newPix, pix, mask, 0, 0)) { throw new Exception("Could not mask"); } } newPix.Save(newImagePath, ImageFileFormat.JFIF_JPEG); CutImagePath = newImagePath; } } } }
public override bool Equals(object obj) { return(obj is TouristSpotModelForImport import && Name.Equals(import.Name) && Description.Equals(import.Description) && ImagePath.Equals(import.ImagePath)); }
public override int GetHashCode() { int hash = 1; if (ImagePath.Length != 0) { hash ^= ImagePath.GetHashCode(); } if (RunPrivileged != false) { hash ^= RunPrivileged.GetHashCode(); } if (RunDocker != false) { hash ^= RunDocker.GetHashCode(); } if (AllowCommands != false) { hash ^= AllowCommands.GetHashCode(); } hash ^= injectedCredentialTypes_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Set Imagepath as default or custom /// </summary> /// <returns></returns> private object SetImagepath() { ImagePath imagepath = this.Bind(); if (imagepath.isdefault) { ServerSettings.ImagesPath = ServerSettings.DefaultImagePath; return(APIStatus.statusOK()); } else { if (!String.IsNullOrEmpty(imagepath.path) && imagepath.path != "") { if (Directory.Exists(imagepath.path)) { ServerSettings.ImagesPath = imagepath.path; return(APIStatus.statusOK()); } else { return(new APIMessage(404, "Directory Not Found on Host")); } } else { return(new APIMessage(400, "Path Missing")); } } }
//maintains ratio creates images from 7 standard web sizes and saves public void CreateImagesForWeb() { foreach (var size in sizes) { using (Image <Rgba32> image = Image.Load(ImagePath)) { int Width = (int)(image.Width * (size / (float)image.Width)); int Height = (int)(image.Height * (size / (float)image.Width)); var filename = Path.GetFileName(ImagePath); var extention = Path.GetExtension(filename); var imagePath = ImagePath.Replace(filename, $"{ImageName}_W{Width}_H{Height}{extention}"); image.Mutate(x => x .Resize(Width, Height) ); image.Save(imagePath); // Automatic encoder selected based on extension. Console.WriteLine($"File Saved As {Path.GetFileName(imagePath)}"); } } using (var imageStream = new FileStream(ImagePath, FileMode.Open)) { using (Image <Rgba32> image = Image.Load(imageStream)) { } } }
public ActionResult Update(ImagePath item, HttpPostedFileBase resim) { ImagePath gelen = ips.GetByID(item.ID); if (resim != null) { bool result; string fileResult = FxFunction.ImageUpload(resim, ImageFile.ImagePath, out result); if (result) { gelen.ProductImage = fileResult; } else { ViewBag.Message = fileResult; } } bool sonuc = ips.Update(gelen); if (sonuc) { return(RedirectToAction("Index", new { id = gelen.ProductID })); } ViewBag.Message = "Güncelleme İşlemi Başarısız"; return(View()); }
public bool Equals(CoreSetting input) { if (input == null) { return(false); } return (( Identifier == input.Identifier || (Identifier != null && Identifier.Equals(input.Identifier)) ) && ( IsDefault == input.IsDefault || (IsDefault != null && IsDefault.Equals(input.IsDefault)) ) && ( DisplayName == input.DisplayName || (DisplayName != null && DisplayName.Equals(input.DisplayName)) ) && ( Summary == input.Summary || (Summary != null && Summary.Equals(input.Summary)) ) && ( ImagePath == input.ImagePath || (ImagePath != null && ImagePath.Equals(input.ImagePath)) ) && ( ChildSettings == input.ChildSettings || (ChildSettings != null && ChildSettings.SequenceEqual(input.ChildSettings)) )); }
private Gallery GetThumbGallery(string location, string rootPath) { int thumbnailSize = 280; int mainImageMaxWidth = 2000; // note: images aren't really this size more like 640x480 int mainImageMaxHeight = 860; Gallery g = new Gallery(); g.imageData = new List <ImageData>(); // build list of images var thumbs = GetThumbs(location); g.imageData.AddRange(thumbs); // add to gallery structure foreach (var image in g.imageData) { // thumbnail ImageSize thumbSize = new ImageSize(thumbnailSize, thumbnailSize, CropType.Square); ImagePath thumbPath = new ImagePath(rootPath, site + "/nails", "thumb_4t" + thumbnailSize + "_" + image.imageName); ImageVersion thumbImage = new ImageVersion(ImageVersionTypes.DesktopForGallery, thumbSize, thumbPath); image.Versions.Add(thumbImage); // large popup ImageSize desktopForGalleryImageSize = new ImageSize(mainImageMaxHeight, mainImageMaxWidth, CropType.None); ImagePath desktopForGalleryImagePaths = new ImagePath(rootPath, site + "/nails", "thumb_b" + mainImageMaxHeight + "_" + mainImageMaxWidth + "_" + image.imageName); ImageVersion desktopForGalleryImage = new ImageVersion(ImageVersionTypes.DesktopMaxSize, desktopForGalleryImageSize, desktopForGalleryImagePaths); image.Versions.Add(desktopForGalleryImage); } return(g); }
protected override void Execute(NativeActivityContext context) { try { string sImagePath = ImagePath.Get(context); bool result = false; if (File.Exists(sImagePath)) { GetSetClick getSetClick = new GetSetClick(); ImageRecognition imgRecognition = new ImageRecognition(); getSetClick = GetSetClick.Click; result = imgRecognition.GetSetClickImage(sImagePath, getSetClick, "", 10000, Accuracy); Result.Set(context, result); } //}); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndClick", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
private void UploadPictures(IFormFileCollection pictures, int newDestinationId) { string[] supportedTypes = { ".jpg", ".jpeg", ".png" }; foreach (IFormFile picture in pictures) { string fileExtension = Path.GetExtension(picture.FileName); if (supportedTypes.Contains(fileExtension)) { string imagesDirectoryPath = "/images/destinations"; string webRootPath = _hostingEnvironment.WebRootPath; // generate unique GUID (globally unique identifier) for file to upload (prevent filename collisions) string picturePath = string.Format(@"{0}/{1}/{2}{3}", imagesDirectoryPath, newDestinationId.ToString(), Guid.NewGuid(), fileExtension); string serverSavePath = string.Format(@"{0}{1}/{2}", webRootPath, imagesDirectoryPath, newDestinationId.ToString()); Directory.CreateDirectory(serverSavePath); picture.CopyTo(new FileStream(webRootPath + picturePath, FileMode.Create)); ImagePath imagePathEntry = new ImagePath { DestinationId = newDestinationId, Path = picturePath }; _service.CreateImagePath(imagePathEntry); } } }
private Gallery GetMainGallery(string location, string rootPath) { int mainImageMaxWidth = 2000; // note: images aren't really this size more like 640x480 int mainImageMaxHeight = 860; Gallery g = new Gallery(); g.imageData = new List <ImageData>(); // build list of images var main = GetMainImage(location); g.imageData.Add(main); // add to gallery structure foreach (var image in g.imageData) { // main image ImageSize desktopForGalleryImageSize = new ImageSize(mainImageMaxHeight, mainImageMaxWidth, CropType.None); ImagePath desktopForGalleryImagePaths = new ImagePath(rootPath, site + "/nails", "thumb_b" + mainImageMaxHeight + "_" + mainImageMaxWidth + "_" + image.imageName); ImageVersion desktopForGalleryImage = new ImageVersion(ImageVersionTypes.DesktopMaxSize, desktopForGalleryImageSize, desktopForGalleryImagePaths); image.Versions.Add(desktopForGalleryImage); } return(g); }
public override int GetHashCode() { unchecked { return(((ImagePath != null ? ImagePath.GetHashCode() : 0) * 397) ^ (ImageKey != null ? ImageKey.GetHashCode() : 0)); } }
public void AddImagePath(string path) { DBObject.ImagePath imagePath = new ImagePath(); imagePath.path = path; IDatabaseHost.IImagePathsStore.Insert(imagePath); ImagePaths.Add(imagePath); }
public void Update(ImagePath item) { string sql = string.Format("Update ImagePath Set " + "Weather = '@Weather', Path = '@Path'"); using (var cmd = new SqlCommand(sql, _connection)) { cmd.Parameters.AddWithValue("@Id", item.Id); cmd.Parameters.AddWithValue("@Weather", item.Weather); cmd.Parameters.AddWithValue("@Path", item.Path); _connection.Open(); try { cmd.ExecuteNonQuery(); } catch (SqlException ex) { throw new Exception("Update operation wasn`t successful." + ex.Message, ex); } finally { _connection.Close(); } } }
private void RenameShape(string newShapeName) { if (HasNameChanged(newShapeName)) { return; } if (!IsValidName(newShapeName)) { MessageBox.Show(Utils.ShapeUtil.IsShapeNameOverMaximumLength(newShapeName) ? CommonText.ErrorNameTooLong : CommonText.ErrorInvalidCharacter); textBox.Text = shapeName; EditStatus = Status.Editing; return; } if (IsDuplicateName(newShapeName)) { EditStatus = Status.Editing; return; } //Update image string newPath = ImagePath.Replace(@"\" + shapeName, @"\" + newShapeName); if (File.Exists(ImagePath)) { File.Move(ImagePath, newPath); this.GetAddIn().ShapePresentation.RenameShape(shapeName, newShapeName); } ImagePath = newPath; ShapesLabUtils.SyncShapeRename(this.GetAddIn(), shapeName, newShapeName, parent.CurrentCategory); parent.RenameCustomShape(shapeName, newShapeName); }
protected override void SetupOnBeforeImageLoading(TaskParameter imageLoader) { base.SetupOnBeforeImageLoading(imageLoader); #if __IOS__ int width = (int)this.Bounds.Width; int height = (int)this.Bounds.Height; #elif __ANDROID__ int width = this.Width; int height = this.Height; #elif __WINDOWS__ int width = (int)this.Width; int height = (int)this.Height; #endif if ((!string.IsNullOrWhiteSpace(ImagePath) && ImagePath.IsSvgFileUrl()) || ImageStream != null) { imageLoader.WithCustomDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap)); } if (!string.IsNullOrWhiteSpace(LoadingPlaceholderImagePath) && LoadingPlaceholderImagePath.IsSvgFileUrl()) { imageLoader.WithCustomLoadingPlaceholderDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap)); } if (!string.IsNullOrWhiteSpace(ErrorPlaceholderImagePath) && ErrorPlaceholderImagePath.IsSvgFileUrl()) { imageLoader.WithCustomErrorPlaceholderDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap)); } }
/// <summary> /// Return ImagePath object /// </summary> /// <returns></returns> private object GetImagepath() { ImagePath imagepath = new ImagePath(); imagepath.path = ServerSettings.ImagesPath; imagepath.isdefault = ServerSettings.ImagesPath == ServerSettings.DefaultImagePath; return(imagepath); }
public EditorAddressBookContact(AddressBookContact _source) : base(_source) { // Change the Image path here if (!string.IsNullOrEmpty(ImagePath)) { ImagePath = Application.dataPath + "/" + ImagePath.TrimStart('/'); } }
protected override Models.Devotion Parse() { return(new Models.Devotion { Id = ToInt(DevotionID), ImagePath = ImagePath.ToString(), Prayer = Prayer.ToString(), Title = Title.ToString() }); }
public object GetImagepath() { ImagePath imagepath = new ImagePath { path = ServerSettings.Instance.ImagesPath, isdefault = ServerSettings.Instance.ImagesPath == ServerSettings.DefaultImagePath }; return(imagepath); }
protected override Models.BasicCatholicPrayer Parse() { return(new Models.BasicCatholicPrayer { Id = ToInt(BasicCatholicPrayerID), ImagePath = ImagePath.ToString(), Prayer = Prayer.ToString(), Title = Title.ToString() }); }
protected void Page_Load(object sender, EventArgs e) { // if we haven't picked an FST version, we get the one from the config file, match it with the one in the database, set it on match, error on mismatch if (Session["FST_VERSION"] == null) { try { string appConfigVersion = ConfigurationManager.AppSettings.Get("FST_VERSION"); string databaseVersion = string.Empty; try { FST.Common.Database db = new FST.Common.Database(); databaseVersion = db.getVersion(); } catch { Response.Write("Database conenction failed or internal application permissions were insufficient. Please notify the person responsible for this application."); Response.End(); return; } // we have a version mismatch, so print an error if (appConfigVersion != databaseVersion) { Response.Write("Current database version and application version do not match. This may be a configuration or deployment issue. Please notify the person responsible for this application."); Response.End(); return; } Session["FST_VERSION"] = FST_VERSION = appConfigVersion; } catch { } } else { FST_VERSION = Convert.ToString(Session["FST_VERSION"]); } try { // generate the proper path to the root URL. this actually comes out different on PWS vs IIS, so be careful about changing this. ImagePath = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath; ImagePath += (ImagePath.LastIndexOf('/') == ImagePath.Length - 1 ? string.Empty : "/"); } catch { } if (!IsPostBack) { lblConfirmation.Visible = false; } }
public static string UpdatePhoto(HttpPostedFileBase file, ImagePath path) { if (file != null) { string fileExtension = Path.GetExtension(file.FileName); string photoUrl = Guid.NewGuid().ToString(); string photoUrlOriginal = photoUrl + "_original" + fileExtension; string returnUrl = photoUrl + ".png"; string serverPath = FullImagePath(photoUrlOriginal, path); file.SaveAs(serverPath); //Resizes the pic without changing the properties of the original pic which has _or in the filename //Returning back to the controller... //Using Substring to remove the "~" from the path so that the database call can be clean in the Razor View. if (path == ImagePath.ProfileImage) { ResizeStream(256, 256, file.InputStream, FullImagePath((photoUrl + ".png"), path)); return ProfileImageDatabasePath.Substring(1) + returnUrl; } if (path == ImagePath.BlogPostImage) { ResizeStream(848, 307, file.InputStream, FullImagePath((photoUrl + ".png"), path)); return BlogImageDatabasePath.Substring(1) + returnUrl; } if (path == ImagePath.PublicImage) { //Return the original saved image path with ending "_original" return PublicImageDatabasePath.Substring(1) + photoUrlOriginal; } return null; } return null; }
public static string FullImagePath(string profileFileName, ImagePath path) { if (path == ImagePath.ProfileImage) { return Path.Combine(HttpContext.Current.Server.MapPath(ProfileImageDatabasePath), profileFileName); } if (path == ImagePath.BlogPostImage) { return Path.Combine(HttpContext.Current.Server.MapPath(BlogImageDatabasePath), profileFileName); } if (path == ImagePath.PublicImage) { return Path.Combine(HttpContext.Current.Server.MapPath(PublicImageDatabasePath), profileFileName); } return null; //TODO: So far this will only work on .jpg files, need to modify this to accept all image types. }