2
// ResizeImageDialog.cs
5
// Jonathan Pobst <monkey@jpobst.com>
7
// Copyright (c) 2010 Jonathan Pobst
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
public partial class ResizeImageDialog : Gtk.Dialog
34
private bool value_changing;
36
public ResizeImageDialog ()
40
Icon = PintaCore.Resources.GetIcon ("Menu.Image.Resize.png");
42
widthSpinner.Value = PintaCore.Workspace.ImageSize.X;
43
heightSpinner.Value = PintaCore.Workspace.ImageSize.Y;
45
percentageRadio.Toggled += new EventHandler (percentageRadio_Toggled);
46
absoluteRadio.Toggled += new EventHandler (absoluteRadio_Toggled);
48
percentageSpinner.ValueChanged += new EventHandler (percentageSpinner_ValueChanged);
50
widthSpinner.ValueChanged += new EventHandler (widthSpinner_ValueChanged);
51
heightSpinner.ValueChanged += new EventHandler (heightSpinner_ValueChanged);
54
#region Public Methods
55
public void SaveChanges ()
57
PintaCore.Workspace.ResizeImage (widthSpinner.ValueAsInt, heightSpinner.ValueAsInt);
61
#region Private Methods
62
private void heightSpinner_ValueChanged (object sender, EventArgs e)
67
if (aspectCheckbox.Active) {
68
value_changing = true;
69
widthSpinner.Value = (int)((heightSpinner.Value * PintaCore.Workspace.ImageSize.X) / PintaCore.Workspace.ImageSize.Y);
70
value_changing = false;
74
private void widthSpinner_ValueChanged (object sender, EventArgs e)
79
if (aspectCheckbox.Active) {
80
value_changing = true;
81
heightSpinner.Value = (int)((widthSpinner.Value * PintaCore.Workspace.ImageSize.Y) / PintaCore.Workspace.ImageSize.X);
82
value_changing = false;
86
private void percentageSpinner_ValueChanged (object sender, EventArgs e)
88
widthSpinner.Value = (int)(PintaCore.Workspace.ImageSize.X * (percentageSpinner.ValueAsInt / 100f));
89
heightSpinner.Value = (int)(PintaCore.Workspace.ImageSize.Y * (percentageSpinner.ValueAsInt / 100f));
92
private void absoluteRadio_Toggled (object sender, EventArgs e)
97
private void percentageRadio_Toggled (object sender, EventArgs e)
102
private void RadioToggle ()
104
if (percentageRadio.Active) {
105
percentageSpinner.Sensitive = true;
107
widthSpinner.Sensitive = false;
108
heightSpinner.Sensitive = false;
109
aspectCheckbox.Sensitive = false;
111
percentageSpinner.Sensitive = false;
113
widthSpinner.Sensitive = true;
114
heightSpinner.Sensitive = true;
115
aspectCheckbox.Sensitive = true;