protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var curData = (DataRowView)e.Item.DataItem; var lnkName = (HyperLink)e.Item.FindControl("lnkName"); var litTeaser = (Literal)e.Item.FindControl("litTeaser"); //var lnkAvatar = (HyperLink)e.Item.FindControl("lnkAvatar"); var imgAvatar = (Image)e.Item.FindControl("imgAvatar"); lnkName.Text = curData["Content_Name"].ToString(); lnkName.NavigateUrl = UrlFilter.BuildUrlByItemID(ConvertUtility.ToInt32(curData["Distribution_ID"])); litTeaser.Text = curData["Content_Teaser"].ToString().Replace("\n", "<br />"); var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"])); if (coverInfo != null) { string avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = UrlFilter.BuildImageUrl(avatar, 120, 0); } else { imgAvatar.Visible = false; } } else { imgAvatar.Visible = false; } } }
private void OnEnable() { AudioBlender blender = (AudioBlender)target; blender.EditorAwake(); if (blender.serializeObject == null) { blender.serializeObject = CreateInstance <EditorSerializeObject>(); } if (blender.serializeObject.edit && blender.serializeObject.selection >= 0 && blender.serializeObject.selection < blender.sequenceCount && editorWindow == null) { OpenEditorWindow(blender.GetSequence(blender.serializeObject.selection)); } if (playIcon == null) { playIcon = ImageDB.GetImage("play.png", "Blenda/Editor/Images"); } if (pauseIcon == null) { pauseIcon = ImageDB.GetImage("pause.png", "Blenda/Editor/Images"); } if (stopIcon == null) { stopIcon = ImageDB.GetImage("stop.png", "Blenda/Editor/Images"); } playContent = new GUIContent(playIcon); pauseContent = new GUIContent(pauseIcon); stopContent = new GUIContent(stopIcon); Undo.undoRedoPerformed += UndoRedo; }
protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { var curData = (DataRowView)e.Item.DataItem; var litName = (Literal)e.Item.FindControl("litName"); var litTeaser = (Literal)e.Item.FindControl("litTeaser"); var litDatetime = (Literal)e.Item.FindControl("litDatetime"); var imgAvatar = (Image)e.Item.FindControl("imgAvatar"); litName.Text = curData["Content_Name"].ToString(); litTeaser.Text = curData["Content_Teaser"].ToString(); litDatetime.Text = ConvertUtility.ToDateTime(curData["Distribution_CreateDate"]).ToString("dd MMMM yyyy"); var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"])); if (coverInfo != null) { var avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = UrlFilter.BuildImageScaleHeight(avatar, 0, 50); } else { imgAvatar.Visible = false; } } else { imgAvatar.Visible = false; } } }
public void init() { minSize = maxSize = new Vector2(450, 500); #if UNITY_5_0 title = "Dreamteck Splines " + PluginInfo.version; #else titleContent = new GUIContent("Dreamteck Splines " + PluginInfo.version); #endif float x = position.x; if (x < 50) { x = 50; } else if (x > Screen.width - 500) { x = Screen.width - 500; } float y = position.y; if (y < 50) { x = 50; } else if (y > Screen.height - 550) { x = Screen.height - 550; } position = new Rect(x, y, 500, 550); changeLogPanel = new WindowPanel(); supportPanel = new WindowPanel(); homePanel = new WindowPanel(); learnPanel = new WindowPanel(); changeLogPanel.size = supportPanel.size = homePanel.size = learnPanel.size = new Vector2(maxSize.x, maxSize.y - 82); changeLogPanel.slideDuration = supportPanel.slideDuration = homePanel.slideDuration = learnPanel.slideDuration = 0.25f; homePanel.SetState(true, false); header = ImageDB.GetImage("plugin_header.png", "Splines/Editor/Icons"); changelogIcon = ImageDB.GetImage("changelog.png", "Splines/Editor/Icons"); learnIcon = ImageDB.GetImage("get_started.png", "Splines/Editor/Icons"); supportIcon = ImageDB.GetImage("support.png", "Splines/Editor/Icons"); rateIcon = ImageDB.GetImage("rate.png", "Splines/Editor/Icons"); pdfIcon = ImageDB.GetImage("pdf.png", "Splines/Editor/Icons"); videoIcon = ImageDB.GetImage("video_tutorials.png", "Splines/Editor/Icons"); string path = ResourceUtility.FindFolder(Application.dataPath, "Dreamteck/Splines/Editor"); if (Directory.Exists(path)) { if (File.Exists(path + "/changelog.txt")) { string[] lines = File.ReadAllLines(path + "/changelog.txt"); changelogText = ""; for (int i = 0; i < lines.Length; i++) { changelogText += lines[i] + "\r\n"; } } } windowInitialized = true; }
public JsonResult GetImages() { var images = new ImageDB().Headers; images = images.OrderBy(image => image.Id.CreationTime); var ids = images.Select(image => image.Id.ToString()); return(Json(ids)); }
protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var curData = (DataRowView)e.Item.DataItem; var lnkName = (HyperLink)e.Item.FindControl("lnkName"); var litTeaser = (Literal)e.Item.FindControl("litTeaser"); var litDatetime = (Literal)e.Item.FindControl("litDatetime"); //var lnkAvatar = (HyperLink)e.Item.FindControl("lnkAvatar"); var imgAvatar = (Image)e.Item.FindControl("imgAvatar"); var divRight = (HtmlGenericControl)e.Item.FindControl("divRight"); var lnkRegister = (HyperLink)e.Item.FindControl("lnkRegister"); lnkName.Text = curData["Content_Name"].ToString(); lnkName.NavigateUrl = UrlFilter.BuildUrlByItemID(ConvertUtility.ToInt32(curData["Distribution_ID"])); litTeaser.Text = curData["Content_Teaser"].ToString(); var khInfo = KhoahocDB.GetInfo(ConvertUtility.ToInt32(curData["Content_ID"])); if (khInfo != null) { litDatetime.Text = khInfo.Khoahoc_KhaiGiang; lnkRegister.NavigateUrl = UrlFilter.BuildUrlByZoneID( ConvertUtility.ToInt32( SettingDB.GetValue(AppEnv.CMS_ZoneClassRegister + AppEnv.GetLanguageFrontEnd()))) + "&khoahocid=" + khInfo.Khoahoc_ID; } //var newstime = ConvertUtility.ToDateTime(curData["Distribution_CreateDate"]); //litDatetime.Text = newstime.Day + " tháng " + newstime.Month + " năm" + newstime.Year; var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"])); if (coverInfo != null) { string avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = UrlFilter.BuildImageUrl(avatar, 120, 0); } else { imgAvatar.Visible = false; divRight.Attributes.Add("style", "width: 100%;"); } } else { imgAvatar.Visible = false; divRight.Attributes.Add("style", "width: 100%"); } } }
public FileResult GetImageData(string id) { var image = new ImageDB().GetImageByIdString(id, true); if (image != null) { return(File(image.Data, MimeTypeMap.GetMimeType(Path.GetExtension(image.OriginalFileName)))); } return(File(new byte[] {}, "text/plain")); }
public JsonResult GetImage(string id) { var image = new ImageDB().GetImageByIdString(id, false); if (image != null) { var webImage = new WebImage(image); return(Json(webImage)); } return(Json(false)); }
internal static GUIContent IconContent(string title, string iconName, string description) { GUIContent content = new GUIContent(title, description); string path = "Splines/Editor/Icons"; if (EditorGUIUtility.isProSkin) iconName += "_dark"; Texture2D tex = ImageDB.GetImage(iconName + ".png", path); if (tex != null) { content.image = tex; content.text = ""; } return content; }
//图片查询 根据工单号 public DataTable imageQuery(String orderId) { ImageDB imageDb = new ImageDB(); DataSet ds = imageDb.imageQueryByOrderId(orderId); if (ds.Tables[0].Rows.Count > 0) { return(ds.Tables[0]); } else { return(null); } }
public Image Get(int id) { ImageDB.ImageEntry entry = ImageDB.Get(id); Image i = new Image { Id = entry.Id, Name = entry.Name, MediaType = entry.MediaType, Data = entry.Data }; //a.SelfLink = typeof(Image).CreateUri(new { Id = a.Id }); return(i); }
public bool EditButton(bool selected) { float width = 40f; editButtonContent.image = ImageDB.GetImage("edit_cursor.png", "Splines/Editor/Icons"); if (editButtonContent.image != null) { editButtonContent.text = ""; width = 25f; } if (SplineEditorGUI.EditorLayoutSelectableButton(editButtonContent, true, selected, GUILayout.Width(width))) { SceneView.RepaintAll(); return(true); } return(false); }
public void EnableToolbar() { Texture2D tex = ImageDB.GetImage("presets.png", "Splines/Editor/Icons"); if (tex != null) { presetButtonContent.image = tex; presetButtonContent.text = ""; } tex = ImageDB.GetImage("move.png", "Splines/Editor/Icons"); if (tex != null) { moveButtonContent.image = tex; moveButtonContent.text = ""; } tex = ImageDB.GetImage("rotate.png", "Splines/Editor/Icons"); if (tex != null) { rotateButtonContent.image = tex; rotateButtonContent.text = ""; } tex = ImageDB.GetImage("scale.png", "Splines/Editor/Icons"); if (tex != null) { scaleButtonContent.image = tex; scaleButtonContent.text = ""; } tex = ImageDB.GetImage("normals.png", "Splines/Editor/Icons"); if (tex != null) { normalsButtonContent.image = tex; normalsButtonContent.text = ""; } tex = ImageDB.GetImage("mirror.png", "Splines/Editor/Icons"); if (tex != null) { mirrorButtonContent.image = tex; mirrorButtonContent.text = ""; } tex = ImageDB.GetImage("merge.png", "Splines/Editor/Icons"); if (tex != null) { mergeButtonContent.image = tex; mergeButtonContent.text = ""; } tex = ImageDB.GetImage("split.png", "Splines/Editor/Icons"); if (tex != null) { splitButtonContent.image = tex; splitButtonContent.text = ""; } }
void InitGUI() { titleStyle = new GUIStyle(GUI.skin.label); titleStyle.fontSize = 18; titleStyle.fontStyle = FontStyle.Bold; Color col = titleStyle.normal.textColor; col.a = 0.85f; titleStyle.normal.textColor = col; titleStyle.alignment = TextAnchor.MiddleCenter; textStyle = new GUIStyle(GUI.skin.label); textStyle.wordWrap = true; textStyle.padding = new RectOffset(10, 10, 10, 10); textStyleBold = new GUIStyle(textStyle); textStyleBold.fontStyle = FontStyle.Bold; headerTex = ImageDB.GetImage("splines2header.png", "Splines/Editor/Icons"); maxSize = minSize = new Vector2(headerTex.width, headerTex.height * 2.5f); timeOpened = Time.realtimeSinceStartup; init = true; }
protected void cmdUpdate_Click(object sender, EventArgs e) { var info = ImageDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); info.Image_Name = ConvertUtility.ToString(txtName.Text); info.Image_Description = txtTeaser.Text; info.Image_Visible = chkVisible.Checked; try { ImageDB.Update(info); lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_ERROR; } }
protected void dtlProduct_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView curData = (DataRowView)e.Item.DataItem; HyperLink lnkName = (HyperLink)e.Item.FindControl("lnkName"); var imgAvatar = (Image)e.Item.FindControl("imgAvatar"); Label lblProductPrice = (Label)e.Item.FindControl("lblProductPrice"); var txtQuantity = (TextBox)e.Item.FindControl("txtQuantity"); Label lblPriceSum = (Label)e.Item.FindControl("lblPriceSum"); var butRowUpdate = (Button)e.Item.FindControl("butRowUpdate"); var butRowDelete = (Button)e.Item.FindControl("butRowDelete"); lnkName.Text = curData["Content_Name"].ToString(); lblProductPrice.Text = String.Format("{0:0,0}", curData["Price"]) + " VNÐ"; txtQuantity.Text = curData["Quantity"].ToString(); lblPriceSum.Text = String.Format("{0:0,0}", curData["PriceSum"]) + " VNÐ"; butRowDelete.CommandArgument = butRowUpdate.CommandArgument = ConvertUtility.ToString(curData["Content_ID"]); var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"])); if (coverInfo != null) { string avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = avatar; } else { imgAvatar.Visible = false; } } else { imgAvatar.Visible = false; } } }
public BlendClipEditor(Sequence.AudioTrack.BlendClip c, int id) { clip = c; trackId = id; if (stripePattern == null) { stripePattern = ImageDB.GetImage("stripes.png", "Blenda/Editor/Images"); } if (loopIcon == null) { loopIcon = ImageDB.GetImage("loop.png", "Blenda/Editor/Images"); } if (startIcon == null) { startIcon = ImageDB.GetImage("start.png", "Blenda/Editor/Images"); } if (endIcon == null) { endIcon = ImageDB.GetImage("end.png", "Blenda/Editor/Images"); } }
public void Init() { titleContent = new GUIContent("Track Editor"); if (trackerHeadImg == null) { trackerHeadImg = ImageDB.GetImage("tracker_head.png", "Blenda/Editor/Images"); } if (startHeadImg == null) { startHeadImg = ImageDB.GetImage("start_time.png", "Blenda/Editor/Images"); } UpdateTrackEditors(); UpdateClipEditors(); FindOverlappingClips(); trackLabelStyle = new GUIStyle(GUI.skin.GetStyle("label")); trackLabelStyle.alignment = TextAnchor.UpperCenter; trackLabelStyle.fontSize = 10; trackLabelStyle.fontStyle = FontStyle.Normal; trackLabelStyle.normal.textColor = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.25f) : new Color(0f, 0f, 0f, 0.25f); isInit = true; }
protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { var curData = (DataRowView)e.Item.DataItem; var lnkName = (HyperLink)e.Item.FindControl("lnkName"); var lnkAvatar = (HyperLink)e.Item.FindControl("lnkAvatar"); var imgAvatar = (Image)e.Item.FindControl("imgAvatar"); var litTeaser = (Literal)e.Item.FindControl("litTeaser"); var distid = ConvertUtility.ToInt32(curData["Distribution_ID"]); lnkName.Text = curData["Content_Name"].ToString(); lnkName.NavigateUrl = lnkAvatar.NavigateUrl = UrlFilter.BuildUrlByItemID(distid); litTeaser.Text = curData["Content_Teaser"].ToString(); var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"])); if (coverInfo != null) { string avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = UrlFilter.BuildImageUrl(MultimediaUtility.GetOriginalImage(avatar), 224, 0); } else { imgAvatar.Visible = false; } } else { imgAvatar.Visible = false; } SessionUtility.Remove("excludeid"); SessionUtility.SetValue("excludeid", distid.ToString()); } }
private void SeeFirstImageSavedOnDB() { DBController.s_Instance.GetImage((result) => { if (WebResponse.isResultOk(result)) { debugInformationTxt.text = "Displaying Image"; //Deserialize image string imageDataResult = WebResponse.GetResponseInfo(result); ImageDB imageDB = JsonManager.DeserializeFromJson <ImageDB>(imageDataResult); //Create texture and assign it to the displayImage Texture2D tex = new Texture2D(2, 2); tex.LoadImage(imageDB.ImageDataBytes); displayImage.texture = tex; } else { debugInformationTxt.text = "There is no Image saved yet on DB"; } }); }
public object Post(BlogItemInput input) { int? imageId = null; MemoryStream imageData = new MemoryStream(); if (input.Image != null && input.Image.Length > 0) { CopyStream(input.Image.OpenStream(), imageData); ImageDB.ImageEntry imageEntry = ImageDB.AddImage(input.Image.FileName, input.Image.ContentType, imageData); imageId = imageEntry.Id; } BlogDB.PostEntry postEntry = BlogDB.AddPost(input.Title, input.Text, 1, imageId); BlogItemHandler h = new BlogItemHandler(); BlogItem createdItem = h.Get(postEntry.Id); return(new OperationResult.Created { ResponseResource = createdItem, RedirectLocation = typeof(BlogItem).CreateUri(new { id = postEntry.Id }) }); }
protected override void GetHeader() { header = ImageDB.GetImage("plugin_header.png", "Splines/Editor/Icons"); }
//删除图片 public int imageRemove(int id) { ImageDB imageDb = new ImageDB(); return(imageDb.imageDelete(id)); }
public Profile(string userName, int imageId) { UserName = userName; ImageData = ImageDB.Read(imageId); }
protected override void GetHeader() { header = ImageDB.GetImage("plugin_header1.png", "Blenda/Editor/Images"); }
protected void Page_Load(object sender, EventArgs e) { _distInfo = DistributionDB.GetInfo(ConvertUtility.ToInt32(Request.QueryString["itemid"])); if (_distInfo == null) { Visible = false; return; } DistributionDB.UpdateView(_distInfo.Distribution_ID, 1); var contentInfo = ContentDB.GetInfo(_distInfo.Distribution_ContentID); litName.Text = contentInfo.Content_Name; if (_distInfo.Distribution_DisableTeaser) { pnTeaser.Visible = false; } else { if (contentInfo.Content_Teaser.Length > 0) { litTeaser.Text = contentInfo.Content_Teaser; } else { litTeaser.Visible = false; } if (_distInfo.Distribution_DisableAvatar) { imgAvatar.Visible = false; } else { var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(contentInfo.Content_ID)); if (coverInfo != null) { string avatar = coverInfo.Image_File; if (avatar.Length > 0) { imgAvatar.ImageUrl = UrlFilter.BuildImageUrl(avatar, 150, 0); lnkAvatar.NavigateUrl = MultimediaUtility.GetOriginalImage(avatar); lnkAvatar.Attributes.Add("rel", "prettyPhoto"); lnkAvatar.ToolTip = coverInfo.Image_Description; } else { imgAvatar.Visible = false; } } else { imgAvatar.Visible = false; } } } litContent.Text = contentInfo.Content_Body; //litDatetime.Text = ConvertUtility.ToDateTime(distInfo.Distribution_CreateDate).ToString("dd/MM/yyyy"); //DataTable dtNews = DistributionDB.GetNewsForCurrent(distInfo.Distribution_ID, 5); //if (dtNews.Rows.Count == 0) //{ // pnNew.Visible = false; //} //else //{ // rptNew.DataSource = dtNews; // rptNew.DataBind(); //} }
private void initConfig() { iniFile = new IniFile(Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini"); initC = new InitConfig(); //regE = new RegEdit(); //MessageBox.Show("aaa " + Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini", "LottoryControl StatusServer" + initC.StatusServer.ToLower()); GetConfig(); //MessageBox.Show("bbb", "LottoryControl"); cf = new Config1(); //MessageBox.Show("ccc", "LottoryControl"); conn = new ConnectDB(initC); ratedb = new RateDB(conn); saledb = new SaleDB(conn); sfdb = new StaffDB(conn); thodb = new ThooDB(conn); lotdb = new LottoDB(conn); rwdb = new RewardDB(conn); fldb = new FlockDB(conn); srdb = new SaleRateDB(conn); cudb = new CustomerDB(conn); imgdb = new ImageDB(conn); nldb = new NumberLimitDB(conn); //MessageBox.Show("ddd", "LottoryControl"); rate = new Rate(); sale = new Sale(); staff = new Staff(); tho = new Thoo(); lot = new Lotto(); rw = new Reward(); fl = new FLock(); sr = new SaleRate(); cu = new Customer(); img = new Image1(); nl = new NumberLimit(); r2Down = new Rate(); r2Tod = new Rate(); r2Up = new Rate(); r3Up = new Rate(); r3Tod = new Rate(); r3Down = new Rate(); rUp = new Rate(); rDown = new Rate(); //MessageBox.Show("bbb", "LottoryControl"); rUp = ratedb.selectByPk("up"); rDown = ratedb.selectByPk("down"); r3Up = ratedb.selectByPk("3up"); r3Tod = ratedb.selectByPk("3tod"); r3Down = ratedb.selectByPk("3down"); r2Down = ratedb.selectByPk("2down"); r2Up = ratedb.selectByPk("2up"); lTho = thodb.setData(); setThoColor(); lsr = srdb.selectSRAll(); ls = saledb.selectSAll(); lnl = selectByNumberLimit(); //cboThoo = new ComboBox(); cbosf = new ComboBox(); //cboSale = new ComboBox(); //cboThoo = thodb.getCboThoo(cboThoo); cbosf = sfdb.getCboStaff(cbosf); //cboSale = saledb.getCboSale(cboSale); }
protected void dtgPix_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "delete") { int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text); ImageInfo info = ImageDB.GetInfo(id); try { string avatarsource = info.Image_File; if (avatarsource.Length > 0) { int lengUploadString3 = AppEnv.UploadImagesThumbDir.Length; string filename3 = avatarsource.Substring(lengUploadString3); FileInfo file3 = new FileInfo(Server.MapPath(AppEnv.UploadImagesThumbDir) + filename3); if (file3.Exists) { file3.Delete(); } FileInfo file4 = new FileInfo(Server.MapPath(AppEnv.UploadImagesNormalDir) + filename3); if (file4.Exists) { file4.Delete(); } FileInfo file5 = new FileInfo(Server.MapPath(AppEnv.UploadImagesOriginalDir) + filename3); if (file5.Exists) { file5.Delete(); } } ContentImageDB.Delete(_contentId, id); ImageDB.Delete(id); lblStatusUpdate.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblStatusUpdate.Text = MiscUtility.UPDATE_ERROR; } } if (e.CommandName == "updaterow") { try { int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text); ImageInfo info = ImageDB.GetInfo(id); TextBox txtPriority = (TextBox)e.Item.FindControl("txtPriority"); CheckBox chkVisible = (CheckBox)e.Item.FindControl("chkVisible"); CheckBox chkCover = (CheckBox)e.Item.FindControl("chkCover"); info.Image_Visible = ConvertUtility.ToBoolean(chkVisible.Checked); ImageDB.Update(info); ContentImageInfo ctinfo = ContentImageDB.GetInfo(_contentId, id); ctinfo.Priority = ConvertUtility.ToInt32(txtPriority.Text); ctinfo.IsCover = ConvertUtility.ToBoolean(chkCover.Checked); ContentImageDB.Update(ctinfo); lblStatusUpdate.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblStatusUpdate.Text = MiscUtility.UPDATE_ERROR; //ex.ToString(); } } if (e.CommandName == "editrow") { lblStatusUpdate.Text = lblStatusUpdate2.Text = string.Empty; var id = ConvertUtility.ToInt32(e.Item.Cells[0].Text); var info = ImageDB.GetInfo(id); chkVisible.Checked = info.Image_Visible; txtName.Text = info.Image_Name; txtTeaser.Text = info.Image_Description; txtID.Text = id.ToString(); } }
//添加图片 public int imageAdd(String imgUrl, String orderId) { ImageDB imageDb = new ImageDB(); return(imageDb.imageCreate(imgUrl, orderId)); }
protected void btnAddNew_Click(object sender, EventArgs e) { var dirAvatarOriginal = AppEnv.UploadImagesOriginalDir; const string dirAvatarNormal = AppEnv.UploadImagesNormalDir; const string dirAvatarThumb = AppEnv.UploadImagesThumbDir; var imgWidth = 0; var imgHeight = 0; double filesize = 0; string fileAvatarPath = "", newfileAvatarName = ""; var info = new ImageInfo(); var imageCount = ContentImageDB.GetQuantityImageOfContent(_contentId); if (txtFile.PostedFile.FileName.Length > 0) { //string fileAvatarName = Path.GetFileNameWithoutExtension(txtFile.PostedFile.FileName).Replace(" ", "_").Replace("#", "_"); newfileAvatarName = "image_" + _contentId + "_" + imageCount + txtFile.PostedFile.FileName.Substring(txtFile.PostedFile.FileName.LastIndexOf('.')); var file4 = new FileInfo(Server.MapPath(AppEnv.UploadImagesNormalDir) + newfileAvatarName); if (file4.Exists) { newfileAvatarName = "image_" + _contentId + "_" + imageCount + "_" + DateTime.Now.ToString("mmss") + txtFile.PostedFile.FileName.Substring(txtFile.PostedFile.FileName.LastIndexOf('.')); } txtFile.PostedFile.SaveAs(Server.MapPath(dirAvatarOriginal) + newfileAvatarName); double filesizeb = txtFile.PostedFile.ContentLength; filesize = filesizeb / 1024; //thumbnail creation starts // try // { // dinh dang width height mac dinh de scale int smallWidth = ConvertUtility.ToInt32(AppEnv.ThumbWidth);; int smallHeight = ConvertUtility.ToInt32(AppEnv.ThumbHeight); int normalWidth = ConvertUtility.ToInt32(AppEnv.NormalWidth); int normalHeight = ConvertUtility.ToInt32(AppEnv.NormalHeight); double scalesmall = 0; double scalenormal = 0; string imageUrl = Server.MapPath(dirAvatarOriginal + newfileAvatarName); // xac dinh anh chuan bi thumbnail Bitmap InputBitmap = new Bitmap(imageUrl); // tao anh bitmap // xac dinh % de resize imgWidth = InputBitmap.Width; imgHeight = InputBitmap.Height; if (smallHeight == 0)//InputBitmap.Height < InputBitmap.Width) { scalesmall = ((double)smallWidth) / InputBitmap.Width; scalenormal = ((double)normalWidth) / InputBitmap.Width; } int newSmallWidth = 0; int newSmallHeight = 0; int newNormalWidth = 0; int newNormalHeight = 0; if (smallHeight == 0) { newSmallWidth = (int)(scalesmall * InputBitmap.Width); newSmallHeight = (int)(scalesmall * InputBitmap.Height); if (normalWidth < imgWidth) { newNormalWidth = (int)(scalenormal * InputBitmap.Width); newNormalHeight = (int)(scalenormal * InputBitmap.Height); } else { newNormalWidth = imgWidth; newNormalHeight = imgHeight; } } else { newSmallWidth = smallWidth; newSmallHeight = smallHeight; newNormalWidth = normalWidth; newNormalHeight = normalHeight; } Bitmap OutputBitmapSmall = new Bitmap(InputBitmap, newSmallWidth, newSmallHeight); // tao anh bitmap voi size small moi Bitmap OutputBitmapNormal = new Bitmap(InputBitmap, newNormalWidth, newNormalHeight); // tao anh bitmap voi size normal moi // xac dinh mime type //Response.Clear(); //Response.ContentType="image/Jpeg"; //moi ImageCodecInfo[] Info = ImageCodecInfo.GetImageEncoders(); EncoderParameters Params = new EncoderParameters(1); Params.Param[0] = new EncoderParameter(Encoder.Quality, 100L); //Response.ContentType = Info[1].MimeType; //thumbnail.Save(Response.OutputStream,Info[1],Params); InputBitmap.Dispose(); OutputBitmapSmall.Save(Server.MapPath(dirAvatarThumb) + newfileAvatarName, Info[1], Params); OutputBitmapNormal.Save(Server.MapPath(dirAvatarNormal) + newfileAvatarName, Info[1], Params); // thuc hien OutputBitmapSmall.Dispose(); OutputBitmapNormal.Dispose(); // } // catch(Exception ex) // { // Response.Write("An error occurred - " + ex.ToString()); // } //MultimediaUtility.SetThumbnail(Server.MapPath(dirLarge + newfileoutsidename), Server.MapPath(dirThumb), ConvertUtility.ToInt32(Constants.ThumbWidth), ConvertUtility.ToInt32(Constants.ThumbHeight)); //ImageDB.CreateThumbnail(dirThumb, dirLarge + newfileoutsidename); fileAvatarPath = dirAvatarThumb + newfileAvatarName; //fileAvatarPath = dirAvatarOriginal + newfileAvatarName; //MultimediaUtility.SetAvatarThumbnail(Server.MapPath(fileAvatarPath), 250, 0); } else { fileAvatarPath = ""; } if (fileAvatarPath.Length > 0) { if (txtName.Text.Length > 0) { info.Image_Name = ConvertUtility.ToString(txtName.Text); } else { info.Image_Name = newfileAvatarName; } info.Image_Description = txtTeaser.Text; info.Image_File = fileAvatarPath; info.Image_CreateDate = DateTime.Now; info.Image_FileSize = ConvertUtility.ToDouble(filesize.ToString("#0.00")); info.Image_Width = imgWidth; info.Image_Height = imgHeight; info.Image_View = 0; info.User_ID = ConvertUtility.ToInt32(ckid); info.Image_Visible = chkVisible.Checked; try { var imgId = ImageDB.Insert(info); var contentImgInfo = new ContentImageInfo(); contentImgInfo.Content_ID = _contentId; contentImgInfo.Image_ID = imgId; if (imageCount == 0) { contentImgInfo.IsCover = true; } else { contentImgInfo.IsCover = false; } contentImgInfo.Priority = imageCount; ContentImageDB.Insert(contentImgInfo); Response.Redirect(Request.RawUrl + "#idTab2"); lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_ERROR; } } }