diff --git a/Pinta.Core/Actions/ImageActions.cs b/Pinta.Core/Actions/ImageActions.cs index 134323241..51d6a5b0a 100644 --- a/Pinta.Core/Actions/ImageActions.cs +++ b/Pinta.Core/Actions/ImageActions.cs @@ -281,10 +281,10 @@ static void CropImageToRectangle (Document doc, RectangleI rect, Path? selection if (rect.Width <= 0 || rect.Height <= 0) return; - ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize); - - hist.Icon = Resources.Icons.ImageCrop; - hist.Text = Translations.GetString ("Crop to Selection"); + ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize) { + Icon = Resources.Icons.ImageCrop, + Text = Translations.GetString ("Crop to Selection") + }; hist.StartSnapshotOfImage (); hist.RestoreSelection = doc.Selection.Clone (); diff --git a/Pinta.Core/Classes/AsyncEffectRenderer.cs b/Pinta.Core/Classes/AsyncEffectRenderer.cs index 98212ec12..fb887afc6 100644 --- a/Pinta.Core/Classes/AsyncEffectRenderer.cs +++ b/Pinta.Core/Classes/AsyncEffectRenderer.cs @@ -201,9 +201,9 @@ void StartRender () HandleRenderCompletion (); return false; // don't call the timer again }); - }); - - master.Priority = settings.ThreadPriority; + }) { + Priority = settings.ThreadPriority + }; master.Start (); // Start timer used to periodically fire update events on the UI thread. @@ -214,9 +214,9 @@ Thread StartSlaveThread (int renderId, int threadId) { var slave = new Thread (() => { Render (renderId, threadId); - }); - - slave.Priority = settings.ThreadPriority; + }) { + Priority = settings.ThreadPriority + }; slave.Start (); return slave; diff --git a/Pinta.Core/Classes/Document.cs b/Pinta.Core/Classes/Document.cs index c442cdd1d..38180beee 100644 --- a/Pinta.Core/Classes/Document.cs +++ b/Pinta.Core/Classes/Document.cs @@ -294,9 +294,10 @@ public void ResizeCanvas (int width, int height, Anchor anchor, CompoundHistoryI PintaCore.Tools.Commit (); - ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize); - hist.Icon = Resources.Icons.ImageResizeCanvas; - hist.Text = Translations.GetString ("Resize Canvas"); + ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize) { + Icon = Resources.Icons.ImageResizeCanvas, + Text = Translations.GetString ("Resize Canvas") + }; hist.StartSnapshotOfImage (); scale = Workspace.Scale; diff --git a/Pinta.Core/Effects/ColorBgra.cs b/Pinta.Core/Effects/ColorBgra.cs index 2849f1a6c..fd815324f 100644 --- a/Pinta.Core/Effects/ColorBgra.cs +++ b/Pinta.Core/Effects/ColorBgra.cs @@ -191,8 +191,9 @@ public readonly ColorBgra NewAlpha (byte newA) /// public static ColorBgra FromBgra (byte b, byte g, byte r, byte a) { - ColorBgra color = new ColorBgra (); - color.Bgra = BgraToUInt32 (b, g, r, a); + ColorBgra color = new ColorBgra { + Bgra = BgraToUInt32 (b, g, r, a) + }; return color; } @@ -259,8 +260,9 @@ public static ColorBgra FromBgr (byte b, byte g, byte r) /// public static ColorBgra FromUInt32 (UInt32 bgra) { - ColorBgra color = new ColorBgra (); - color.Bgra = bgra; + ColorBgra color = new ColorBgra { + Bgra = bgra + }; return color; } @@ -313,12 +315,12 @@ public static ColorBgra Blend (ColorBgra ca, ColorBgra cb, byte cbAlpha) /// public static ColorBgra Lerp (ColorBgra from, ColorBgra to, float frac) { - ColorBgra ret = new ColorBgra (); - - ret.B = (byte) ClampToByte (Lerp (from.B, to.B, frac)); - ret.G = (byte) ClampToByte (Lerp (from.G, to.G, frac)); - ret.R = (byte) ClampToByte (Lerp (from.R, to.R, frac)); - ret.A = (byte) ClampToByte (Lerp (from.A, to.A, frac)); + ColorBgra ret = new ColorBgra { + B = (byte) ClampToByte (Lerp (from.B, to.B, frac)), + G = (byte) ClampToByte (Lerp (from.G, to.G, frac)), + R = (byte) ClampToByte (Lerp (from.R, to.R, frac)), + A = (byte) ClampToByte (Lerp (from.A, to.A, frac)) + }; return ret; } @@ -343,12 +345,12 @@ public static double Lerp (double from, double to, double frac) /// public static ColorBgra Lerp (ColorBgra from, ColorBgra to, double frac) { - ColorBgra ret = new ColorBgra (); - - ret.B = (byte) ClampToByte (Lerp (from.B, to.B, frac)); - ret.G = (byte) ClampToByte (Lerp (from.G, to.G, frac)); - ret.R = (byte) ClampToByte (Lerp (from.R, to.R, frac)); - ret.A = (byte) ClampToByte (Lerp (from.A, to.A, frac)); + ColorBgra ret = new ColorBgra { + B = (byte) ClampToByte (Lerp (from.B, to.B, frac)), + G = (byte) ClampToByte (Lerp (from.G, to.G, frac)), + R = (byte) ClampToByte (Lerp (from.R, to.R, frac)), + A = (byte) ClampToByte (Lerp (from.A, to.A, frac)) + }; return ret; } diff --git a/Pinta.Core/Effects/UnaryPixelOps.cs b/Pinta.Core/Effects/UnaryPixelOps.cs index d4b95025f..630f95a0c 100644 --- a/Pinta.Core/Effects/UnaryPixelOps.cs +++ b/Pinta.Core/Effects/UnaryPixelOps.cs @@ -686,11 +686,11 @@ public void UnApply (ColorBgra after, float[] beforeOut, float[] slopesOut) public object Clone () { - Level copy = new Level (color_in_low, color_in_high, (float[]) gamma.Clone (), color_out_low, color_out_high); - - copy.CurveB = (byte[]) this.CurveB.Clone (); - copy.CurveG = (byte[]) this.CurveG.Clone (); - copy.CurveR = (byte[]) this.CurveR.Clone (); + Level copy = new Level (color_in_low, color_in_high, (float[]) gamma.Clone (), color_out_low, color_out_high) { + CurveB = (byte[]) this.CurveB.Clone (), + CurveG = (byte[]) this.CurveG.Clone (), + CurveR = (byte[]) this.CurveR.Clone () + }; return copy; } diff --git a/Pinta.Core/ImageFormats/OraFormat.cs b/Pinta.Core/ImageFormats/OraFormat.cs index 63bc798cb..4267f5822 100644 --- a/Pinta.Core/ImageFormats/OraFormat.cs +++ b/Pinta.Core/ImageFormats/OraFormat.cs @@ -145,8 +145,9 @@ private static Size GetThumbDimensions (int width, int height) private byte[] GetLayerXmlData (IReadOnlyList layers) { MemoryStream ms = new MemoryStream (); - XmlTextWriter writer = new XmlTextWriter (ms, System.Text.Encoding.UTF8); - writer.Formatting = Formatting.Indented; + XmlTextWriter writer = new XmlTextWriter (ms, System.Text.Encoding.UTF8) { + Formatting = Formatting.Indented + }; writer.WriteStartElement ("image"); writer.WriteAttributeString ("w", layers[0].Surface.Width.ToString ()); @@ -183,8 +184,9 @@ public void Export (Document document, Gio.File file, Gtk.Window parent) using var stream = new ZipOutputStream (file_stream) { UseZip64 = UseZip64.Off // For backwards compatibility with older versions. }; - ZipEntry mimetype = new ZipEntry ("mimetype"); - mimetype.CompressionMethod = CompressionMethod.Stored; + ZipEntry mimetype = new ZipEntry ("mimetype") { + CompressionMethod = CompressionMethod.Stored + }; stream.PutNextEntry (mimetype); byte[] databytes = System.Text.Encoding.ASCII.GetBytes ("image/openraster"); diff --git a/Pinta.Core/ImageFormats/TgaExporter.cs b/Pinta.Core/ImageFormats/TgaExporter.cs index dc4e75d38..4ffae5c9f 100644 --- a/Pinta.Core/ImageFormats/TgaExporter.cs +++ b/Pinta.Core/ImageFormats/TgaExporter.cs @@ -95,20 +95,20 @@ public void Export (Document document, Gio.File file, Gtk.Window parent) using var file_stream = new GioStream (file.Replace ()); using var writer = new BinaryWriter (file_stream); - TgaHeader header = new TgaHeader (); - - header.idLength = (byte) (ImageIdField.Length + 1); - header.cmapType = 0; - header.imageType = 2; // uncompressed RGB - header.cmapIndex = 0; - header.cmapLength = 0; - header.cmapEntrySize = 0; - header.xOrigin = 0; - header.yOrigin = 0; - header.imageWidth = (ushort) surf.Width; - header.imageHeight = (ushort) surf.Height; - header.pixelDepth = 32; - header.imageDesc = 8; // 32-bit, lower-left origin, which is weird but hey... + TgaHeader header = new TgaHeader { + idLength = (byte) (ImageIdField.Length + 1), + cmapType = 0, + imageType = 2, // uncompressed RGB + cmapIndex = 0, + cmapLength = 0, + cmapEntrySize = 0, + xOrigin = 0, + yOrigin = 0, + imageWidth = (ushort) surf.Width, + imageHeight = (ushort) surf.Height, + pixelDepth = 32, + imageDesc = 8 // 32-bit, lower-left origin, which is weird but hey... + }; header.WriteTo (writer); writer.Write (ImageIdField); diff --git a/Pinta.Effects/Dialogs/Effects.PosterizeDialog.cs b/Pinta.Effects/Dialogs/Effects.PosterizeDialog.cs index ff8eac150..845552321 100644 --- a/Pinta.Effects/Dialogs/Effects.PosterizeDialog.cs +++ b/Pinta.Effects/Dialogs/Effects.PosterizeDialog.cs @@ -105,18 +105,21 @@ private void Build () content_area.SetAllMargins (6); content_area.Spacing = 6; - red_spinbox = new HScaleSpinButtonWidget (); - red_spinbox.Label = Translations.GetString ("Red"); + red_spinbox = new HScaleSpinButtonWidget { + Label = Translations.GetString ("Red") + }; InitSpinBox (red_spinbox); content_area.Append (red_spinbox); - green_spinbox = new HScaleSpinButtonWidget (); - green_spinbox.Label = Translations.GetString ("Green"); + green_spinbox = new HScaleSpinButtonWidget { + Label = Translations.GetString ("Green") + }; InitSpinBox (green_spinbox); content_area.Append (green_spinbox); - blue_spinbox = new HScaleSpinButtonWidget (); - blue_spinbox.Label = Translations.GetString ("Blue"); + blue_spinbox = new HScaleSpinButtonWidget { + Label = Translations.GetString ("Blue") + }; InitSpinBox (blue_spinbox); content_area.Append (blue_spinbox); diff --git a/Pinta.Gui.Widgets/Widgets/AnglePickerWidget.cs b/Pinta.Gui.Widgets/Widgets/AnglePickerWidget.cs index e16ee9633..e834ae167 100644 --- a/Pinta.Gui.Widgets/Widgets/AnglePickerWidget.cs +++ b/Pinta.Gui.Widgets/Widgets/AnglePickerWidget.cs @@ -94,9 +94,10 @@ private void Build () var hbox2 = new Box () { Spacing = spacing }; hbox2.SetOrientation (Orientation.Horizontal); - anglepickergraphic1 = new AnglePickerGraphic (); - anglepickergraphic1.Hexpand = true; - anglepickergraphic1.Halign = Align.Center; + anglepickergraphic1 = new AnglePickerGraphic { + Hexpand = true, + Halign = Align.Center + }; hbox2.Append (anglepickergraphic1); spin = SpinButton.NewWithRange (0, 360, 1); diff --git a/Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs b/Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs index e17496bfc..26056b74c 100644 --- a/Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs +++ b/Pinta.Gui.Widgets/Widgets/PointPickerWidget.cs @@ -157,9 +157,10 @@ private void Build () var hbox2 = new Box () { Spacing = spacing }; hbox2.SetOrientation (Orientation.Horizontal); - pointpickergraphic1 = new PointPickerGraphic (); - pointpickergraphic1.Hexpand = true; - pointpickergraphic1.Halign = Align.Center; + pointpickergraphic1 = new PointPickerGraphic { + Hexpand = true, + Halign = Align.Center + }; hbox2.Append (pointpickergraphic1); // X spinner diff --git a/Pinta.Tools/Editable/Shapes/Arrow.cs b/Pinta.Tools/Editable/Shapes/Arrow.cs index 8767fc110..88094ca5f 100644 --- a/Pinta.Tools/Editable/Shapes/Arrow.cs +++ b/Pinta.Tools/Editable/Shapes/Arrow.cs @@ -44,12 +44,12 @@ public class Arrow /// A clone of the Arrow. public Arrow Clone () { - Arrow clonedA = new Arrow (); - - clonedA.Show = Show; - clonedA.ArrowSize = ArrowSize; - clonedA.AngleOffset = AngleOffset; - clonedA.LengthOffset = LengthOffset; + Arrow clonedA = new Arrow { + Show = Show, + ArrowSize = ArrowSize, + AngleOffset = AngleOffset, + LengthOffset = LengthOffset + }; return clonedA; } diff --git a/Pinta.Tools/Tools/EraserTool.cs b/Pinta.Tools/Tools/EraserTool.cs index 1aa690a0b..529ae2b31 100644 --- a/Pinta.Tools/Tools/EraserTool.cs +++ b/Pinta.Tools/Tools/EraserTool.cs @@ -144,8 +144,9 @@ private static ImageSurface CopySurfacePart (ImageSurface surf, RectangleI dest_ { var tmp_surface = CairoExtensions.CreateImageSurface (Format.Argb32, dest_rect.Width, dest_rect.Height); - var g = new Context (tmp_surface); - g.Operator = Operator.Source; + var g = new Context (tmp_surface) { + Operator = Operator.Source + }; g.SetSourceSurface (surf, -dest_rect.Left, -dest_rect.Top); g.Rectangle (new RectangleD (0, 0, dest_rect.Width, dest_rect.Height)); g.Fill (); diff --git a/Pinta.Tools/Tools/LassoSelectTool.cs b/Pinta.Tools/Tools/LassoSelectTool.cs index 150e198b7..5d6c921e6 100644 --- a/Pinta.Tools/Tools/LassoSelectTool.cs +++ b/Pinta.Tools/Tools/LassoSelectTool.cs @@ -90,8 +90,9 @@ protected override void OnMouseMove (Document document, ToolMouseEventArgs e) var surf = document.Layers.SelectionLayer.Surface; - var g = new Context (surf); - g.Antialias = Antialias.Subpixel; + var g = new Context (surf) { + Antialias = Antialias.Subpixel + }; if (path != null) { g.AppendPath (path); diff --git a/Pinta.Tools/Tools/PaintBucketTool.cs b/Pinta.Tools/Tools/PaintBucketTool.cs index 0689c8fb9..2310655f6 100644 --- a/Pinta.Tools/Tools/PaintBucketTool.cs +++ b/Pinta.Tools/Tools/PaintBucketTool.cs @@ -62,8 +62,9 @@ protected override void OnFillRegionComputed (Document document, BitMask stencil { var surf = document.Layers.ToolLayer.Surface; - var g = new Context (surf); - g.Operator = Operator.Source; + var g = new Context (surf) { + Operator = Operator.Source + }; g.SetSourceSurface (document.Layers.CurrentUserLayer.Surface, 0, 0); g.Paint (); diff --git a/Pinta.Tools/Tools/TextTool.cs b/Pinta.Tools/Tools/TextTool.cs index 78ead3f53..21af3f4ee 100644 --- a/Pinta.Tools/Tools/TextTool.cs +++ b/Pinta.Tools/Tools/TextTool.cs @@ -139,9 +139,12 @@ protected override void OnBuildToolBar (Gtk.Box tb) tb.Append (font_label); if (font_button == null) { - font_button = new FontButton () { UseSize = false, UseFont = true, CanFocus = false }; - // Default to Arial if possible. - font_button.Font = Settings.GetSetting (FONT_SETTING, "Arial 12"); + font_button = new FontButton { + UseSize = false, + UseFont = true, + CanFocus = false, // Default to Arial if possible. + Font = Settings.GetSetting (FONT_SETTING, "Arial 12") + }; font_button.OnFontSet += HandleFontChanged; } @@ -151,36 +154,36 @@ protected override void OnBuildToolBar (Gtk.Box tb) tb.Append (GtkExtensions.CreateToolBarSeparator ()); if (bold_btn == null) { - bold_btn = new ToggleButton () { + bold_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatTextBold, TooltipText = Translations.GetString ("Bold"), - CanFocus = false + CanFocus = false, + Active = Settings.GetSetting (BOLD_SETTING, false) }; - bold_btn.Active = Settings.GetSetting (BOLD_SETTING, false); bold_btn.OnToggled += HandleBoldButtonToggled; } tb.Append (bold_btn); if (italic_btn == null) { - italic_btn = new ToggleButton () { + italic_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatTextItalic, TooltipText = Translations.GetString ("Italic"), - CanFocus = false + CanFocus = false, + Active = Settings.GetSetting (ITALIC_SETTING, false) }; - italic_btn.Active = Settings.GetSetting (ITALIC_SETTING, false); italic_btn.OnToggled += HandleItalicButtonToggled; } tb.Append (italic_btn); if (underscore_btn == null) { - underscore_btn = new ToggleButton () { + underscore_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatTextUnderline, TooltipText = Translations.GetString ("Underline"), - CanFocus = false + CanFocus = false, + Active = Settings.GetSetting (UNDERLINE_SETTING, false) }; - underscore_btn.Active = Settings.GetSetting (UNDERLINE_SETTING, false); underscore_btn.OnToggled += HandleUnderscoreButtonToggled; } @@ -191,36 +194,36 @@ protected override void OnBuildToolBar (Gtk.Box tb) var alignment = (TextAlignment) Settings.GetSetting (ALIGNMENT_SETTING, (int) TextAlignment.Left); if (left_alignment_btn == null) { - left_alignment_btn = new ToggleButton () { + left_alignment_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatJustifyLeft, TooltipText = Translations.GetString ("Left Align"), - CanFocus = false + CanFocus = false, + Active = alignment == TextAlignment.Left }; - left_alignment_btn.Active = alignment == TextAlignment.Left; left_alignment_btn.OnToggled += HandleLeftAlignmentButtonToggled; } tb.Append (left_alignment_btn); if (center_alignment_btn == null) { - center_alignment_btn = new ToggleButton () { + center_alignment_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatJustifyCenter, TooltipText = Translations.GetString ("Center Align"), - CanFocus = false + CanFocus = false, + Active = alignment == TextAlignment.Center }; - center_alignment_btn.Active = alignment == TextAlignment.Center; center_alignment_btn.OnToggled += HandleCenterAlignmentButtonToggled; } tb.Append (center_alignment_btn); if (right_alignment_btn == null) { - right_alignment_btn = new ToggleButton () { + right_alignment_btn = new ToggleButton { IconName = Pinta.Resources.StandardIcons.FormatJustifyRight, TooltipText = Translations.GetString ("Right Align"), - CanFocus = false + CanFocus = false, + Active = alignment == TextAlignment.Right }; - right_alignment_btn.Active = alignment == TextAlignment.Right; right_alignment_btn.OnToggled += HandleRightAlignmentButtonToggled; } diff --git a/Pinta/Dialogs/LayerPropertiesDialog.cs b/Pinta/Dialogs/LayerPropertiesDialog.cs index 73b0d713a..36ca7e07c 100644 --- a/Pinta/Dialogs/LayerPropertiesDialog.cs +++ b/Pinta/Dialogs/LayerPropertiesDialog.cs @@ -180,9 +180,10 @@ private void Build () name_label.Halign = Align.End; grid.Attach (name_label, 0, 0, 1, 1); - layerNameEntry = new Entry (); - layerNameEntry.Hexpand = true; - layerNameEntry.Halign = Align.Fill; + layerNameEntry = new Entry { + Hexpand = true, + Halign = Align.Fill + }; grid.Attach (layerNameEntry, 1, 0, 1, 1); // Visible checkbox diff --git a/Pinta/Dialogs/NewImageDialog.cs b/Pinta/Dialogs/NewImageDialog.cs index 366bb43c4..5578a2a61 100644 --- a/Pinta/Dialogs/NewImageDialog.cs +++ b/Pinta/Dialogs/NewImageDialog.cs @@ -188,10 +188,10 @@ private void InitializePresets () private void BuildDialog () { // Layout table for preset, width, and height - var layout_grid = new Grid (); - - layout_grid.RowSpacing = 5; - layout_grid.ColumnSpacing = 6; + var layout_grid = new Grid { + RowSpacing = 5, + ColumnSpacing = 6 + }; // Preset Combo var size_label = Label.New (Translations.GetString ("Preset:")); @@ -217,9 +217,10 @@ private void BuildDialog () width_label.Xalign = 1f; width_label.Yalign = .5f; - width_entry = new Entry (); - width_entry.WidthRequest = 50; - width_entry.ActivatesDefault = true; + width_entry = new Entry { + WidthRequest = 50, + ActivatesDefault = true + }; var width_units = Label.New (Translations.GetString ("pixels")); width_units.MarginStart = 5; @@ -236,9 +237,10 @@ private void BuildDialog () height_label.Xalign = 1f; height_label.Yalign = .5f; - height_entry = new Entry (); - height_entry.WidthRequest = 50; - height_entry.ActivatesDefault = true; + height_entry = new Entry { + WidthRequest = 50, + ActivatesDefault = true + }; var height_units = Label.New (Translations.GetString ("pixels")); height_units.MarginStart = 5; @@ -343,9 +345,10 @@ private void BuildDialog () options_vbox.Append (background_vbox); // Layout the preview + the options - preview = new PreviewArea (); - preview.Vexpand = true; - preview.Valign = Align.Fill; + preview = new PreviewArea { + Vexpand = true, + Valign = Align.Fill + }; var preview_label = Label.New (Translations.GetString ("Preview")); diff --git a/Pinta/Dialogs/ResizeCanvasDialog.cs b/Pinta/Dialogs/ResizeCanvasDialog.cs index 22d0c0163..0cbbac397 100644 --- a/Pinta/Dialogs/ResizeCanvasDialog.cs +++ b/Pinta/Dialogs/ResizeCanvasDialog.cs @@ -370,9 +370,12 @@ private void Build () SButton = CreateAnchorButton (); SEButton = CreateAnchorButton (); - var grid = new Grid () { RowSpacing = spacing, ColumnSpacing = spacing }; - grid.Halign = Align.Center; - grid.Valign = Align.Center; + var grid = new Grid { + RowSpacing = spacing, + ColumnSpacing = spacing, + Halign = Align.Center, + Valign = Align.Center + }; grid.Attach (NWButton, 0, 0, 1, 1); grid.Attach (NButton, 1, 0, 1, 1); grid.Attach (NEButton, 2, 0, 1, 1); diff --git a/Pinta/MainWindow.cs b/Pinta/MainWindow.cs index 276f9693a..ce84c66a8 100644 --- a/Pinta/MainWindow.cs +++ b/Pinta/MainWindow.cs @@ -408,9 +408,10 @@ private void CreateDockAndPads (Box container) PintaCore.Chrome.InitializeToolBox (toolbox); // Dock widget - dock = new Dock (); - dock.Hexpand = true; - dock.Halign = Align.Fill; + dock = new Dock { + Hexpand = true, + Halign = Align.Fill + }; // Canvas pad canvas_pad = new CanvasPad ();