📄 pictureoptions.aspx.cs
字号:
imgWatermark.Width = 100;
}
imgWatermark.BorderStyle = BorderStyle.Solid;
imgWatermark.BorderColor = Color.Black;
imgWatermark.BorderWidth = Unit.Pixel(1);
}
private void SaveButton_Click(object sender, EventArgs e)
{
if(Page.IsValid)
{
CurrentGallery.EnableExif = ynEnableExif.SelectedValue;
ArrayList properties = new ArrayList();
foreach(ListItem item in ExifTypes.Items)
if(item.Selected)
properties.Add(item.Value);
CurrentGallery.DisplayExifProperties = (string[])properties.ToArray(typeof(string));
GalleryImageSettings settings;
settings = ThumbnailSettings.GetFormFields();
CurrentGallery.ThumbnailX = settings.Width;
CurrentGallery.ThumbnailY = settings.Height;
CurrentGallery.ThumbnailQuality = settings.Quality;
CurrentGallery.ThumbnailBrightness = settings.Brightness;
settings = SecondaryThumbnailSettings.GetFormFields();
CurrentGallery.SecondaryThumbnailX = settings.Width;
CurrentGallery.SecondaryThumbnailY = settings.Height;
CurrentGallery.SecondaryThumbnailQuality = settings.Quality;
settings = PictureDetailsSettings.GetFormFields();
CurrentGallery.PictureDetailsX = settings.Width;
CurrentGallery.PictureDetailsY = settings.Height;
CurrentGallery.PictureDetailsQuality = settings.Quality;
settings = SlideshowSettings.GetFormFields();
CurrentGallery.SlideshowX = settings.Width;
CurrentGallery.SlideshowY = settings.Height;
CurrentGallery.SlideshowQuality = settings.Quality;
settings = MaxSettings.GetFormFields();
CurrentGallery.MaxX = settings.Width;
CurrentGallery.MaxY = settings.Height;
CurrentGallery.Quality = settings.Quality;
string newWatermarkText = WatermarkText.Text.Trim();
WatermarkPosition newWatermarkPosition = (WatermarkPosition)Enum.Parse(typeof(WatermarkPosition), ImageWatermarkPosition.SelectedValue);
WatermarkType newWatermarkType = (WatermarkType)Enum.Parse(typeof(WatermarkType), ImageWatermarkType.SelectedValue);
if(CurrentGallery.WatermarkText != newWatermarkText ||
CurrentGallery.WatermarkPosition != newWatermarkPosition ||
CurrentGallery.WatermarkType != newWatermarkType)
{
GalleryConfiguration.Instance().CacheSettings.LegacyClearStorage(CurrentGallery.SectionID) ;
GalleryConfiguration.Instance().CacheSettings.DeleteSectionFromDisk(CurrentGallery.SectionID) ;
CalculateCacheSize();
}
CurrentGallery.WatermarkText = newWatermarkText;
CurrentGallery.WatermarkPosition = newWatermarkPosition;
CurrentGallery.WatermarkType = newWatermarkType;
CurrentGallery.WatermarkMinWidth = int.Parse(WatermarkMinImageX.Text) ;
CurrentGallery.WatermarkMinHeight = int.Parse(WatermarkMinImageY.Text) ;
CommunityServer.Galleries.Galleries.Update(CurrentGallery);
}
}
private void CalculateCacheSize()
{
// Calculate the current cache size
CacheSize.Text = GalleryConfiguration.Instance().CacheSettings.FolderSize() + "kb";
}
private void CalculateImportCount()
{
// Count the number of images in the Stub Gallery folder
ImportCount.Text = GetImportFiles().Count.ToString();
}
private ArrayList GetImportFiles()
{
ArrayList importFiles = new ArrayList();
// Count the number of images in the Stub Gallery folder
string gallerydir = CSContext.Current.MapPath( Globals.GetSiteUrls().Locations.FindLocationByName("galleries").PhysicalPath + CurrentGallery.ApplicationKey );
// Add the end directory separator if missing
if(!gallerydir.EndsWith( Path.DirectorySeparatorChar.ToString() ))
gallerydir += Path.DirectorySeparatorChar;
DirectoryInfo dir = new DirectoryInfo(gallerydir);
if (dir.Exists)
{
FileInfo[] files = (new DirectoryInfo(gallerydir)).GetFiles("*.*");
foreach (FileInfo file in files)
{
if (GalleryConfiguration.Instance().AttachmentSettings.Extensions.ToLower().IndexOf(file.Extension.TrimStart('.').ToLower()) > -1)
importFiles.Add(file);
}
}
else
{
ImportStatus.Visible = true;
ImportStatus.Success = false;
ImportStatus.Text =
String.Format(
"The gallery directory ({0}) could not be found, Importing has been disabled. Create this directory on your web server and try again.",
gallerydir);
}
ImportButton.Visible = importFiles.Count > 0;
return importFiles;
}
private void AddClickEvents()
{
ThumbnailRebuild.Click += new EventHandler(ThumbnailRebuild_Click);
SecondaryThumbnailRebuild.Click += new EventHandler(SecondaryThumbnailRebuild_Click);
CleanCache.Click += new EventHandler(CleanCache_Click);
ClearCache.Click += new EventHandler(ClearCache_Click);
ImportButton.Click += new EventHandler(ImportButton_Click) ;
}
private void ThumbnailRebuild_Click(object sender, EventArgs e)
{
Hashtable pictures = GalleryDataProvider.Instance().GetAllPictures(CurrentGallery.SectionID);
Queue queue = CSCache.Get("RebuildItems") as Queue;
// The queue doesn't exist, so create it
if(queue == null)
{
queue = Queue.Synchronized(new Queue());
CSCache.Max("RebuildItems", queue);
}
// Loop the pictures and create the queue items
foreach(int key in pictures.Keys)
{
GalleryPost galleryPost = pictures[key] as GalleryPost;
string filename = GalleryConfiguration.Instance().CacheSettings.GetLocalThumbnailFileName(galleryPost) ;
// Remove the file in advance, so if anyone browses it will regenerate it then and skip it in the job
File.Delete(filename);
// Create the item and queue it
RebuildItem item = new RebuildItem(CurrentGallery, galleryPost, filename, CurrentGallery.GetThumbnailSettings());
queue.Enqueue(item);
}
// Show a message that they have been queued.
CacheMessage.Text = "<span style='color: green'>" + string.Format(Components.ResourceManager.GetString("CP_Photos_PictureOptions_RebuildQueue"), pictures.Count) + " </span>";
CacheMessage.Visible = true;
}
private void SecondaryThumbnailRebuild_Click(object sender, EventArgs e)
{
Hashtable pictures = GalleryDataProvider.Instance().GetAllPictures(CurrentGallery.SectionID);
Queue queue = CSCache.Get("RebuildItems") as Queue;
// The queue doesn't exist, so create it
if(queue == null)
{
queue = Queue.Synchronized(new Queue());
CSCache.Max("RebuildItems", queue);
}
// Loop the pictures and create the queue items
foreach(int key in pictures.Keys)
{
GalleryPost galleryPost = pictures[key] as GalleryPost;
string filename = GalleryConfiguration.Instance().CacheSettings.GetLocalSecondaryThumbnailFileName(galleryPost) ;
// Remove the file in advance, so if anyone browses it will regenerate it then and skip it in the job
File.Delete(filename);
// Create the item and queue it
RebuildItem item = new RebuildItem(CurrentGallery, galleryPost, filename, CurrentGallery.GetSecondaryThumbnailSettings());
queue.Enqueue(item);
}
// Show a message that they have been queued.
CacheMessage.Text = "<span style='color: green'>" + string.Format(ResourceManager.GetString("CP_Photos_PictureOptions_RebuildQueue"), pictures.Count) + " </span>";
CacheMessage.Visible = true;
}
private void ImportButton_Click(object sender, EventArgs e)
{
ArrayList pictures = GetImportFiles();
Queue queue = CSCache.Get("GalleryImportItems") as Queue;
// The queue doesn't exist, so create it
if(queue == null)
{
queue = Queue.Synchronized(new Queue());
CSCache.Max("GalleryImportItems", queue);
}
//get the category name
String CategoryName = null;
if(ImportCategoryID.SelectedCategoryID > 0)
{
try{CategoryName = PostCategories.GetCategory(ImportCategoryID.SelectedCategoryID, CurrentGallery.SectionID).Name; }
catch{}
}
// Loop the pictures and create the queue items
foreach(FileInfo file in pictures)
{
// Create the item and queue it
ImportItem item = new ImportItem(CurrentGallery, CategoryName, file.FullName, CSContext.Current.User);
queue.Enqueue(item);
}
// Show a message that they have been queued.
CacheMessage.Text = "<span style='color: green'>" + string.Format(Components.ResourceManager.GetString("CP_Photos_PictureOptions_ImportQueue"), pictures.Count) + " </span>";
CacheMessage.Visible = true;
}
private void CleanCache_Click(object sender, EventArgs e)
{
// Delete all of the files except those which might be thumbnails or large thumbnails
GalleryConfiguration.Instance().CacheSettings.LegacyCleanStorage(CurrentGallery.SectionID) ;
CalculateCacheSize();
}
private void ClearCache_Click(object sender, EventArgs e)
{
GalleryConfiguration.Instance().CacheSettings.LegacyClearStorage(CurrentGallery.SectionID) ;
GalleryConfiguration.Instance().CacheSettings.DeleteSectionFromDisk(CurrentGallery.SectionID) ;
CalculateCacheSize();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -