예제 #1
0
        private void LoadSizes()
        {
            if (Selection.SelectedItem == null)
            {
                throw new ArgumentNullException("Selection.SelectedItem");
            }

            var imageConfig = Engine.Config.Sections.Management.Images;

            if (imageConfig == null)
            {
                throw new ArgumentNullException("imageConfig");
            }
            else if (imageConfig.Sizes == null)
            {
                throw new ArgumentNullException("imageConfig.Sizes");
            }

            string baseImagePath, imageSize;

            ImagesUtility.SplitImageAndSize(Selection.SelectedItem.Url, imageConfig.Sizes.GetSizeNames(), out baseImagePath, out imageSize);

            if (string.IsNullOrEmpty(baseImagePath))
            {
                throw new ArgumentException("baseImagePath");
            }

            foreach (var size in imageConfig.Sizes.AllElements.Where(s => s.Announced))
            {
                AddSize(baseImagePath, size);
            }
        }
예제 #2
0
        private void LoadSizes()
        {
            var    imageConfig = Engine.Resolve <EditSection>().Images;
            string baseImagePath, imageSize;

            ImagesUtility.SplitImageAndSize(Selection.SelectedItem.Url, imageConfig.Sizes.GetSizeNames(), out baseImagePath, out imageSize);
            foreach (var size in imageConfig.Sizes.AllElements.Where(s => s.Announced))
            {
                var hl = new HyperLink();
                hl.ID = size.Name + "Size";
                bool exists;
                var  path = ImagesUtility.GetExistingImagePath(Engine.Resolve <IFileSystem>(), baseImagePath, size.Name, out exists);
                if (exists)
                {
                    var file = (SelectedFile.Parent as File) ?? SelectedFile;

                    hl.NavigateUrl = "File.aspx?selected=" + file.GetChild(VirtualPathUtility.GetFileName(path)).Path;
                    hl.Text        = Utility.GetResourceString("ImageSizes", size.Name + ".Text") ?? (string.IsNullOrEmpty(size.Description) ? size.Name : size.Description);
                    hl.Text       += GetSizeText(size.Width, size.Height);
                    hl.CssClass    = "command";
                    if (path == Selection.SelectedItem.Url)
                    {
                        omSizes.Controls.AddAt(0, hl);
                    }
                    else
                    {
                        omSizes.Controls.Add(hl);
                    }
                }
            }
            omSizes.Visible = omSizes.Controls.Count > 1;
        }
예제 #3
0
        public ImageSizeElement GetImageSize(string imageUrl)
        {
            string baseImagePath;
            string imageSize;

            ImagesUtility.SplitImageAndSize(imageUrl, Sizes.GetSizeNames(), out baseImagePath, out imageSize);
            return(Sizes.FirstOrDefault(s => s.Name == imageSize));
        }
예제 #4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            sizes = Engine.Resolve <EditSection>().Images.Sizes;
            fs    = Engine.Resolve <IFileSystem>();

            ImagesUtility.SplitImageAndSize(Selection.SelectedItem.Url, sizes.GetSizeNames(), out baseImagePath, out imageSize);
            originalImagePath = fs.GetExistingImagePath(baseImagePath, "original");

            size = sizes.FirstOrDefault(s => s.Name == imageSize);
        }