コード例 #1
0
        private void deletePlugin(int numberInList)
        {
            DialogResult window = DialogMan.ShowConfirm(
                this,
                LangMan.Get("delete-plugin-warning"),
                windowTitle: LangMan.Get("warning"),
                yesBtnText: LangMan.Get("delete-plugin"),
                yesBtnImage: deleteBtn.Image,
                darkMode: DarkMode,
                topMost: TopMost
                );

            if (window == DialogResult.Yes)
            {
                listView1.Items[numberInList].Remove();
                imageList1.Images[numberInList].Dispose();

                string pluginFolder = Path.Combine(PluginMan.pluginsFolder, codenames[numberInList]);
                if (File.Exists(pluginFolder))
                {
                    FileMan.MoveFileOrFolderToRecycleBin(pluginFolder);
                }
                else
                {
                    DialogMan.ShowInfo(
                        this,
                        LangMan.Get("plugin-not-found"),
                        LangMan.Get("error"),
                        DarkMode,
                        TopMost
                        );
                }
                RefreshPluginsList();
            }
        }
コード例 #2
0
        private void setZoomFactor(int newZoomFactor)
        {
            if (newZoomFactor < 1)
            {
                newZoomFactor = 1;
            }
            if (newZoomFactor > 250)
            {
                newZoomFactor = 250;
            }

            if (newZoomFactor != zoomFactor)
            {
                zoomFactor = newZoomFactor;

                zoomLabel.Text = LangMan.Get("zoom") + ": " + zoomFactor.ToString() + "%";

                setAutoZoom(false);

                int newWidth  = Convert.ToInt32(width * zoomFactor / 100);
                int newHeight = Convert.ToInt32(height * zoomFactor / 100);

                pictureBox.Size = new Size(newWidth, newHeight);

                updatePictureBoxLocation();
            }
        }
コード例 #3
0
        public SelectionForm(Panel srcPanel, bool darkMode)
        {
            picturePanel = srcPanel;

            MinimumSize = new Size(gripSize * 4, gripSize * 4);

            whitePen.DashStyle  = DashStyle.Dot;
            blackPen.DashStyle  = DashStyle.Dot;
            blackPen.DashOffset = 1;

            InitializeComponent();

            gripBrush = new SolidBrush(darkMode ? ThemeMan.DarkPaleColor : ThemeMan.LightPaleColor);
            selectionMenu.DarkMode = darkMode;

            cutBtn.Text                = LangMan.Get("cut");
            cropBtn.Text               = LangMan.Get("crop");
            selectionCopyBtn.Text      = LangMan.Get("copy");
            selectionSelectAllBtn.Text = LangMan.Get("select-all");
            editSelectionBtn.Text      = LangMan.Get("edit-selection") + " ...";

            if (darkMode)
            {
                cutBtn.Image                = Properties.Resources.white_cut;
                cropBtn.Image               = Properties.Resources.white_crop;
                selectionCopyBtn.Image      = Properties.Resources.white_copy;
                selectionSelectAllBtn.Image = Properties.Resources.white_selectall;
                editSelectionBtn.Image      = Properties.Resources.white_editsel;
            }
        }
コード例 #4
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            try
            {
                CPSD psd     = new CPSD();
                int  nResult = psd.Load(path);
                switch (nResult)
                {
                case -1:
                    return(new FileTypeMan.OpenResult
                    {
                        ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                    });

                default:
                    return(new FileTypeMan.OpenResult
                    {
                        Bmp = Image.FromHbitmap(psd.GetHBitmap())
                    });
                }
            }
            catch
            {
                return(new FileTypeMan.OpenResult
                {
                    ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                });
            }
        }
コード例 #5
0
        private void deletePlugin(int numberInList)
        {
            DialogResult window = DialogMan.ShowConfirm(
                this,
                LangMan.Get("delete-plugin-warning"),
                windowTitle: LangMan.Get("warning"),
                yesBtnText: LangMan.Get("delete-plugin"),
                yesBtnImage: deleteBtn.Image,
                darkMode: DarkMode
                );

            if (window == DialogResult.Yes)
            {
                listView1.Items[numberInList].Remove();
                imageList1.Images[numberInList].Dispose();

                string pluginFolder = Path.Combine(PluginMan.pluginsFolder, codenames[numberInList]);
                if (FileSystem.DirectoryExists(pluginFolder))
                {
                    FileSystem.DeleteDirectory(pluginFolder, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin, UICancelOption.DoNothing);
                }
                else
                {
                    DialogMan.ShowInfo(
                        this,
                        LangMan.Get("plugin-not-found"),
                        LangMan.Get("error"),
                        DarkMode
                        );
                }
                RefreshPluginsList();
            }
        }
