Esempio n. 1
0
        private string TargetFileExtension(TargetImageFormat fomrat)
        {
            switch (fomrat)
            {
            case TargetImageFormat.JPG:
                return("jpeg");

            case TargetImageFormat.PNG:
                return("png");

            default:
                throw new FormatException();
            }
        }
Esempio n. 2
0
        public void LoadProduct(IColumnField field)
        {
            if (!(field is ImageField))
            {
                throw new ArgumentException();
            }
            ImageField imf = (ImageField)field;

            mainPath     = imf.MainDirectory;
            thumbPath    = imf.ThumbDirectory;
            fullWidth    = imf.FullWidth;
            thumbWidth   = imf.ThumbWidth;
            targetFormat = imf.TargetFormat;
            useThubs     = thumbPath != null;
            FillFields();
        }
Esempio n. 3
0
        public void ValidateForm()
        {
            errorMessage = null;
            int fw = 0;
            int tw = 0;
            string mp = null;
            string tp = null;
            TargetImageFormat tf;

            try
            {
                if(String.IsNullOrEmpty(mainPathBox.Text)){
                    throw new Exception("Please, fill in the main direcotry for the images.");
                }
                DirectoryInfo mainDirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + mainPathBox.Text);
                if (!mainDirInfo.Exists) {
                    throw new Exception("The directory specified as the storage of full-size images (" + mainDirInfo.FullName  + ") does not exist");
                }
                mp = mainPathBox.Text;
                if (!mp.EndsWith("/")) mp += "/";
                fw = 0;
                if(!string.IsNullOrEmpty(fullWidthBox.Text)) fw = Int32.Parse(fullWidthBox.Text);
                if (useThumbsCheck.Checked) {
                    DirectoryInfo thumbDirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + thumbPathBox.Text);
                    if (!thumbDirInfo.Exists)
                    {
                        throw new Exception("The directory specified as the storage of thumbnail images (" + thumbDirInfo.FullName + ") does not exist");
                    }
                    tp = thumbPathBox.Text;
                    if (!mp.EndsWith("/")) mp += "/";
                    tw = 0;
                    if(thumbWidthBox.Text != "") tw = Int32.Parse(thumbWidthBox.Text);
                }
                if (targetFormatRadios.SelectedIndex < 0)
                    throw new Exception("Please, specify the format into which to convert the images");
                tf = (TargetImageFormat)Enum.Parse(typeof(TargetImageFormat), targetFormatRadios.SelectedValue);

            }
            catch (Exception e) {
                errorMessage = e.Message;
                return;
            }

            // will get here only if the validation succeeds
            mainPath = mp;
            thumbPath = tp;
            fullWidth = fw;
            thumbWidth = tw;
            targetFormat = tf;
        }
Esempio n. 4
0
 public void LoadProduct(IColumnField field)
 {
     if (!(field is ImageField))
         throw new ArgumentException();
     ImageField imf = (ImageField)field;
     mainPath = imf.MainDirectory;
     thumbPath = imf.ThumbDirectory;
     fullWidth = imf.FullWidth;
     thumbWidth = imf.ThumbWidth;
     targetFormat = imf.TargetFormat;
     useThubs = thumbPath != null;
     FillFields();
 }
Esempio n. 5
0
 private string TargetFileExtension(TargetImageFormat fomrat)
 {
     switch (fomrat)
     {
         case TargetImageFormat.JPG:
             return "jpeg";
         case TargetImageFormat.PNG:
             return "png";
         default:
             throw new FormatException();
     }
 }
Esempio n. 6
0
        public void ValidateForm()
        {
            errorMessage = null;
            int               fw = 0;
            int               tw = 0;
            string            mp = null;
            string            tp = null;
            TargetImageFormat tf;

            try
            {
                if (String.IsNullOrEmpty(mainPathBox.Text))
                {
                    throw new Exception("Please, fill in the main direcotry for the images.");
                }
                DirectoryInfo mainDirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + mainPathBox.Text);
                if (!mainDirInfo.Exists)
                {
                    throw new Exception("The directory specified as the storage of full-size images (" + mainDirInfo.FullName + ") does not exist");
                }
                mp = mainPathBox.Text;
                if (!mp.EndsWith("/"))
                {
                    mp += "/";
                }
                fw = 0;
                if (!string.IsNullOrEmpty(fullWidthBox.Text))
                {
                    fw = Int32.Parse(fullWidthBox.Text);
                }
                if (useThumbsCheck.Checked)
                {
                    DirectoryInfo thumbDirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + thumbPathBox.Text);
                    if (!thumbDirInfo.Exists)
                    {
                        throw new Exception("The directory specified as the storage of thumbnail images (" + thumbDirInfo.FullName + ") does not exist");
                    }
                    tp = thumbPathBox.Text;
                    if (!mp.EndsWith("/"))
                    {
                        mp += "/";
                    }
                    tw = 0;
                    if (thumbWidthBox.Text != "")
                    {
                        tw = Int32.Parse(thumbWidthBox.Text);
                    }
                }
                if (targetFormatRadios.SelectedIndex < 0)
                {
                    throw new Exception("Please, specify the format into which to convert the images");
                }
                tf = (TargetImageFormat)Enum.Parse(typeof(TargetImageFormat), targetFormatRadios.SelectedValue);
            }
            catch (Exception e) {
                errorMessage = e.Message;
                return;
            }

            // will get here only if the validation succeeds
            mainPath     = mp;
            thumbPath    = tp;
            fullWidth    = fw;
            thumbWidth   = tw;
            targetFormat = tf;
        }