Пример #1
0
        public Document NewDocument(Gdk.Size imageSize, Color backgroundColor)
        {
            Document doc = CreateAndActivateDocument(null, imageSize);

            doc.Workspace.CanvasSize = imageSize;

            // Start with an empty white layer
            Layer background = doc.Layers.AddNewLayer(Translations.GetString("Background"));

            if (backgroundColor.A != 0)
            {
                using (Cairo.Context g = new Cairo.Context(background.Surface)) {
                    g.SetSourceColor(backgroundColor);
                    g.Paint();
                }
            }

            doc.Workspace.History.PushNewItem(new BaseHistoryItem(Resources.StandardIcons.DocumentNew, Translations.GetString("New Image")));
            doc.Workspace.History.SetClean();

            // This ensures these are called after the window is done being created and sized.
            // Without it, we sometimes try to zoom when the window has a size of (0, 0).
            Gtk.Application.Invoke(delegate {
                PintaCore.Actions.View.ZoomToWindow.Activate();
            });

            return(doc);
        }
Пример #2
0
        public EditActions()
        {
            Undo              = new Command("undo", Translations.GetString("Undo"), null, Resources.StandardIcons.EditUndo);
            Redo              = new Command("redo", Translations.GetString("Redo"), null, Resources.StandardIcons.EditRedo);
            Cut               = new Command("cut", Translations.GetString("Cut"), null, Resources.StandardIcons.EditCut);
            Copy              = new Command("copy", Translations.GetString("Copy"), null, Resources.StandardIcons.EditCopy);
            CopyMerged        = new Command("copymerged", Translations.GetString("Copy Merged"), null, Resources.StandardIcons.EditCopy);
            Paste             = new Command("paste", Translations.GetString("Paste"), null, Resources.StandardIcons.EditPaste);
            PasteIntoNewLayer = new Command("pasteintonewlayer", Translations.GetString("Paste Into New Layer"), null, Resources.StandardIcons.EditPaste);
            PasteIntoNewImage = new Command("pasteintonewimage", Translations.GetString("Paste Into New Image"), null, Resources.StandardIcons.EditPaste);
            EraseSelection    = new Command("eraseselection", Translations.GetString("Erase Selection"), null, Resources.Icons.EditSelectionErase);
            FillSelection     = new Command("fillselection", Translations.GetString("Fill Selection"), null, Resources.Icons.EditSelectionFill);
            InvertSelection   = new Command("invertselection", Translations.GetString("Invert Selection"), null, Resources.Icons.EditSelectionFill);
            SelectAll         = new Command("selectall", Translations.GetString("Select All"), null, Resources.StandardIcons.EditSelectAll);
            Deselect          = new Command("deselect", Translations.GetString("Deselect All"), null, Resources.Icons.EditSelectionNone);

            LoadPalette   = new Command("loadpalette", Translations.GetString("Open..."), null, Resources.StandardIcons.DocumentOpen);
            SavePalette   = new Command("savepalette", Translations.GetString("Save As..."), null, Resources.StandardIcons.DocumentSave);
            ResetPalette  = new Command("resetpalette", Translations.GetString("Reset to Default"), null, Resources.StandardIcons.DocumentRevert);
            ResizePalette = new Command("resizepalette", Translations.GetString("Set Number of Colors"), null, Resources.Icons.ImageResize);

            Undo.IsImportant = true;
            Undo.Sensitive   = false;
            Redo.Sensitive   = false;
        }
Пример #3
0
        public void RegisterActions(Gtk.Application app, GLib.Menu menu)
        {
            var zoom_section = new GLib.Menu();

            menu.AppendSection(null, zoom_section);

            app.AddAccelAction(ZoomIn, new[] { "<Primary>plus", "<Primary>equal", "equal", "<Primary>KP_Add", "KP_Add" });
            zoom_section.AppendItem(ZoomIn.CreateMenuItem());

            app.AddAccelAction(ZoomOut, new[] { "<Primary>minus", "<Primary>underscore", "minus", "<Primary>KP_Subtract", "KP_Subtract" });
            zoom_section.AppendItem(ZoomOut.CreateMenuItem());

            app.AddAccelAction(ActualSize, new[] { "<Primary>0", "<Primary><Shift>A" });
            zoom_section.AppendItem(ActualSize.CreateMenuItem());

            app.AddAccelAction(ZoomToWindow, "<Primary>B");
            zoom_section.AppendItem(ZoomToWindow.CreateMenuItem());

            app.AddAccelAction(Fullscreen, "F11");
            zoom_section.AppendItem(Fullscreen.CreateMenuItem());

            var metric_section = new GLib.Menu();

            menu.AppendSection(null, metric_section);

            var metric_menu = new GLib.Menu();

            metric_section.AppendSubmenu(Translations.GetString("Ruler Units"), metric_menu);

            app.AddAction(RulerMetric);
            metric_menu.Append(Translations.GetString("Pixels"), $"app.{RulerMetric.Name}(0)");
            metric_menu.Append(Translations.GetString("Inches"), $"app.{RulerMetric.Name}(1)");
            metric_menu.Append(Translations.GetString("Centimeters"), $"app.{RulerMetric.Name}(2)");

            var show_hide_section = new GLib.Menu();

            menu.AppendSection(null, show_hide_section);

            var show_hide_menu = new GLib.Menu();

            show_hide_section.AppendSubmenu(Translations.GetString("Show/Hide"), show_hide_menu);

            app.AddAction(PixelGrid);
            show_hide_menu.AppendItem(PixelGrid.CreateMenuItem());

            app.AddAction(Rulers);
            show_hide_menu.AppendItem(Rulers.CreateMenuItem());

            app.AddAction(ToolBar);
            show_hide_menu.AppendItem(ToolBar.CreateMenuItem());

            app.AddAction(StatusBar);
            show_hide_menu.AppendItem(StatusBar.CreateMenuItem());

            app.AddAction(ToolBox);
            show_hide_menu.AppendItem(ToolBox.CreateMenuItem());

            app.AddAction(ImageTabs);
            show_hide_menu.AppendItem(ImageTabs.CreateMenuItem());
        }
Пример #4
0
        public PaletteDescriptor(string displayPrefix, string[] extensions, IPaletteLoader loader, IPaletteSaver saver)
        {
            this.Extensions = extensions;
            this.Loader     = loader;
            this.Saver      = saver;

            FileFilter    ff          = new FileFilter();
            StringBuilder formatNames = new StringBuilder();

            foreach (string ext in extensions)
            {
                if (formatNames.Length > 0)
                {
                    formatNames.Append(", ");
                }

                string wildcard = string.Format("*.{0}", ext);
                ff.AddPattern(wildcard);
                formatNames.Append(wildcard);
            }

            // Translators: {0} is the palette format (e.g. "GIMP") and {1} is a list of file extensions.
            ff.Name     = Translations.GetString("{0} palette ({1})", displayPrefix, formatNames);
            this.Filter = ff;
        }
Пример #5
0
        public ResizeHistoryItem(Size oldSize) : base()
        {
            old_size = oldSize;

            Icon = Resources.Icons.ImageResize;
            Text = Translations.GetString("Resize Image");
        }
Пример #6
0
        public void UpdateCanvasScale()
        {
            string text = PintaCore.Actions.View.ZoomComboBox.ComboBox.ActiveText;

            // stay in "Zoom to Window" mode if this function was called without the zoom level being changed by the user (e.g. if the
            // image was rotated or cropped) and "Zoom to Window" mode is active
            if (text == Translations.GetString("Window") || (ZoomToWindowActivated && old_zoom_text == text))
            {
                PintaCore.Actions.View.ZoomToWindow.Activate();
                ZoomToWindowActivated = true;
                return;
            }
            else
            {
                ZoomToWindowActivated = false;
            }

            double percent;

            if (!TryParsePercent(text, out percent))
            {
                return;
            }

            percent = Math.Min(percent, 3600);
            percent = percent / 100.0;

            PintaCore.Workspace.Scale = percent;
        }
Пример #7
0
 public HelpActions()
 {
     Contents  = new Command("contents", Translations.GetString("Contents"), null, Resources.StandardIcons.HelpBrowser);
     Website   = new Command("website", Translations.GetString("Pinta Website"), null, Resources.Icons.HelpWebsite);
     Bugs      = new Command("bugs", Translations.GetString("File a Bug"), null, Resources.Icons.HelpBug);
     Translate = new Command("translate", Translations.GetString("Translate This Application"), null, Resources.Icons.HelpTranslate);
 }
Пример #8
0
        static void CropImageToRectangle(Document doc, Gdk.Rectangle rect, Path?selection)
        {
            if (rect.Width > 0 && rect.Height > 0)
            {
                ResizeHistoryItem hist = new ResizeHistoryItem(doc.ImageSize);

                hist.Icon = Resources.Icons.ImageCrop;
                hist.Text = Translations.GetString("Crop to Selection");
                hist.StartSnapshotOfImage();
                hist.RestoreSelection = doc.Selection.Clone();

                doc.Workspace.Canvas.Window.FreezeUpdates();

                double original_scale = doc.Workspace.Scale;
                doc.ImageSize            = rect.Size;
                doc.Workspace.CanvasSize = rect.Size;
                doc.Workspace.Scale      = original_scale;

                PintaCore.Actions.View.UpdateCanvasScale();

                doc.Workspace.Canvas.Window.ThawUpdates();

                foreach (var layer in doc.Layers.UserLayers)
                {
                    layer.Crop(rect, selection);
                }

                hist.FinishSnapshotOfImage();

                doc.History.PushNewItem(hist);
                doc.ResetSelectionPaths();

                doc.Workspace.Invalidate();
            }
        }
Пример #9
0
        public void BuildToolbar(Gtk.Toolbar tb, ISettingsService settings)
        {
            if (selection_label == null)
            {
                selection_label = new ToolBarLabel(Translations.GetString(" Selection Mode: "));
            }

            tb.AppendItem(selection_label);

            if (selection_combo_box == null)
            {
                selection_combo_box = new ToolBarComboBox(170, 0, false);

                selection_combo_box.ComboBox.Changed += (o, e) => {
                    selected_mode = combine_modes[selection_combo_box.ComboBox.ActiveText];
                };

                foreach (var mode in combine_modes)
                {
                    selection_combo_box.ComboBox.AppendText(mode.Key);
                }

                selection_combo_box.ComboBox.Active = settings.GetSetting(COMBINE_MODE_SETTING, 0);
            }

            tb.AppendItem(selection_combo_box);
        }
Пример #10
0
        /// <param name="displayPrefix">
        /// A descriptive name for the format, such as "OpenRaster". This will be displayed
        /// in the file dialog's filter.
        /// </param>
        /// <param name="extensions">A list of supported file extensions (for example, "jpeg" and "JPEG").</param>
        /// <param name="importer">The importer for this file format, or null if importing is not supported.</param>
        /// <param name="exporter">The exporter for this file format, or null if exporting is not supported.</param>
        public FormatDescriptor(string displayPrefix, string[] extensions,
                                IImageImporter?importer, IImageExporter?exporter)
        {
            if (extensions == null || (importer == null && exporter == null))
            {
                throw new ArgumentNullException("Format descriptor is initialized incorrectly");
            }

            this.Extensions = extensions;
            this.Importer   = importer;
            this.Exporter   = exporter;

            FileFilter    ff          = new FileFilter();
            StringBuilder formatNames = new StringBuilder();

            foreach (string ext in extensions)
            {
                if (formatNames.Length > 0)
                {
                    formatNames.Append(", ");
                }

                string wildcard = string.Format("*.{0}", ext);
                ff.AddPattern(wildcard);
                formatNames.Append(wildcard);
            }

            ff.Name     = string.Format(Translations.GetString("{0} image ({1})"), displayPrefix, formatNames);
            this.Filter = ff;
        }
Пример #11
0
        public PasteHistoryItem(Gdk.Pixbuf pasteImage, DocumentSelection oldSelection)
        {
            Text = Translations.GetString("Paste");
            Icon = Resources.StandardIcons.EditPaste;

            paste_image   = pasteImage;
            old_selection = oldSelection;
        }
Пример #12
0
        /// <summary>
        /// Convert the given number to a percentage string using the current locale.
        /// </summary>
        public static string ToPercent(double n)
        {
            var percent = (n * 100).ToString("N0", CultureInfo.CurrentCulture);

            // Translators: This specifies the format of the zoom percentage choices
            // in the toolbar.
            return(Translations.GetString("{0}%", percent));
        }
Пример #13
0
        private void ShowOpenFileErrorDialog(Window parent, string filename, string primaryText, string details)
        {
            string markup        = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}";
            string secondaryText = string.Format(Translations.GetString("Could not open file: {0}"), filename);
            string message       = string.Format(markup, primaryText, secondaryText);

            PintaCore.Chrome.ShowErrorDialog(parent, message, details);
        }
Пример #14
0
        private void ShowFilePermissionErrorDialog(Window parent, string filename)
        {
            string markup  = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}";
            string primary = Translations.GetString("Failed to open image");
            // Translators: {0} is the name of a file that the user does not have permission to open.
            string secondary = Translations.GetString("You do not have access to '{0}'.", filename);
            string message   = string.Format(markup, primary, secondary);

            using var md = new MessageDialog(parent, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, message);
            md.Run();
        }
Пример #15
0
        public ViewActions()
        {
            ZoomIn          = new Command("ZoomIn", Translations.GetString("Zoom In"), null, Resources.StandardIcons.ZoomIn);
            ZoomOut         = new Command("ZoomOut", Translations.GetString("Zoom Out"), null, Resources.StandardIcons.ZoomOut);
            ZoomToWindow    = new Command("ZoomToWindow", Translations.GetString("Best Fit"), null, Resources.StandardIcons.ZoomFitBest);
            ZoomToSelection = new Command("ZoomToSelection", Translations.GetString("Zoom to Selection"), null, Resources.Icons.ViewZoomSelection);
            ActualSize      = new Command("ActualSize", Translations.GetString("Normal Size"), null, Resources.StandardIcons.ZoomOriginal);
            ToolBar         = new ToggleCommand("Toolbar", Translations.GetString("Toolbar"), null, null);
            ImageTabs       = new ToggleCommand("ImageTabs", Translations.GetString("Image Tabs"), null, null);
            PixelGrid       = new ToggleCommand("PixelGrid", Translations.GetString("Pixel Grid"), null, Resources.Icons.ViewGrid);
            StatusBar       = new ToggleCommand("Statusbar", Translations.GetString("Status Bar"), null, null);
            ToolBox         = new ToggleCommand("ToolBox", Translations.GetString("Tool Box"), null, null);
            Rulers          = new ToggleCommand("Rulers", Translations.GetString("Rulers"), null, Resources.Icons.ViewRulers);
            RulerMetric     = new GLib.SimpleAction("rulermetric", GLib.VariantType.Int32, new GLib.Variant(0));
            Fullscreen      = new Command("Fullscreen", Translations.GetString("Fullscreen"), null, Resources.StandardIcons.DocumentNew);

            ZoomCollection = new string[] {
                ToPercent(36),
                ToPercent(24),
                ToPercent(16),
                ToPercent(12),
                ToPercent(8),
                ToPercent(7),
                ToPercent(6),
                ToPercent(5),
                ToPercent(4),
                ToPercent(3),
                ToPercent(2),
                ToPercent(1.75),
                ToPercent(1.5),
                ToPercent(1.25),
                ToPercent(1),
                ToPercent(0.66),
                ToPercent(0.5),
                ToPercent(0.33),
                ToPercent(0.25),
                ToPercent(0.16),
                ToPercent(0.12),
                ToPercent(0.08),
                ToPercent(0.05),
                Translations.GetString("Window")
            };
            ZoomComboBox = new ToolBarComboBox(90, DefaultZoomIndex(), true, ZoomCollection)
            {
                Margin = 4
            };

            // The toolbar is shown by default.
            ToolBar.Value   = true;
            ImageTabs.Value = true;
            StatusBar.Value = true;
            ToolBox.Value   = true;
        }
