protected void Button1_Click(object sender, ImageClickEventArgs e) { DirectoryInfo d = new DirectoryInfo(Server.MapPath("~/Upload")); foreach (FileInfo f in d.GetFiles("*.jpg")) { byte[] buffer = new byte[f.OpenRead().Length]; f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length); PhotoManager.AddPhoto(Convert.ToInt32(Request.QueryString["AlbumID"]), f.Name, buffer); } GridView1.DataBind(); }
protected void AggiungiFoto(object sender, EventArgs e) { int AlbumID = int.Parse((string)Request.QueryString["AlbumID"]); string caption = PhotoCaption.Text; byte[] photoBytes = PhotoFile.FileBytes; DataSetVepAdminTableAdapters.PhotosTableAdapter taphotos = new DataSetVepAdminTableAdapters.PhotosTableAdapter(); DataTable dtphotos = taphotos.GetFotoByAlbumID(AlbumID); int ordine = dtphotos.Rows.Count + 1; PhotoManager.AddPhoto(AlbumID, caption, photoBytes, ordine); }
public ActionResult Upload(int id) { DirectoryInfo d = new DirectoryInfo(Server.MapPath("~/Upload")); foreach (FileInfo f in d.GetFiles("*.jpg")) { byte[] buffer = new byte[f.OpenRead().Length]; f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length); PhotoManager.AddPhoto(id, f.Name, buffer); } return(RedirectToAction("Index")); }
protected void ButtonUploadFoto_Click(object sender, EventArgs e) { if (!_isRefresh) { int AlbumID = int.Parse((string)Request.QueryString["AlbumID"]); string caption = PhotoCaption.Text; byte[] photoBytes = PhotoFile.FileBytes; //devo recuperare tutte le foto dell'album per trovare la prima posizione disponibile DataSetVepAdminTableAdapters.PhotosTableAdapter taPhotos = new DataSetVepAdminTableAdapters.PhotosTableAdapter(); DataTable dtPhotos = taPhotos.GetFotoByAlbumID(AlbumID); int ordine = dtPhotos.Rows.Count + 1; PhotoManager.AddPhoto(AlbumID, caption, photoBytes, ordine); lvFoto.DataBind(); btnChangePos.Visible = true; } }
IEnumerator ListAllImages(List <string> files) { #region 前処理:アトラクターの一時停止とシステム状態の遷移 photoManager.AttractorDisable(); if ((SystemManager.systemState & SystemManager.SystemState.MAIN) == SystemManager.SystemState.MAIN) { SystemManager.systemState = ~SystemManager.SystemState.MAIN & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.LOAD; } #endregion #region デフォルトのメタデータのキーコードを生成 photoManager.CreateKeydataCode("輝度"); photoManager.CreateKeydataCode("彩度"); photoManager.CreateKeydataCode("撮影年月"); photoManager.CreateKeywordCode("カラー"); #endregion //ファイルを均等な配列で生成 int column = (int)Mathf.Sqrt(files.Count) + 1; var span_x = (AutoDisplayAdjuster.Instance.NormalizedSize.x) / (column + 1); var span_y = (AutoDisplayAdjuster.Instance.NormalizedSize.y) / (column + 1); Vector3 createPosition = new Vector3(AutoDisplayAdjuster.Instance.BottomLeft().x + photoMargin + span_x, AutoDisplayAdjuster.Instance.TopRight().y, 0); for (var i = 0; i < files.Count; i++) { GameObject photo = new GameObject() as GameObject; GameObject sprite = new GameObject() as GameObject; var sp = sprite.AddComponent <SpriteRenderer>(); sp.material = Instantiate(spriteMaterial); sp.material.SetFloat("_Offset", 0.1f); var _p = photo.AddComponent <DflipPhoto>(); var _s = sprite.AddComponent <PhotoSprite>(); _p.sprite = _s; _p.ID = i; string[] temp = files[i].Split('/'); _p.fileName = temp[temp.Length - 1].Split('.')[0]; //画像ロード if (i >= files.Count - 1) { last = true; } Bitmap bit = TaggingFromExif(files[i], _p); _s.Load(files[i], photo, bit); #region D-FLIPアルゴリズムの衝突判定用コライダ var boxCollider = photo.AddComponent <BoxCollider>(); boxCollider.material = pm; boxCollider.size = new Vector3(sprite.GetComponent <SpriteRenderer>().bounds.size.x, sprite.GetComponent <SpriteRenderer>().bounds.size.y, 0) + 0.3f * Vector3.one; boxCollider.isTrigger = true; Rigidbody rigid = photo.AddComponent <Rigidbody>(); rigid.constraints = RigidbodyConstraints.FreezePositionZ; rigid.freezeRotation = true; rigid.useGravity = false; rigid.drag = 1f; #endregion #region タッチ用コライダ var boxCollider_s = sprite.AddComponent <BoxCollider>(); boxCollider_s.material = pm; boxCollider_s.size = sprite.GetComponent <SpriteRenderer>().bounds.size; boxCollider_s.isTrigger = true; Rigidbody rigid_s = sprite.AddComponent <Rigidbody>(); rigid_s.constraints = RigidbodyConstraints.FreezePositionZ; rigid_s.freezeRotation = true; rigid_s.useGravity = false; rigid_s.drag = 1f; sprite.AddComponent <PhotoInteraction>(); #endregion #region 初期位置&スケール photo.transform.localPosition = createPosition + PhotoManager.offset; sprite.transform.localPosition = createPosition; sp.sortingOrder = 1; photo.transform.localScale = new Vector3(0.05f, 0.05f, 1f); sprite.transform.localScale = photo.transform.localScale; #endregion photoManager.AddPhoto(_p); #region CreatePositionの調整 if ((i + 1) % column == 0) { createPosition = new Vector3(AutoDisplayAdjuster.Instance.BottomLeft().x + photoMargin, createPosition.y, createPosition.z); createPosition -= new Vector3(0, span_y, 0); } createPosition += new Vector3(span_x, 0, 0); #endregion yield return(null); } #region 後処理 GetComponent <GUIManager>().CreateButtons(); GetComponent <GUIManager>().GUIInteractable(); #region exifに関しては全画像についてexifデータが揃っていなければinteractableをオフにする if (checker != photoManager.photos.Count) { gameObject.GetComponent <GUIManager>().Deinteractable("撮影年月"); } else { photoManager.CreateMaxMinCode("撮影年月"); } #endregion SystemManager.systemState = ~SystemManager.SystemState.LOAD & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.MAIN; photoManager.AttractorEnable(); #endregion }
// Update is called once per frame void Update() { transform.position = Vector3.MoveTowards(transform.position, waypoints[waypoint].transform.position, 4 * Time.deltaTime); if (Vector3.Distance(transform.position, waypoints[waypoint].transform.position) < 0.1) { waypoint++; } if (Input.GetButton("Fire2")) { zoom = true; ui.crossHair.SetActive(true); if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 200)) { if (hit.collider.tag == "Waifu") { ui.crossHair.GetComponent <Animator>().SetBool("Photo", true); ui.redDot.SetActive(true); if (Input.GetButtonDown("Fire1")) { OnClickScreenCaptureButton(); ui.ChangeWaifuText(hit.collider.gameObject.GetComponent <WaifuClass>()); photoManager.photosLeft--; photoManager.AddPhoto(hit.collider.gameObject.GetComponent <WaifuClass>()); } } else { ui.redDot.SetActive(false); ui.crossHair.GetComponent <Animator>().SetBool("Photo", false); } } else { ui.redDot.SetActive(false); ui.crossHair.GetComponent <Animator>().SetBool("Photo", false); } } else { ui.crossHair.SetActive(false); ui.redDot.SetActive(false); ui.crossHair.GetComponent <Animator>().SetBool("Photo", false); zoom = false; } if (zoom) { if (Camera.main.fieldOfView > 50) { Camera.main.fieldOfView--; } } else { if (Camera.main.fieldOfView < 60) { Camera.main.fieldOfView++; } } }
/// <summary> ///添加照片至相册 /// </summary> /// <param name="Photos"></param> /// <param name="_alumobj"></param> private void AddPhotosToAlume(List <string> Photos, Album _alumobj) { if (Photos != null && Photos.Count > 0) { string strImgPath = ""; string strImgName = ""; FileInfo tempfile = null; System.Drawing.Image newimg = null; string miniImgtempRoot = Path.Combine(rootPath, "miniImgtemp//" + _alumobj.AlbumName); if (!Directory.Exists(miniImgtempRoot)) { Directory.CreateDirectory(miniImgtempRoot); } string miniPath = ""; PhotoInfo newphoto = null; PhotoManager manager = new PhotoManager(); #region 逐一存储照片 foreach (string _strImgName in Photos) { miniPath = ""; strImgPath = _strImgName; if (File.Exists(strImgPath)) { tempfile = new FileInfo(strImgPath); miniPath = Path.Combine(miniImgtempRoot, tempfile.Name);//缩略图名称 strImgName = tempfile.Name.Substring(0, tempfile.Name.LastIndexOf(".")); tempfile = null; newphoto = new PhotoInfo(strImgName, ""); newphoto.PhotoData = strImgPath; bool bolstate = ImgManager.Instance.MakeThumbnail(strImgPath, miniPath, 100, 100); if (bolstate) { #region 缩略图处理成功后存储照片信息 newphoto.PhotoMiniData = miniPath; ManagerStateMsg msg = manager.AddPhoto(_alumobj.AlbumNO, newphoto);//添加照片至相册 if (msg.Statevalue) { if (AddPhotoEvent != null) { AddPhotoEvent(_alumobj.AlbumName, strImgName, true); } else { if (AddPhotoEvent != null) { AddPhotoEvent(_alumobj.AlbumName, strImgName, false); } } } #endregion } else { newphoto = null; if (AddPhotoEvent != null) { AddPhotoEvent(_alumobj.AlbumName, strImgName, false); } } System.Threading.Thread.Sleep(500); } } #endregion } }
protected void AddNewPhotoButton_Click(object sender, ImageClickEventArgs e) { string name = ""; #region ValidarConFoto if (((FileUpload)FormView1.FindControl("PhotoFile")).FileBytes.Length > 0) { DirectoryInfo d = new DirectoryInfo(((FileUpload)FormView1.FindControl("PhotoFile")).PostedFile.FileName.Replace(((FileUpload)FormView1.FindControl("PhotoFile")).FileName, "")); name = ((FileUpload)FormView1.FindControl("PhotoFile")).PostedFile.FileName; FileInfo f = new FileInfo(((FileUpload)FormView1.FindControl("PhotoFile")).PostedFile.FileName); byte[] buffer = new byte[((FileUpload)FormView1.FindControl("PhotoFile")).FileBytes.Length]; f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length); Photo objPhoto = new Photo(); PhotoManager objPhotoManager = new PhotoManager(); //objPhoto = (Photo)FormView1.DataItem; #region AsignarVariablesPhoto // objPhoto.PhotoID = (TextBox)FormView1.FindControl("txtPhotoID"); objPhoto.Caption = ((TextBox)FormView1.FindControl("txtCaption")).Text; objPhoto.Categoria = ((TextBox)FormView1.FindControl("txtCategoria")).Text; objPhoto.CodigoProducto = ((TextBox)FormView1.FindControl("txtCodigoProducto")).Text; objPhoto.CodigoFabricante = ((TextBox)FormView1.FindControl("txtCodigoFabricante")).Text; objPhoto.NombreComercial = ((TextBox)FormView1.FindControl("txtNombreComercial")).Text; objPhoto.Descripcion = ((TextBox)FormView1.FindControl("txtDescripcion")).Text; objPhoto.Presentacion = ((TextBox)FormView1.FindControl("txtPresentacion")).Text; objPhoto.PartidaArancelaria = ((TextBox)FormView1.FindControl("txtPartidaArancelaria")).Text; objPhoto.PrecioCompra = ((TextBox)FormView1.FindControl("txtPrecioCompra")).Text; objPhoto.PrecioVenta = ((TextBox)FormView1.FindControl("txtPrecioVenta")).Text; objPhoto.CostoEnvioProm = ((TextBox)FormView1.FindControl("txtCostoEnvioProm")).Text; objPhoto.Tamanio = ((TextBox)FormView1.FindControl("txtTamanio")).Text; objPhoto.Peso = ((TextBox)FormView1.FindControl("txtPeso")).Text; objPhoto.TipoEmpaque = ((TextBox)FormView1.FindControl("txtTipoEmpaque")).Text; objPhoto.Historia = ((TextBox)FormView1.FindControl("txtHistoria")).Text; objPhoto.Material = ((TextBox)FormView1.FindControl("txtMaterial")).Text; objPhoto.Tecnica = ((TextBox)FormView1.FindControl("txtTecnica")).Text; #endregion #region ConFoto objPhotoManager.AddPhoto( Convert.ToInt32(Request.QueryString["AlbumID"]), objPhoto.Caption, buffer, objPhoto.Categoria, objPhoto.CodigoProducto, objPhoto.CodigoFabricante, objPhoto.NombreComercial, objPhoto.Descripcion, objPhoto.Presentacion, objPhoto.PartidaArancelaria, objPhoto.PrecioCompra, objPhoto.PrecioVenta, objPhoto.CostoEnvioProm, objPhoto.Tamanio, objPhoto.Peso, objPhoto.TipoEmpaque, objPhoto.Historia, objPhoto.Material, objPhoto.Tecnica ); #endregion } #endregion #region SinFoto else { Photo objPhoto = new Photo(); PhotoManager objPhotoManager = new PhotoManager(); objPhoto.Caption = ((TextBox)FormView1.FindControl("txtCaption")).Text; objPhoto.Categoria = ((TextBox)FormView1.FindControl("txtCategoria")).Text; objPhoto.CodigoProducto = ((TextBox)FormView1.FindControl("txtCodigoProducto")).Text; objPhoto.CodigoFabricante = ((TextBox)FormView1.FindControl("txtCodigoFabricante")).Text; objPhoto.NombreComercial = ((TextBox)FormView1.FindControl("txtNombreComercial")).Text; objPhoto.Descripcion = ((TextBox)FormView1.FindControl("txtDescripcion")).Text; objPhoto.Presentacion = ((TextBox)FormView1.FindControl("txtPresentacion")).Text; objPhoto.PartidaArancelaria = ((TextBox)FormView1.FindControl("txtPartidaArancelaria")).Text; objPhoto.PrecioCompra = ((TextBox)FormView1.FindControl("txtPrecioCompra")).Text; objPhoto.PrecioVenta = ((TextBox)FormView1.FindControl("txtPrecioVenta")).Text; objPhoto.CostoEnvioProm = ((TextBox)FormView1.FindControl("txtCostoEnvioProm")).Text; objPhoto.Tamanio = ((TextBox)FormView1.FindControl("txtTamanio")).Text; objPhoto.Peso = ((TextBox)FormView1.FindControl("txtPeso")).Text; objPhoto.TipoEmpaque = ((TextBox)FormView1.FindControl("txtTipoEmpaque")).Text; objPhoto.Historia = ((TextBox)FormView1.FindControl("txtHistoria")).Text; objPhoto.Material = ((TextBox)FormView1.FindControl("txtMaterial")).Text; objPhoto.Tecnica = ((TextBox)FormView1.FindControl("txtTecnica")).Text; #region SinFoto FileInfo f = new FileInfo(Server.MapPath("~/Images") + "\\" + "resume-photo.jpg"); byte[] buffer = new byte[f.Length]; f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length); objPhotoManager.AddPhoto( Convert.ToInt32(Request.QueryString["AlbumID"]), objPhoto.Caption, buffer, objPhoto.Categoria, objPhoto.CodigoProducto, objPhoto.CodigoFabricante, objPhoto.NombreComercial, objPhoto.Descripcion, objPhoto.Presentacion, objPhoto.PartidaArancelaria, objPhoto.PrecioCompra, objPhoto.PrecioVenta, objPhoto.CostoEnvioProm, objPhoto.Tamanio, objPhoto.Peso, objPhoto.TipoEmpaque, objPhoto.Historia, objPhoto.Material, objPhoto.Tecnica ); #endregion } #endregion ((Label)(FormView1.FindControl("lblMensaje"))).Text = "Se guarda adicion"; GridView1.DataBind(); }
protected void Button1_Click(object sender, ImageClickEventArgs e) { int seq = 0; seq = int.Parse(((TextBox)FormView1.FindControl("txtSecuencia")).Text); PhotoManager objPhotoManager = new PhotoManager(); DirectoryInfo d = new DirectoryInfo(Server.MapPath("~/Upload")); foreach (FileInfo f in d.GetFiles("*.jpg")) { byte[] buffer = new byte[f.OpenRead().Length]; f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length); objPhotoManager.AddPhoto( Convert.ToInt32(Request.QueryString["AlbumID"]) , f.Name , buffer , ((TextBox)FormView1.FindControl("txtCategoria")).Text , ((TextBox)FormView1.FindControl("txtCodigoProducto")).Text + AutocompletarCerosIzquierda(seq) + (string)(seq.ToString()) , ((TextBox)FormView1.FindControl("txtCodigoFabricante")).Text , ((TextBox)FormView1.FindControl("txtNombreComercial")).Text , ((TextBox)FormView1.FindControl("txtDescripcion")).Text , ((TextBox)FormView1.FindControl("txtPresentacion")).Text , ((TextBox)FormView1.FindControl("txtPartidaArancelaria")).Text , ((TextBox)FormView1.FindControl("txtPrecioCompra")).Text , ((TextBox)FormView1.FindControl("txtPrecioVenta")).Text , ((TextBox)FormView1.FindControl("txtCostoEnvioProm")).Text , ((TextBox)FormView1.FindControl("txtTamanio")).Text , ((TextBox)FormView1.FindControl("txtPeso")).Text , ((TextBox)FormView1.FindControl("txtTipoEmpaque")).Text , ((TextBox)FormView1.FindControl("txtHistoria")).Text , ((TextBox)FormView1.FindControl("txtMaterial")).Text , ((TextBox)FormView1.FindControl("txtTecnica")).Text ); seq = seq + 1; } GridView1.DataBind(); lblMensajeMasivo.Text = "Se guardo Correctamente Masivo"; UploadList.DataBind(); }