protected void RecreateThumbnails() { //Get all items from db var tc = new ItemController(); IEnumerable<Item> dblist = tc.GetItems(ModuleId); foreach (Item picture in dblist) { string thumbName = "thm_" + picture.ItemFileName; //replace old thumbnail with new thumbnail // Get image System.Drawing.Image image = System.Drawing.Image.FromFile(PicturePath + "\\"+ picture.ItemFileName); //Delete thumbnail float x = image.Width; float y = image.Height; float scale = x / y; int newx = 120; int newy = Convert.ToInt32(120 / scale); if (newy > 120) { newy = 120; newx = Convert.ToInt32(120 * scale); } //create thumbnail System.Drawing.Image thumb = image.GetThumbnailImage(newx, newy, () => false, IntPtr.Zero); thumb.Save(PicturePath + "\\thm_" + picture.ItemFileName); } }
protected void RescanDirectory() { //Increase timeout Server.ScriptTimeout = 600; //get list of files IEnumerable<FileInfo> filelist = FileUtility.GetSafeFileList(PicturePath, GetExcludedFiles(), GetSortOrder()); int filelistcount = filelist.Count(); //If there are any process them if (filelistcount > 0) { //get list from db var tc = new ItemController(); IEnumerable<Item> dblist = tc.GetItems(ModuleId); foreach (FileInfo file in filelist) { bool isinDB = false; //see if this file is in dm foreach (Item picture in dblist) { if (file.FileName.Contains("thm_") || file.FileName == picture.ItemFileName) { isinDB = true; break; } } if (!isinDB) //picture is not in db so add it and create thumbnail { Item addPic = new Item(); //check for bad filename string goodFileName = RemoveCharactersFromString(file.FileName," '&#<>"); if(goodFileName != file.FileName) { //rename the file and use goodfilename instead of file.filename string myPath = Server.MapPath("portals/" + PortalId + "/Gallery/Nano/" + ModuleId + "/"); string myOldPath = myPath + file.FileName; string myNewPath = myPath + goodFileName; System.IO.FileInfo f = new System.IO.FileInfo(myOldPath); f.CopyTo(myNewPath); f.Delete(); } addPic.ItemFileName = goodFileName; addPic.ItemTitle = goodFileName; addPic.ItemKind = ""; addPic.AlbumID = 0; addPic.ItemDescription = "New Picture"; addPic.CreatedOnDate = DateTime.Now; addPic.LastModifiedOnDate = DateTime.Now; addPic.LastModifiedByUserId = UserId; addPic.ModuleId = ModuleId; //add to db var tc1 = new ItemController(); tc1.CreateItem(addPic); // Get image System.Drawing.Image image = System.Drawing.Image.FromFile(PicturePath + "\\" + goodFileName); float x = image.Width; float y = image.Height; float scale = x / y; int newx = 120; int newy = Convert.ToInt32(120 / scale); if (newy > 120) { newy = 120; newx = Convert.ToInt32(120 * scale); } //create thumbnail System.Drawing.Image thumb = image.GetThumbnailImage(newx, newy, () => false, IntPtr.Zero); thumb.Save(PicturePath + "\\thm_" + goodFileName); } } } //Reload page Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); }
private void WriteOutnanoGalleryConstructors() { //Create the javascript var sb = new StringBuilder(); sb.Append("<script>"); sb.Append(Environment.NewLine); sb.Append("$(document).ready(function (){ "); sb.Append(Environment.NewLine); string contentNameID = "contentGalleryMLN" + ModuleId.ToString(); sb.Append("var " + contentNameID + "=["); sb.Append(Environment.NewLine); // get items for this module from db var tc = new ItemController(); IEnumerable<Item> dblist = tc.GetItems(ModuleId); // Get all the items for this module from DB int _items = dblist.Count(); //get number of pictures if (_items > 0) //If there are any process them { for (int ii = 0; ii < _items; ii++) { Item _picture = new Item(); //get a single item _picture = dblist.ElementAt(ii); sb.Append("{src:'" + _picture.ItemFileName + "',"); sb.Append("srct:'thm_" + _picture.ItemFileName + "',"); sb.Append("title: '" + _picture.ItemTitle + "',"); sb.Append("description: '" + _picture.ItemDescription + "',"); sb.Append("ID: " + _picture.ItemId.ToString() + ","); if (_picture.AlbumID != 0) sb.Append("albumID: " + _picture.AlbumID.ToString() + ","); if (_picture.ItemKind == "album") sb.Append("kind: '" + _picture.ItemKind + "'"); sb.Append("},"); //close item definition //add a comma after the } to add more items sb.Append(Environment.NewLine); } } //close array list sb.Append("];"); sb.Append(Environment.NewLine); //Add gallery settings string divNameID = "\"#nanoGalleryMLN" + ModuleId.ToString() + "\""; sb.Append("jQuery(" + divNameID + ").nanoGallery({"); sb.Append(Environment.NewLine); sb.Append("items: " + contentNameID + ","); if (Settings.Contains("ThumbnailWidth")) sb.Append("thumbnailWidth: " + Settings["ThumbnailWidth"].ToString() + ","); if (Settings.Contains("ThumbnailHeight")) sb.Append("thumbnailHeight: " + Settings["ThumbnailHeight"].ToString() + ","); if (Settings.Contains("MaxItemsPerLine")) sb.Append("maxItemsPerLine: " + Settings["MaxItemsPerLine"].ToString() + ","); if (Settings.Contains("PaginationMaxLinesPerPage")) sb.Append("paginationMaxLinesPerPage: " + Settings["PaginationMaxLinesPerPage"].ToString() + ","); if (Settings.Contains("Theme")) sb.Append("theme: " + Settings["Theme"].ToString() + ","); if (Settings.Contains("BreadcrumbAutoHideTopLevel")) sb.Append("breadcrumbAutoHideTopLevel: " + Settings["BreadcrumbAutoHideTopLevel"].ToString() + ","); if (Settings.Contains("ThumbnailHoverEffect1")) { if (Settings["ThumbnailHoverEffect1"].ToString() != "none") { sb.Append("thumbnailHoverEffect: '"); if (Settings["ThumbnailHoverEffect1"].ToString() != "none") { sb.Append(Settings["ThumbnailHoverEffect1"].ToString()); } if (Settings["ThumbnailHoverEffect2"].ToString() != "none" && Settings["ThumbnailHoverEffect1"].ToString() != "none") { sb.Append("," + Settings["ThumbnailHoverEffect2"].ToString()); } if (Settings["ThumbnailHoverEffect3"].ToString() != "none" && Settings["ThumbnailHoverEffect2"].ToString() != "none" && Settings["ThumbnailHoverEffect1"].ToString() != "none") { sb.Append("," + Settings["ThumbnailHoverEffect3"].ToString()); } sb.Append("',"); } } //sb.Append("paginationDots: true,"); if (Settings.Contains("PaginationDots")) sb.Append("paginationDots: " + Settings["PaginationDots"].ToString() + ","); //colorScheme if (Settings.Contains("ColorScheme")) sb.Append("colorScheme: " + Settings["ColorScheme"].ToString() + ","); //locationHash if (Settings.Contains("LocationHash")) sb.Append("locationHash: " + Settings["LocationHash"].ToString() + ","); //thumbnailGutterWidth thumbnailGutterHeight if (Settings.Contains("ThumbnailGutterWidth")) sb.Append("thumbnailGutterWidth: " + Settings["ThumbnailGutterWidth"].ToString() + ","); if (Settings.Contains("ThumbnailGutterHeight")) sb.Append("thumbnailGutterHeight: " + Settings["ThumbnailGutterHeight"].ToString() + ","); //thumbnailLabel.itemsCount //this is a more advanced option todo later //if (Settings.Contains("CountDisplay")) sb.Append("thumbnailLabel.itemsCount: " + Settings["CountDisplay"].ToString() + ","); sb.Append("viewerDisplayLogo: false,"); //sb.AppendFormat("'changeSpeed': {0}, ", objSetting.ChangeSpeed); ////example sb.AppendFormat("itemsBaseURL: '/{0}',", Settings["BaseFolderPath"].ToString()); //add comma to add more items //Last line does not have a comma!!! sb.Append("useTags: false"); sb.Append("})"); sb.Append(Environment.NewLine); sb.Append("});"); sb.Append(Environment.NewLine); sb.Append("</script>"); phScript.Controls.Add(new LiteralControl(sb.ToString())); }
private void LoadGalleryList() { //Load all pictures into a listview for editing var tc = new ItemController(); var t = tc.GetItems(ModuleId); lvGalleryList.DataSource = t; //set lines per page if (Settings.Contains("EditLinesPerPage")) dbPictureList.PageSize = Convert.ToInt32(Settings["EditLinesPerPage"].ToString()); lvGalleryList.DataBind(); }
private void LoadSingleView() { //set radio buttons System.Web.UI.WebControls.ListItem rb1 = new System.Web.UI.WebControls.ListItem("Picture", ""); System.Web.UI.WebControls.ListItem rb2 = new System.Web.UI.WebControls.ListItem("Album", "album"); rblItemKind.Items.Add(rb1); rblItemKind.Items.Add(rb2); //Fil ddl with available albums ddlAlbumID.Items.Add(new System.Web.UI.WebControls.ListItem("None", "0")); var tc = new ItemController(); var Items = tc.GetItems(ModuleId); foreach (Item pc in Items) { if (pc.ItemKind == "album") { ddlAlbumID.Items.Add(new System.Web.UI.WebControls.ListItem(pc.ItemTitle, pc.ItemId.ToString())); } } }
protected void LoadAlbumList() { //Fil ddl with available albums ddlAlbumList.Items.Add(new System.Web.UI.WebControls.ListItem("None", "0")); var tc = new ItemController(); var Items = tc.GetItems(ModuleId); foreach (Item pc in Items) { if (pc.ItemKind == "album") { ddlAlbumList.Items.Add(new System.Web.UI.WebControls.ListItem(pc.ItemTitle, pc.ItemId.ToString())); } } }