public static OpenResult Open(string path)
        {
            TypeWrapper tw;

            switch (Path.GetExtension(path).ToLower())
            {
            case ".webp":
                tw = new WebpWrapper();
                break;

            case ".svg":
                tw = new SvgWrapper();
                break;

            case ".psd":
                tw = new PsdWrapper();
                break;

            case ".ico":
                tw = new IcoWrapper();
                break;

            case ".cr2":
                tw = new Cr2Wrapper();
                break;

            case ".dds":
            case ".tga":
                tw = new DdsTgaWrapper();
                break;

            default:
                tw = new BitmapWrapper();
                break;
            }
            OpenResult res = tw.Open(path);

            if (string.IsNullOrEmpty(res.ErrorMessage))
            {
                return new OpenResult
                       {
                           ErrorMessage = null,
                           TypeName     = tw.TypeName,
                           Bmp          = res.Bmp,
                           ShowTypeOps  = tw.ShowTypeOps
                       }
            }
            ;
            else
            {
                return new OpenResult
                       {
                           ErrorMessage = res.ErrorMessage,
                           TypeName     = tw.TypeName,
                           Bmp          = null,
                           ShowTypeOps  = false
                       }
            };
        }
Ejemplo n.º 2
0
        private void okButton_Click(object sender, EventArgs e)
        {
            MainForm mf = Owner as MainForm;

            FileTypeMan.OpenResult res = SvgWrapper.CustomSizeOpen(path, (int)widthNumeric.Value, (int)heightNumeric.Value);
            if (string.IsNullOrEmpty(res.ErrorMessage))
            {
                mf.openImage(res.Bmp, Path.GetDirectoryName(path), Path.GetFileName(path));
            }
            else
            {
                mf.showSuggestion(res.ErrorMessage, MainForm.SuggestionIcon.Warning);
            }
            Close();
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            MainForm mf  = Owner as MainForm;
            Bitmap   bmp = SvgWrapper.ParseSvg(path, (int)widthNumeric.Value, (int)heightNumeric.Value);

            switch (SvgWrapper.CurrentError)
            {
            case SvgWrapper.Error.NoError:
                mf.openImage(bmp, Path.GetDirectoryName(path), Path.GetFileName(path));
                break;

            case SvgWrapper.Error.UnableToOpen:
                mf.showSuggestion(SvgWrapper.TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path), MainForm.SuggestionIcon.Warning);
                break;
            }
            Close();
        }