コード例 #6
0
 private void openWithCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (settingsStarted)
     {
         try
         {
             if (openWithCheckBox.Checked)
             {
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer", "", "Open with Quick Picture Viewer");
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer", "Icon", string.Format("\"{0}picture.ico\"", AppDomain.CurrentDomain.BaseDirectory));
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer\\command", "", string.Format("\"{0}quick-picture-viewer.exe\" \"%V\"", AppDomain.CurrentDomain.BaseDirectory));
             }
             else
             {
                 RegistryKey RegKey = Registry.ClassesRoot.OpenSubKey("*\\shell\\QuickPictureViewer", true);
                 RegKey.DeleteSubKeyTree("");
             }
         }
         catch
         {
             settingsStarted = false;
             DialogMan.ShowInfo(
                 this,
                 LangMan.Get("context-menu-notice"),
                 LangMan.Get("error"),
                 DarkMode,
                 TopMost
                 );
             openWithCheckBox.Checked = !openWithCheckBox.Checked;
             settingsStarted          = true;
         }
     }
 }
コード例 #7
0
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         string tempJpg = ConvertImage(path);
         if (tempJpg == null)
         {
             return(new FileTypeMan.OpenResult
             {
                 ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
             });
         }
         else
         {
             return(new FileTypeMan.OpenResult
             {
                 Bmp = new Bitmap(tempJpg)
             });
         }
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
コード例 #8
0
 private void InitLanguage()
 {
     Text                = LangMan.Get("about");
     updatesBtn.Text     = " " + LangMan.Get("check-for-app-updates");
     descTextBox.Text    = LangMan.Get("app-description");
     makeDefaultBtn.Text = LangMan.Get("set-as-default-image-viewer");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #9
0
 private void InitLanguage()
 {
     Text             = LangMan.Get("edit-selection");
     widthLabel.Text  = LangMan.Get("width") + ":";
     heightLabel.Text = LangMan.Get("height") + ":";
     okButton.Text    = NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDOK);
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #10
0
        private void NavPanel_Load(object sender, System.EventArgs e)
        {
            owner = Parent as MainForm;

            infoTooltip.SetToolTip(navPrevBtn, LangMan.Get("prev-image") + " | " + LangMan.Get("left-arrow"));
            infoTooltip.SetToolTip(navNextBtn, LangMan.Get("next-image") + " | " + LangMan.Get("right-arrow"));
            infoTooltip.SetToolTip(navSlideshowBtn, LangMan.Get("slideshow") + " | Ctrl+Shift+S");

            Location = new Point(borderSpacing, Parent.ClientRectangle.Height - extraBottomMargin - Height - borderSpacing);
        }
コード例 #11
0
 private void InitLanguage()
 {
     infoTooltip.SetToolTip(autoZoomBtn, LangMan.Get("auto-zoom") + " | Ctrl+A");
     infoTooltip.SetToolTip(opacityBtn, LangMan.Get("change-window-opacity") + " | Ctrl+O");
     zoomLabel.Text     = LangMan.Get("zoom") + ": " + LangMan.Get("auto");
     checkboardBtn.Text = LangMan.Get("checkboard-background");
     newWindowBtn.Text  = LangMan.Get("new-window");
     quitPipBtn.Text    = LangMan.Get("exit-picture-in-picture");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #12
0
        private void InfoForm_Load(object sender, EventArgs e)
        {
            SetDarkMode(DarkMode);
            InitLanguage();

            if (directoryName != null)
            {
                string path = Path.Combine(directoryName, fileName);

                fileNameTextBox.Text = fileName;
                folderTextBox.Text   = directoryName;
                fullPathTextBox.Text = path;

                diskSizeTextBox.Text  = Converter.PathToSize(path);
                extensionTextBox.Text = Path.GetExtension(path).Substring(1, Path.GetExtension(path).Length - 1).ToUpper();

                createdTextBox.Text  = File.GetCreationTime(path).ToShortDateString() + " - " + File.GetCreationTime(path).ToLongTimeString();
                modifiedTextBox.Text = File.GetLastWriteTime(path).ToShortDateString() + " - " + File.GetLastWriteTime(path).ToLongTimeString();

                propertiesButton.Visible = true;
            }

            double inchesWidth  = bitmap.Width / bitmap.HorizontalResolution;
            double inchesHeight = bitmap.Height / bitmap.VerticalResolution;
            double cmWidth      = inchesWidth * 2.54;
            double cmHeight     = inchesHeight * 2.54;

            compressionTextBox.Text = getImageCompression(bitmap);

            sizeTextBox.Text       = bitmap.Width + " x " + bitmap.Height + " " + LangMan.Get("pixels");
            megapixelsTextBox.Text = ((((float)bitmap.Height * bitmap.Width) / 1000000)).ToString("0.##") + " " + LangMan.Get("megapixels");
            resolutionTextBox.Text = Math.Round(bitmap.HorizontalResolution) + " x " + Math.Round(bitmap.VerticalResolution) + " DPI";
            inchesTextBox.Text     = inchesWidth.ToString("0.##") + " x " + inchesHeight.ToString("0.##") + " " + LangMan.Get("inches");
            cmTextBox.Text         = cmWidth.ToString("0.##") + " x " + cmHeight.ToString("0.##") + " " + LangMan.Get("centimeters");

            int firstRatio  = bitmap.Width / GCD(bitmap.Width, bitmap.Height);
            int secondRatio = bitmap.Height / GCD(bitmap.Width, bitmap.Height);

            ratioTextBox.Text = string.Format("{0} : {1} (", firstRatio, secondRatio);
            if (firstRatio == secondRatio)
            {
                ratioTextBox.Text += LangMan.Get("square");
            }
            else if (firstRatio > secondRatio)
            {
                ratioTextBox.Text += LangMan.Get("landscape");
            }
            else
            {
                ratioTextBox.Text += LangMan.Get("portrait");
            }
            ratioTextBox.Text += ")";

            fileNameTextBox.Focus();
        }
コード例 #13
0
 private void InitLanguage()
 {
     Text = "SVG " + LangMan.Get("type-options");
     presetsLabel.Text        = LangMan.Get("presets") + ":";
     widthLabel.Text          = LangMan.Get("width") + ":";
     heightLabel.Text         = LangMan.Get("height") + ":";
     defaultSizeButton.Text   = LangMan.Get("original-size");
     autoSizeBtn.Text         = LangMan.Get("auto-size");
     okButton.Text            = " " + LangMan.Get("resize-svg");
     aspectRatioCheckbox.Text = LangMan.Get("maintain-aspect-ratio");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #14
0
 private void InitLanguage()
 {
     Text          = LangMan.Get("set-as-desktop-background");
     fitLabel.Text = LangMan.Get("choose-fit") + ":";
     okButton.Text = " " + LangMan.Get("set-background");
     fitComboBox.Items.Add(LangMan.Get("fill"));
     fitComboBox.Items.Add(LangMan.Get("fit"));
     fitComboBox.Items.Add(LangMan.Get("stretch"));
     fitComboBox.Items.Add(LangMan.Get("tile"));
     fitComboBox.Items.Add(LangMan.Get("center"));
     fitComboBox.Items.Add(LangMan.Get("span"));
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #15
0
        public static string GetFolder()
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            dialog.Title          = LangMan.Get("open-recursive");
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string p = dialog.FileName;
                dialog.Dispose();
                return(p);
            }
            return(null);
        }
コード例 #16
0
 private void InitLanguage()
 {
     Text = LangMan.Get("plugin-manager");
     listView1.Columns[0].Text = LangMan.Get("plugin");
     listView1.Columns[1].Text = LangMan.Get("desc");
     listView1.Columns[2].Text = LangMan.Get("created-by");
     listView1.Columns[3].Text = LangMan.Get("version");
     addPluginBtn.Text         = " " + LangMan.Get("browse-for-plugins");
     deleteBtn.Text            = LangMan.Get("delete-plugin");
     openFileDialog1.Title     = LangMan.Get("browse-for-plugins");
     morePluginsBtn.Text       = " " + LangMan.Get("more-plugins");
     pluginWebsiteBtn.Text     = LangMan.Get("plugin-website");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #17
0
 private void InitLanguage()
 {
     Text = LangMan.Get("print-conf");
     setMarginsButton.Text   = LangMan.Get("set-margins-btn");
     okButton.Text           = LangMan.Get("print");
     leftLabel.Text          = LangMan.Get("left") + ":";
     rightLabel.Text         = LangMan.Get("right") + ":";
     topLabel.Text           = LangMan.Get("top") + ":";
     bottomLabel.Text        = LangMan.Get("bottom") + ":";
     documentLabel.Text      = LangMan.Get("title") + ":";
     centerCheckbox.Text     = LangMan.Get("center-image");
     horizontalCheckBox.Text = LangMan.Get("landscape-orientation");
     marginsLabel.Text       = LangMan.Get("margins") + ":";
     marginsCheckBox.Text    = LangMan.Get("margin-bounds");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #18
0
        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();
        }
コード例 #19
0
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         return(new FileTypeMan.OpenResult
         {
             Bmp = new Icon(path, 128, 128).ToBitmap()
         });
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
コード例 #20
0
 private void setMarginsButton_Click(object sender, EventArgs e)
 {
     try
     {
         printPreviewControl1.Document.DefaultPageSettings.Margins.Left   = Convert.ToInt32(leftMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Top    = Convert.ToInt32(topMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Right  = Convert.ToInt32(rightMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Bottom = Convert.ToInt32(bottomMarginTextBox.Value);
         printPreviewControl1.InvalidatePreview();
     }
     catch
     {
         DialogMan.ShowInfo(
             LangMan.Get("plugin-not-found"),
             LangMan.Get("print-margins-error"),
             DarkMode
             );
     }
 }
コード例 #21
0
 private void InitLanguage()
 {
     Text                          = LangMan.Get("settings");
     langPage.Text                 = LangMan.Get("localization");
     startupPage.Text              = LangMan.Get("startup");
     restartLabel1.Text            = "* " + LangMan.Get("restart-required");
     restartLabel2.Text            = "* " + LangMan.Get("restart-required");
     systemThemeRadio.Text         = LangMan.Get("use-system-setting");
     lightThemeRadio.Text          = LangMan.Get("light");
     darkThemeRadio.Text           = LangMan.Get("dark");
     themePage.Text                = LangMan.Get("theme");
     startupLabel.Text             = LangMan.Get("app-startup-actions") + ":";
     startupPasteCheckBox.Text     = LangMan.Get("paste-from-clipboard");
     startupBoundsCheckBox.Text    = LangMan.Get("restore-last-window-bounds");
     updatesCheckBox.Text          = LangMan.Get("check-for-app-updates");
     favExtLabel.Text              = LangMan.Get("fav-external-app") + ":";
     browseBtn.Text                = " " + LangMan.Get("browse");
     slideshowPage.Text            = LangMan.Get("slideshow");
     slideshowTimeLabel.Text       = LangMan.Get("switching-time") + ":";
     mousePage.Text                = LangMan.Get("input");
     slideshowSecondsLabel.Text    = LangMan.Get("seconds");
     slideshowCounterCheckBox.Text = LangMan.Get("show-slideshow-counter");
     fullscrCursorCheckBox.Text    = LangMan.Get("fullscreen-cursor");
     langLabel.Text                = LangMan.Get("ui-lang") + ":";
     translatedByLabel.Text        = LangMan.Get("translated-by") + ": ";
     escToExitCheckBox.Text        = string.Format(LangMan.Get("esc-to-exit"), "Esc");
     mouseWheelActionLabel.Text    = LangMan.Get("mouse-wheel-action") + ":";
     mouseWheelActionRadio1.Text   = LangMan.Get("scroll-up-down");
     mouseWheelActionRadio2.Text   = LangMan.Get("zoom-in-out");
     mouseWheelActionRadio3.Text   = LangMan.Get("next-prev-image");
     themeRestart.Text             = LangMan.Get("restart");
     localizationRestart.Text      = LangMan.Get("restart");
     contextMenuLabel.Text         = LangMan.Get("context-menu") + ":";
     makeDefaultBtn.Text           = LangMan.Get("set-as-default-image-viewer");
     navBarPage.Text               = LangMan.Get("navigation-bar");
     navBarCheckBox.Text           = LangMan.Get("enable-navigation-bar");
     navBarFullscreenCheckBox.Text = LangMan.Get("nav-bar-fullscreen");
     openWithCheckBox.Text         = LangMan.Get("open-with-qpv");
     browseWithCheckBox.Text       = LangMan.Get("browse-folder-with-qpv");
     helpTranslateBtn.Text         = LangMan.Get("help-us-translate-app");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #22
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            Bitmap bmp = ParseSvg(path);

            if (bmp != null)
            {
                return new FileTypeMan.OpenResult
                       {
                           Bmp = bmp
                       }
            }
            ;
            else
            {
                return new FileTypeMan.OpenResult
                       {
                           ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                       }
            };
        }
コード例 #23
0
        public static FileTypeMan.OpenResult CustomSizeOpen(string path, int Width = -1, int Height = -1)
        {
            Bitmap bmp = ParseSvg(path, Width, Height);

            if (bmp != null)
            {
                return new FileTypeMan.OpenResult
                       {
                           Bmp = bmp
                       }
            }
            ;
            else
            {
                return new FileTypeMan.OpenResult
                       {
                           ErrorMessage = "SVG - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                       }
            };
        }
コード例 #24
0
        private void setAutoZoom(bool b)
        {
            autoZoom = b;

            if (b)
            {
                pictureBox.Dock = DockStyle.Fill;

                zoomLabel.Text = LangMan.Get("zoom") + ": " + LangMan.Get("auto");

                Height = Convert.ToInt32(Width / ratio);
                if (Height == MaximumSize.Height)
                {
                    Width = Convert.ToInt32(Height * ratio);
                }
            }
            else
            {
                pictureBox.Dock = DockStyle.None;
            }
        }
コード例 #25
0
 private void InitLanguage()
 {
     Text = LangMan.Get("image-info");
     fileNameLabel.Text   = LangMan.Get("file") + ":";
     folderLabel.Text     = LangMan.Get("folder") + ":";
     fullPathLabel.Text   = LangMan.Get("full-path") + ":";
     diskSizeLabel.Text   = LangMan.Get("disk-size") + ":";
     ratioLabel.Text      = LangMan.Get("aspect-ratio") + ":";
     resolutionLabel.Text = LangMan.Get("resolution") + ":";
     createdLabel.Text    = LangMan.Get("created") + ":";
     modifiedLabel.Text   = LangMan.Get("modified") + ":";
     infoTooltip.SetToolTip(copyNameButton, LangMan.Get("copy"));
     infoTooltip.SetToolTip(copyFolderButton, LangMan.Get("copy"));
     infoTooltip.SetToolTip(copyPathButton, LangMan.Get("copy"));
     extensionLabel.Text   = LangMan.Get("extension") + ":";
     compressionLabel.Text = LangMan.Get("compression") + ":";
     propertiesButton.Text = " " + LangMan.Get("file-properties");
     sizeLabel.Text        = LangMan.Get("size") + " (px):";
     megapixelsLabel.Text  = LangMan.Get("size") + " (mp):";
     inchesLabel.Text      = LangMan.Get("print-size") + " (in):";
     cmLabel.Text          = LangMan.Get("print-size") + " (cm):";
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
コード例 #26
0
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         byte[] rawWebP = File.ReadAllBytes(path);
         using (WebP webp = new WebP())
         {
             WebPDecoderOptions decoderOptions = new WebPDecoderOptions();
             decoderOptions.use_threads = 1;
             decoderOptions.alpha_dithering_strength = 100;
             return(new FileTypeMan.OpenResult
             {
                 Bmp = webp.Decode(rawWebP, decoderOptions)
             });
         }
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
コード例 #27
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            try
            {
                using (var image = Pfim.Pfim.FromFile(path))
                {
                    PixelFormat format;

                    switch (image.Format)
                    {
                    case Pfim.ImageFormat.Rgba32:
                        format = PixelFormat.Format32bppArgb;
                        break;

                    case Pfim.ImageFormat.Rgb24:
                        format = PixelFormat.Format24bppRgb;
                        break;

                    case Pfim.ImageFormat.Rgba16:
                        format = PixelFormat.Format16bppArgb1555;
                        break;

                    case Pfim.ImageFormat.Rgb8:
                        format = PixelFormat.Format8bppIndexed;
                        break;

                    default:
                        return(new FileTypeMan.OpenResult
                        {
                            ErrorMessage = TypeName + " - " + LangMan.Get("unsupported-pixel-format") + ": " + Path.GetFileName(path)
                        });
                    }

                    try
                    {
                        if (TmpGcHandle != null && TmpGcHandle.IsAllocated)
                        {
                            TmpGcHandle.Free();
                        }
                        TmpGcHandle = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
                        var data = Marshal.UnsafeAddrOfPinnedArrayElement(image.Data, 0);

                        return(new FileTypeMan.OpenResult
                        {
                            Bmp = new Bitmap(image.Width, image.Height, image.Stride, format, data)
                        });
                    }
                    catch
                    {
                        return(new FileTypeMan.OpenResult
                        {
                            ErrorMessage = TypeName + " - " + LangMan.Get("memory-error") + ": " + Path.GetFileName(path)
                        });
                    }
                }
            }
            catch
            {
                return(new FileTypeMan.OpenResult
                {
                    ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                });
            }
        }