Пример #16
0
        private void HandlerPintaCoreActionsEditSavePaletteActivated(object sender, EventArgs e)
        {
            using var fcd = new FileChooserNative(
                      Translations.GetString("Save Palette File"),
                      PintaCore.Chrome.MainWindow,
                      FileChooserAction.Save,
                      Translations.GetString("Save"),
                      Translations.GetString("Cancel"))
                  {
                      DoOverwriteConfirmation = true
                  };

            foreach (var format in PintaCore.System.PaletteFormats.Formats)
            {
                if (!format.IsReadOnly())
                {
                    FileFilter fileFilter = format.Filter;
                    fcd.AddFilter(fileFilter);
                }
            }

            if (lastPaletteDir != null)
            {
                fcd.SetCurrentFolder(lastPaletteDir);
            }

            var response = (ResponseType)fcd.Run();

            if (response == Gtk.ResponseType.Accept)
            {
                string filename = fcd.Filename;

                // Add in the extension if necessary, based on the current selected file filter.
                // Note: on macOS, fcd.Filter doesn't seem to properly update to the current filter.
                // However, on macOS the dialog always adds the extension automatically, so this issue doesn't matter.
                string extension = System.IO.Path.GetExtension(filename);
                if (string.IsNullOrEmpty(extension))
                {
                    var currentFormat = PintaCore.System.PaletteFormats.Formats.First(f => f.Filter == fcd.Filter);
                    filename += "." + currentFormat.Extensions.First();
                }

                var format = PintaCore.System.PaletteFormats.GetFormatByFilename(filename);
                if (format is null)
                {
                    throw new FormatException();
                }

                PintaCore.Palette.CurrentPalette.Save(filename, format.Saver);
                lastPaletteDir = System.IO.Path.GetDirectoryName(filename);
            }
        }
Пример #17
0
 public ImageActions()
 {
     CropToSelection = new Command("croptoselection", Translations.GetString("Crop to Selection"), null, Resources.Icons.ImageCrop);
     AutoCrop        = new Command("autocrop", Translations.GetString("Auto Crop"), null, Resources.Icons.ImageCrop);
     Resize          = new Command("resize", Translations.GetString("Resize Image..."), null, Resources.Icons.ImageResize);
     CanvasSize      = new Command("canvassize", Translations.GetString("Resize Canvas..."), null, Resources.Icons.ImageResizeCanvas);
     FlipHorizontal  = new Command("fliphorizontal", Translations.GetString("Flip Horizontal"), null, Resources.Icons.ImageFlipHorizontal);
     FlipVertical    = new Command("flipvertical", Translations.GetString("Flip Vertical"), null, Resources.Icons.ImageFlipVertical);
     RotateCW        = new Command("rotatecw", Translations.GetString("Rotate 90° Clockwise"), null, Resources.Icons.ImageRotate90CW);
     RotateCCW       = new Command("rotateccw", Translations.GetString("Rotate 90° Counter-Clockwise"), null, Resources.Icons.ImageRotate90CCW);
     Rotate180       = new Command("rotate180", Translations.GetString("Rotate 180°"), null, Resources.Icons.ImageRotate180);
     Flatten         = new Command("flatten", Translations.GetString("Flatten"), null, Resources.Icons.ImageFlatten);
 }
Пример #18
0
 public LayerActions()
 {
     AddNewLayer    = new Command("addnewlayer", Translations.GetString("Add New Layer"), null, Resources.Icons.LayerNew);
     DeleteLayer    = new Command("deletelayer", Translations.GetString("Delete Layer"), null, Resources.Icons.LayerDelete);
     DuplicateLayer = new Command("duplicatelayer", Translations.GetString("Duplicate Layer"), null, Resources.Icons.LayerDuplicate);
     MergeLayerDown = new Command("mergelayerdown", Translations.GetString("Merge Layer Down"), null, Resources.Icons.LayerMergeDown);
     ImportFromFile = new Command("importfromfile", Translations.GetString("Import from File..."), null, Resources.Icons.LayerImport);
     FlipHorizontal = new Command("fliphorizontal", Translations.GetString("Flip Horizontal"), null, Resources.Icons.LayerFlipHorizontal);
     FlipVertical   = new Command("flipvertical", Translations.GetString("Flip Vertical"), null, Resources.Icons.LayerFlipVertical);
     RotateZoom     = new Command("RotateZoom", Translations.GetString("Rotate / Zoom Layer..."), null, Resources.Icons.LayerRotateZoom);
     MoveLayerUp    = new Command("movelayerup", Translations.GetString("Move Layer Up"), null, Resources.Icons.LayerMoveUp);
     MoveLayerDown  = new Command("movelayerdown", Translations.GetString("Move Layer Down"), null, Resources.Icons.LayerMoveDown);
     Properties     = new Command("properties", Translations.GetString("Layer Properties..."), null, Resources.Icons.LayerProperties);
 }
Пример #19
0
 public SelectionModeHandler()
 {
     combine_modes = new Dictionary <string, CombineMode> ()
     {
         { Translations.GetString("Replace"), CombineMode.Replace },
         // Translators: {0} is 'Ctrl', or a platform-specific key such as 'Command' on macOS.
         { Translations.GetString("Union (+) ({0} + Left Click)", GtkExtensions.CtrlLabel()), CombineMode.Union },
         { Translations.GetString("Exclude (-) (Right Click)"), CombineMode.Exclude },
         // Translators: {0} is 'Ctrl', or a platform-specific key such as 'Command' on macOS.
         { Translations.GetString("Xor ({0} + Right Click)", GtkExtensions.CtrlLabel()), CombineMode.Xor },
         // Translators: {0} is 'Alt', or a platform-specific key such as 'Option' on macOS.
         { Translations.GetString("Intersect ({0} + Left Click)", GtkExtensions.AltLabel()), CombineMode.Intersect },
     };
 }
Пример #20
0
        public void AddEffect(string category, Command action)
        {
            var effects_menu = PintaCore.Chrome.EffectsMenu;

            if (!Menus.ContainsKey(category))
            {
                var category_menu = new GLib.Menu();
                effects_menu.AppendMenuItemSorted(GLib.MenuItem.NewSubmenu(Translations.GetString(category), category_menu));
                Menus.Add(category, category_menu);
            }

            Actions.Add(action);

            GLib.Menu m = Menus[category];
            m.AppendMenuItemSorted(action.CreateMenuItem());
        }
Пример #21
0
        public FileActions()
        {
            New           = new Command("new", Translations.GetString("New..."), null, Resources.StandardIcons.DocumentNew);
            NewScreenshot = new Command("NewScreenshot", Translations.GetString("New Screenshot..."), null, Resources.StandardIcons.ViewFullscreen);
            Open          = new Command("open", Translations.GetString("Open..."), null, Resources.StandardIcons.DocumentOpen);

            Close  = new Command("close", Translations.GetString("Close"), null, Resources.StandardIcons.WindowClose);
            Save   = new Command("save", Translations.GetString("Save"), null, Resources.StandardIcons.DocumentSave);
            SaveAs = new Command("saveAs", Translations.GetString("Save As..."), null, Resources.StandardIcons.DocumentSaveAs);
            Print  = new Command("print", Translations.GetString("Print"), null, Resources.StandardIcons.DocumentPrint);

            New.ShortLabel   = Translations.GetString("New");
            Open.ShortLabel  = Translations.GetString("Open");
            Open.IsImportant = true;
            Save.IsImportant = true;
        }
Пример #22
0
        public WindowActions()
        {
            SaveAll  = new Command("SaveAll", Translations.GetString("Save All"), null, Resources.StandardIcons.DocumentSave);
            CloseAll = new Command("CloseAll", Translations.GetString("Close All"), null, Resources.StandardIcons.WindowClose);

            active_doc_action = new GLib.SimpleAction(doc_action_id, GLib.VariantType.Int32, new GLib.Variant(-1));

            active_doc_action.Activated += (o, e) => {
                var idx = (int)e.P0;
                if (idx < PintaCore.Workspace.OpenDocuments.Count)
                {
                    PintaCore.Workspace.SetActiveDocumentInternal(PintaCore.Workspace.OpenDocuments[idx]);
                    active_doc_action.ChangeState(e.P0);
                }
            };
        }
Пример #23
0
        private void HandlerPintaCoreActionsEditLoadPaletteActivated(object sender, EventArgs e)
        {
            using var fcd = new FileChooserNative(
                      Translations.GetString("Open Palette File"),
                      PintaCore.Chrome.MainWindow,
                      FileChooserAction.Open,
                      Translations.GetString("Open"),
                      Translations.GetString("Cancel"));

            var ff = new FileFilter {
                Name = Translations.GetString("Palette files")
            };

            foreach (var format in PintaCore.System.PaletteFormats.Formats)
            {
                if (!format.IsWriteOnly())
                {
                    foreach (var ext in format.Extensions)
                    {
                        ff.AddPattern(string.Format("*.{0}", ext));
                    }
                }
            }

            fcd.AddFilter(ff);

            FileFilter ff2 = new FileFilter {
                Name = Translations.GetString("All files")
            };

            ff2.AddPattern("*.*");
            fcd.AddFilter(ff2);

            if (lastPaletteDir != null)
            {
                fcd.SetCurrentFolder(lastPaletteDir);
            }

            var response = (ResponseType)fcd.Run();

            if (response == ResponseType.Accept)
            {
                var filename = fcd.Filename;
                lastPaletteDir = System.IO.Path.GetDirectoryName(filename);
                PintaCore.Palette.CurrentPalette.Load(filename);
            }
        }
Пример #24
0
        public InvertHistoryItem(InvertType type, int layerIndex)
        {
            this.type        = type;
            this.layer_index = layerIndex;

            switch (type)
            {
            case InvertType.FlipLayerHorizontal:
                Text = Translations.GetString("Flip Layer Horizontal");
                Icon = Resources.Icons.ImageFlipHorizontal;
                break;

            case InvertType.FlipLayerVertical:
                Text = Translations.GetString("Flip Layer Vertical");
                Icon = Resources.Icons.ImageFlipVertical;
                break;
            }
        }
Пример #25
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Tools.Commit();

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.Layers.ToolLayer.Clear();

            SelectionHistoryItem historyItem = new SelectionHistoryItem(Resources.Icons.EditSelectionInvert,
                                                                        Translations.GetString("Invert Selection"));

            historyItem.TakeSnapshot();

            doc.Selection.Invert(doc.Layers.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem(historyItem);
            doc.Workspace.Invalidate();
        }
Пример #26
0
        void Apply()
        {
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss:ffff") + "LivePreviewManager.Apply()");
            apply_live_preview_flag = true;

            if (!renderer.IsRendering)
            {
                HandleApply();
            }
            else
            {
                var dialog = PintaCore.Chrome.ProgressDialog;
                dialog.Title     = Translations.GetString("Rendering Effect");
                dialog.Text      = effect.Name;
                dialog.Progress  = renderer.Progress;
                dialog.Canceled += HandleProgressDialogCancel;
                dialog.Show();
            }
        }
