📄 imagegallery.cs
字号:
{
case "GoToFolder":
if (textArray1.Length == 2)
{
string text1 = textArray1[1];
this.CurrentImagesFolder = text1;
this.returnMessage = "Navigated to " + text1 + ".";
}
break;
case "CreateFolder":
if (textArray1.Length == 2)
{
if (!this.AllowDirectoryCreate)
{
this.returnMessage = "Your permissions do not allow you do create directories";
}
else
{
string text2 = textArray1[1];
try
{
info1.CreateSubdirectory(text2);
this.returnMessage = "Folder created";
}
catch (Exception exception2)
{
exception1 = exception2;
this.returnMessage = "Error creating folder: " + info1.FullName + @"\" + text2 + ": " + exception1.ToString();
}
}
}
break;
case "DeleteFolder":
if (textArray1.Length == 2)
{
if (!this.AllowDirectoryDelete)
{
this.returnMessage = "Your permissions do not allow you do delete directories";
}
else
{
string text3 = textArray1[1];
try
{
Directory.Delete(info1.FullName + @"\" + text3, true);
this.returnMessage = "Directory deleted.";
}
catch (Exception exception3)
{
exception1 = exception3;
this.returnMessage = "Failed to delete: " + info1.FullName + @"\" + text3 + ": " + exception1.ToString();
}
}
}
break;
case "DeleteImage":
if (textArray1.Length == 2)
{
if (!this.AllowImageDelete)
{
this.returnMessage = "Your permissions do not allow you do delete images";
}
else
{
string text4 = textArray1[1];
try
{
File.Delete(info1.FullName + @"\" + text4);
this.returnMessage = "Image deleted.";
}
catch (Exception exception4)
{
exception1 = exception4;
this.returnMessage = "failed to delete: " + info1.FullName + @"\" + text4 + ": " + exception1.ToString();
}
}
}
break;
case "UploadImage":
if (!this.AllowImageUpload)
{
this.returnMessage = "Your permissions do not allow you do upload images";
}
else if (this.inputFile == null)
{
this.returnMessage = "Error: InputFile control not yet created!";
}
else
{
if ((this.inputFile.PostedFile == null) || (this.inputFile.PostedFile.FileName == null))
{
throw new Exception("No file was uploaded!!");
}
string text5 = this.inputFile.PostedFile.FileName.Substring(this.inputFile.PostedFile.FileName.LastIndexOf(@"\") + 1);
this.inputFile.PostedFile.SaveAs(this.context.Server.MapPath(this.CurrentImagesFolder) + @"\" + text5);
this.returnMessage = "Image uploaded";
this.context.Cache.Remove("FTB-Images-" + this.CurrentImagesFolder);
}
break;
}
}
public void RaisePostDataChangedEvent()
{
}
protected override void Render(HtmlTextWriter writer)
{
this.RenderStyles(writer);
writer.Write("\r\n<table height=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n<tr><td colspan=\"2\" height=\"20\" id=\"GalleryTop\"><h3>Image Gallery</h3></td></tr>\r\n<tr>\r\n<td style=\"padding:0px;margin:0px;\">\r\n\t<div id=\"Gallery\" style=\"width:100%; height:" + (this.browserInfo.IsIE5plus ? "100%" : "400px") + "; overflow: auto;margin:0px; background-color: #fff;border: 1px solid #CCC;\">");
this.RenderImages(writer);
writer.Write("\r\n\t</div>\r\n</td>\r\n<td width=\"220\" valign=\"top\" style=\"padding:5px;\">\r\n\t<div id=\"GallerySideBar\">\r\n\t<fieldset style=\"width:220px;\"><legend>Preview</legend>\r\n\t\t<div style=\"width:210px;height:150px;overflow:auto;\">\r\n\t\t\t<img id=\"img_preview\" src=\"" + this.CreateResourceString("spacer", ResourceType.Utility) + "\" />\t\t\t\t\r\n\t\t</div>\r\n\t</fieldset>\r\n\t<!--\r\n\t<fieldset style=\"width:220px;\"><legend>Info</legend>\r\n\t\t<table>\t\r\n\t\t\t<tr><td class=\"f_title\">Url</td>\r\n\t\t\t\t<td><div id=\"img_url\" style=\"width:150px;overflow:hidden;\" /></td>\r\n\t\t\t\t</tr>\t\r\n\t\t\t<tr><td class=\"f_title\">Filesize</td>\r\n\t\t\t\t<td><div id=\"img_size\" style=\"width:150px;\" /></td>\r\n\t\t\t\t</tr>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t</table>\r\n\t</fieldset>\r\n\t-->\t\r\n\r\n\t<fieldset style=\"width:220px;\"><legend>Dimensions</legend>\r\n\t\t<table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td valign=\"top\"><input type=\"radio\" id=\"img_dim_original\" name=\"img_dim\" onclick=\"FTB_DimensionChange(this);\" checked=\"true\" /><label for=\"img_dim_original\">Original Size</a></td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_width\" style=\"width:45px;\" onchange=\"FTB_UpdatePreview(this);\" disabled=\"true\" />x<input type=\"text\" id=\"img_height\" style=\"width:45px;\" onchange=\"FTB_UpdatePreview(this);\" disabled=\"true\" />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td valign=\"top\"><input type=\"radio\" id=\"img_dim_custom\" name=\"img_dim\" onclick=\"FTB_DimensionChange(this);\" /><label for=\"img_dim_custom\">Custom Size</a></td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_width_custom\" style=\"width:45px;\" onkeyup=\"FTB_UpdatePreview(this);\" disabled=\"true\" />x<input type=\"text\" id=\"img_height_custom\" style=\"width:45px;\" onkeyup=\"FTB_UpdatePreview(this);\" disabled=\"true\" />\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t<input type=\"checkbox\" id=\"img_lockRatio\" checked=\"checked\" /> <label for=\"img_lockRatio\">Lock image ratio</a>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><input type=\"radio\" id=\"img_dim_percentage\" name=\"img_dim\" onclick=\"FTB_DimensionChange(this);\" /><label for=\"img_dim_percentage\">Percentage</label></td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_percentage\" style=\"width:45px;\" onkeyup=\"FTB_UpdatePreview(this);\" disabled=\"true\" />\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t</fieldset>\r\n\r\n\t<fieldset style=\"width:220px;\"><legend>Properties</legend>\r\n\t\t<table>\r\n\t\t\t<tr>\r\n\t\t\t<tr><td class=\"f_title\">Align</td>\r\n\t\t\t\t<td><select id=\"img_align\" >\r\n\t\t\t\t\t\t<option value=''>NotSet</option>\r\n\t\t\t\t\t\t<option value='top'>Top</option>\r\n\t\t\t\t\t\t<option value='bottom'>Bottom</option>\r\n\t\t\t\t\t\t<option value='left'>Left</option>\r\n\t\t\t\t\t\t<option value='right'>Right</option>\r\n\t\t\t\t\t\t<option value='center'>Center</option>\r\n\t\t\t\t\t\t<option value='absmiddle'>AbsMiddle</option>\r\n\t\t\t\t\t</select>\r\n\t\t\t\t\tBorder \t<input type=\"text\" id=\"img_border\" style=\"width:30px;\" />\t\t\t\t\t\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\t\r\n\t\t\t<tr><td class=\"f_title\">VSpace</td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_vspace\" style=\"width:30px;\"/> HSpace<input type=\"text\" id=\"img_hspace\" style=\"width:30px;\"/></td>\r\n\t\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t<tr><td class=\"f_title\">Alt</td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_alt\" style=\"width:150px;\"/></td>\r\n\t\t\t\t</tr>\r\n\t\t\t<tr><td class=\"f_title\">Title</td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_title\" style=\"width:150px;\"/></td>\r\n\t\t\t\t</tr>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t</table>\r\n\t</fieldset>\r\n\t<div style=\"text-align:center;padding-bottom: 20px;\">\r\n\t\t<input type=\"button\" class=\"button\" value=\"Insert\" onclick=\"FTB_InsertImage();\" />\r\n\t</div>\r\n\t</div>\r\n</td>\r\n</tr>\r\n\t\t<tr id=\"GalleryBottom\"><td colspan=\"2\" style=\"height:60px;padding-left:10px;\">\r\n\t\t\t<table>\r\n\t\t\t<tr><td colspan=\"2\"><div id=\"img_feedback_title\">" + ((this.returnMessage != string.Empty) ? "Message" : "Status") + "</div></td>\r\n\t\t\t\t<td><input type=\"text\" id=\"img_feedback_message\"" + ((this.returnMessage != string.Empty) ? ("value=\"" + this.returnMessage + "\"") : "") + " disabled=\"disabled\" style=\"width:300px;\" /></td>\t\t\t\r\n\t\t\t\t<td>\t\r\n\t\t\t\t\t<input type=\"button\" id=\"command_DeleteFolderButton\" class=\"button\" value=\"Delete Folder\" onclick=\"FTB_DeleteFolder('" + this.ClientID + "');\" style=\"display:none;\" />\r\n\t\t\t\t\t<input type=\"button\" id=\"command_DeleteImageButton\" class=\"button\" value=\"Delete Image\" onclick=\"FTB_DeleteImage('" + this.ClientID + "');\" style=\"display:none;\" />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\r\n\t\t\t<tr><td>Upload File</td>\r\n\t\t\t<td><img src=\"" + this.CreateResourceString("image", ResourceType.Utility) + "\" width=\"16\" height=\"16\" /></td>\r\n\t\t\t<td>\t\t\t\r\n");
this.inputFile.Attributes["class"] = "button";
this.inputFile.Size = 0x2a;
this.inputFile.Attributes["style"] = "width: 300px;";
this.inputFile.RenderControl(writer);
writer.Write("\r\n\t\t\t</td><td>\r\n\t\t\t\t<input type=\"button\" id=\"command_UploadButton\" class=\"button\" value=\"Upload\" onclick=\"FTB_UploadFile('" + this.ClientID + "');\" />\r\n\t\t\t</td><td>\r\n\t\t\t\t \r\n\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td>Create Folder</td>\r\n\t\t\t<td><img src=\"" + this.CreateResourceString("folder.small", ResourceType.Utility) + "\" width=\"16\" height=\"16\" /></td>\r\n\t\t\t<td>\r\n\t\t\t\t<input type=\"text\" id=\"command_NewFolderName\" style=\"width:300px;\" />\r\n\t\t\t</td><td>\r\n\t\t\t\t<input type=\"button\" id=\"command_NewFolderButton\" class=\"button\" value=\"Create Folder\" onclick=\"FTB_CreateFolder('" + this.ClientID + "');\" />\r\n\t\t\t</td><td>\r\n\t\t\t\t \t\t\t\t\r\n\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t</table>\t\t\r\n\t\r\n\t\t</td></tr>");
writer.Write("\r\n</table>");
writer.Write("<input type=\"hidden\" id=\"TargetFreeTextBox\" value=\"" + this.TargetFreeTextBox + "\" />");
base.Render(writer);
}
protected virtual void RenderImages(HtmlTextWriter writer)
{
string text2;
ArrayList list1 = this.GetImages();
string[] textArray1 = this.ReturnDirectoriesArray();
string text1 = HttpContext.Current.Request.PhysicalApplicationPath;
if (this.request.ApplicationPath == "/")
{
text2 = this.request.ApplicationPath;
}
else
{
text2 = this.request.ApplicationPath + "/";
}
if (this.CurrentImagesFolder != this.RootImagesFolder)
{
string text3 = "";
if (this.CurrentImagesFolder.IndexOf("/") > -1)
{
text3 = this.CurrentImagesFolder.Substring(0, this.CurrentImagesFolder.LastIndexOf("/"));
}
writer.Write("\n<div class=\"thumbnail\">\n");
writer.Write("\t<div class=\"imageholder\" unselectable=\"on\" onclick=\"FTB_FolderClick(this);\" ondblclick=\"FTB_GoToFolder('" + this.ClientID + "','" + this.RootImagesFolder + "','" + text3 + "');\">");
writer.Write("\t\t" + string.Format("<img src=\"{0}\" title=\"{1}\" unselectable=\"on\" align=\"absmiddle\" vspace=\"26\" />", this.CreateResourceString("folder.up", ResourceType.Utility), text3, "Navigate Up"));
writer.Write("\t</div>\n");
writer.Write("<div class=\"titleHolder\">Up</div>");
writer.Write("</div>");
}
if ((textArray1 != null) && (textArray1.Length != 0))
{
foreach (string text4 in textArray1)
{
string text5 = text4.Replace(text1, "").Replace(@"\", "/");
string text6 = text5.Substring(text5.LastIndexOf("/") + 1);
string text7 = this.CurrentImagesFolder + "/" + text6;
writer.Write("\n<div class=\"thumbnail\">\n");
writer.Write("\t<div class=\"imageholder\" unselectable=\"on\" onclick=\"FTB_FolderClick(this,'" + text6 + "');\" ondblclick=\"FTB_GoToFolder('" + this.ClientID + "','" + this.RootImagesFolder + "','" + text7 + "');\">");
writer.Write("\t\t" + string.Format("<img src=\"{0}\" title=\"{1}\" unselectable=\"on\" align=\"absmiddle\" vspace=\"19\" />", this.CreateResourceString("folder.big", ResourceType.Utility), text7));
writer.Write("\t</div>\n");
writer.Write("<div class=\"titleHolder\">" + text6 + "</div>");
writer.Write("</div>");
}
}
if ((list1 == null) || (list1.Count == 0))
{
writer.Write("There are no images: " + this.context.Server.MapPath(this.CurrentImagesFolder).Replace(text1, "").Replace(@"\", "/"));
}
else
{
foreach (FreeTextBoxControls.ImageInfo info1 in list1)
{
writer.Write("\n<div class=\"thumbnail\">\n");
string[] textArray2 = new string[] { "\t<div class=\"imageholder\" unselectable=\"on\" onclick=\"FTB_PreviewImage(this,'", info1.AbsoluteWebPath.Substring(0, info1.AbsoluteWebPath.LastIndexOf("/")), "','", info1.Filename, "',", info1.Width.ToString(), ",", info1.Height.ToString(), ",'", (info1.Size / ((long) 0x400)).ToString(), " KB');\" ondblclick=\"FTB_InsertImage();\">\n" };
writer.Write(string.Concat(textArray2));
writer.Write("\t\t" + string.Format("<img src=\"{0}\" title=\"{1}\" unselectable=\"on\" align=\"absmiddle\" width=\"{2}\" height=\"{3}\" vspace=\"{4}\" />", new object[] { info1.ThumbnailAbsoluteWebPath, info1.AbsoluteWebPath, info1.ThumbnailWidth, info1.ThumbnailHeight, info1.ThumbnailVSpace }) + "\n");
writer.Write("\t</div>\n");
writer.Write("\t<div class=\"titleHolder\">" + info1.Filename + "</div>\n");
writer.Write("</div>\n");
}
}
}
protected virtual void RenderStyles(HtmlTextWriter writer)
{
writer.Write("<style type=\"text/css\">\r\n\r\nbody {\r\n\tmargin: 0px 0px 0px 0px;\r\n\tpadding: 0px 0px 0px 0px;\r\n\twidth: 100%;\r\n\toverflow:hidden;\r\n\tborder: 0;\r\n\tbackground-color: #ECE9D8;\r\n\tcolor: #000000;\r\n}\r\nform { \r\n\tmargin: 0px;\r\n\tpadding: 0px;\r\n}\r\ndiv.thumbnail {\r\n\twidth: 120px;\r\n\theight: 100px;\r\n\ttext-align: center;\t\t\t\r\n\tfloat: left;\r\n\tfont: 10pt verdana;\r\n\tmargin: 5px;\r\n\toverflow: hidden;\r\n}\r\ndiv.imageholder {\r\n\tmargin: 0px;\r\n\tpadding: 1px;\r\n\tborder: 1px solid #CCCCCC;\t\r\n\twidth: 101px;\r\n\theight: 81px;\r\n}\r\n\r\ndiv.titleholder {\r\n\tfont-family: arial;\r\n\tfont-size: 8pt;\r\n\twidth: 100px;\r\n\ttext-overflow: ellipsis;\r\n\toverflow: hidden;\r\n\twhite-space: nowrap;\t\t\t\r\n}\t\t\r\ntable {\r\n font: 11px Tahoma,Verdana,sans-serif;\r\n}\r\nform p {\r\n margin-top: 5px;\r\n margin-bottom: 5px;\r\n}\r\nh3 { margin: 0; margin-top: 4px; margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;}\r\nfieldset { padding: 0px 10px 5px 5px; }\r\n.button { width: 75px; }\r\nselect, input, button { font: 11px Tahoma,Verdana,sans-serif; }\r\n.space { padding: 2px; }\r\n.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px;\r\n\tborder-bottom: 1px solid black; letter-spacing: 2px;\r\n}\r\n.f_title { text-align:right; }\\\r\n.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\r\n</style>");
}
protected virtual string[] ReturnDirectoriesArray()
{
if (this._currentDirectories != null)
{
return this._currentDirectories;
}
if (this.CurrentImagesFolder != "")
{
try
{
return Directory.GetDirectories(this.context.Server.MapPath(this.CurrentImagesFolder), "*");
}
catch
{
return null;
}
}
return null;
}
[Description("Gets or sets the imge file extensions allowed."), Category("Behavior")]
public string[] AcceptedFileTypes
{
get
{
object obj1 = this.ViewState["AcceptedFileTypes"];
return ((obj1 == null) ? new string[] { "jpg", "jpeg", "jpe", "gif", "bmp", "png" } : ((string[]) obj1));
}
set
{
this.ViewState["AcceptedFileTypes"] = value;
}
}
[Category("Behavior"), Description("Gets or sets if directory creation is allowed.")]
public bool AllowDirectoryCreate
{
get
{
object obj1 = this.ViewState["AllowDirectoryCreate"];
return ((obj1 == null) || ((bool) obj1));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -