Esempio n. 1
0
        private System.Drawing.Image LoadImageOrIcon(string fileName)
        {
            System.Drawing.Image image;

            using (System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
            {
                if (System.IO.Path.GetExtension(fileName) == ".ico")
                {
                    Skybound.Drawing.Design.IconFile iconFile = new Skybound.Drawing.Design.IconFile(fileStream);
                    if (iconFile.GetFormats().Length == 1)
                    {
                        return(iconFile.ToBitmap(iconFile.GetFormats()[0]));
                    }
                    Skybound.Drawing.Design.IconFormatDialog iconFormatDialog = new Skybound.Drawing.Design.IconFormatDialog();
                    iconFormatDialog.IconFile = iconFile;
                    iconFormatDialog.ShowDialog(UIService.GetDialogOwnerWindow());
                    if (iconFormatDialog.DialogResult != System.Windows.Forms.DialogResult.OK)
                    {
                        goto label_1;
                    }
                    return(iconFile.ToBitmap(iconFormatDialog.SelectedFormat));
                }
                return(LoadFromStream(fileStream));

                label_1 :;
            }
            return(null);
        }
        private System.Drawing.Image LoadImageOrIcon(string fileName)
        {
            System.Drawing.Image image;

            using (System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
            {
                if (System.IO.Path.GetExtension(fileName) == ".ico")
                {
                    Skybound.Drawing.Design.IconFile iconFile = new Skybound.Drawing.Design.IconFile(fileStream);
                    if (iconFile.GetFormats().Length == 1)
                    {
                        return iconFile.ToBitmap(iconFile.GetFormats()[0]);
                    }
                    Skybound.Drawing.Design.IconFormatDialog iconFormatDialog = new Skybound.Drawing.Design.IconFormatDialog();
                    iconFormatDialog.IconFile = iconFile;
                    iconFormatDialog.ShowDialog(UIService.GetDialogOwnerWindow());
                    if (iconFormatDialog.DialogResult != System.Windows.Forms.DialogResult.OK)
                        goto label_1;
                    return iconFile.ToBitmap(iconFormatDialog.SelectedFormat);
                }
                return LoadFromStream(fileStream);
            label_1:;
            }
            return null;
        }