Пример #27
0
 static UserBlendOps()
 {
     blend_modes.Add(Translations.GetString("Normal"), BlendMode.Normal);
     blend_modes.Add(Translations.GetString("Multiply"), BlendMode.Multiply);
     blend_modes.Add(Translations.GetString("Color Burn"), BlendMode.ColorBurn);
     blend_modes.Add(Translations.GetString("Color Dodge"), BlendMode.ColorDodge);
     blend_modes.Add(Translations.GetString("Overlay"), BlendMode.Overlay);
     blend_modes.Add(Translations.GetString("Difference"), BlendMode.Difference);
     blend_modes.Add(Translations.GetString("Lighten"), BlendMode.Lighten);
     blend_modes.Add(Translations.GetString("Darken"), BlendMode.Darken);
     blend_modes.Add(Translations.GetString("Screen"), BlendMode.Screen);
     blend_modes.Add(Translations.GetString("Xor"), BlendMode.Xor);
     blend_modes.Add(Translations.GetString("Hard Light"), BlendMode.HardLight);
     blend_modes.Add(Translations.GetString("Soft Light"), BlendMode.SoftLight);
     blend_modes.Add(Translations.GetString("Color"), BlendMode.Color);
     blend_modes.Add(Translations.GetString("Luminosity"), BlendMode.Luminosity);
     blend_modes.Add(Translations.GetString("Hue"), BlendMode.Hue);
     blend_modes.Add(Translations.GetString("Saturation"), BlendMode.Saturation);
 }
Пример #28
0
        // TODO: Standardize add to recent files
        public bool OpenFile(string file, Window?parent = null)
        {
            bool fileOpened = false;

            if (parent == null)
            {
                parent = PintaCore.Chrome.MainWindow;
            }

            try {
                // Open the image and add it to the layers
                IImageImporter?importer = PintaCore.System.ImageFormats.GetImporterByFile(file);
                if (importer == null)
                {
                    throw new FormatException(Translations.GetString("Unsupported file format"));
                }

                importer.Import(file, parent);

                PintaCore.Workspace.ActiveDocument.PathAndFileName = file;
                PintaCore.Workspace.ActiveWorkspace.History.PushNewItem(new BaseHistoryItem(Resources.StandardIcons.DocumentOpen, Translations.GetString("Open Image")));
                PintaCore.Workspace.ActiveDocument.History.SetClean();
                PintaCore.Workspace.ActiveDocument.HasFile = true;

                // This ensures these are called after the window is done being created and sized.
                // Without it, we sometimes try to zoom when the window has a size of (0, 0).
                Gtk.Application.Invoke(delegate {
                    PintaCore.Actions.View.ZoomToWindow.Activate();
                    PintaCore.Workspace.Invalidate();
                });

                fileOpened = true;
            } catch (UnauthorizedAccessException) {
                ShowFilePermissionErrorDialog(parent, file);
            } catch (FormatException e) {
                ShowUnsupportedFormatDialog(parent, file, e.Message, e.ToString());
            } catch (Exception e) {
                ShowOpenFileErrorDialog(parent, file, e.Message, e.ToString());
            }

            return(fileOpened);
        }
Пример #29
0
        public Document CreateAndActivateDocument(string?filename, Gdk.Size size)
        {
            Document doc = new Document(size);

            if (string.IsNullOrEmpty(filename))
            {
                doc.Filename = string.Format(Translations.GetString("Unsaved Image {0}"), new_file_name++);
            }
            else
            {
                doc.PathAndFileName = filename;
            }

            OpenDocuments.Add(doc);
            OnDocumentCreated(new DocumentEventArgs(doc));

            SetActiveDocument(doc);

            return(doc);
        }
Пример #30
0
        private void ShowUnsupportedFormatDialog(Window parent, string filename, string primaryText, string details)
        {
            string markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}";

            string secondaryText = Translations.GetString("Could not open file: {0}", filename);

            secondaryText += string.Format("\n\n{0}\n", Translations.GetString("Pinta supports the following file formats:"));
            var extensions = from format in PintaCore.System.ImageFormats.Formats
                             where format.Importer != null
                             from extension in format.Extensions
                             where char.IsLower(extension.FirstOrDefault())
                             orderby extension
                             select extension;

            secondaryText += String.Join(", ", extensions);

            string message = string.Format(markup, primaryText, secondaryText);

            PintaCore.Chrome.ShowUnsupportedFormatDialog(parent, message, details);
        }