diff --git a/GreenshotEditor/Configuration/EditorConfiguration.cs b/GreenshotEditor/Configuration/EditorConfiguration.cs new file mode 100644 index 000000000..841679059 --- /dev/null +++ b/GreenshotEditor/Configuration/EditorConfiguration.cs @@ -0,0 +1,48 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Windows.Forms; + +using Greenshot.Core; + +namespace Greenshot.Editor { + /// + /// Description of CoreConfiguration. + /// + [IniSection("Editor", Description="Greenshot editor configuration")] + public class EditorConfiguration : IniSection { + [IniProperty("EditorWindowSize", Description="Size of the editor.", DefaultValue="540, 380")] + public Size EditorWindowSize; + [IniProperty("EditorWindowLocation", Description="Location of the editor.", DefaultValue="100, 100")] + public Point EditorWindowLocation; + [IniProperty("EditorWindowState", Description="The window state of the editor. (Normal or Maximized)", DefaultValue="Normal")] + public FormWindowState EditorWindowState; + [IniProperty("EditorPreviousScreenbounds", Description="What screenbound did we have last time? Is used to check screen configuration changes, preventing windows to appear nowhere.", DefaultValue="0,0,0,0")] + public Rectangle EditorPreviousScreenbounds; + + public Color[] Editor_RecentColors = new Color[12]; + public Font Editor_Font = null; + } +} diff --git a/GreenshotEditor/Forms/ImageEditorForm.cs b/GreenshotEditor/Forms/ImageEditorForm.cs index f15fb5de8..c43f98e45 100644 --- a/GreenshotEditor/Forms/ImageEditorForm.cs +++ b/GreenshotEditor/Forms/ImageEditorForm.cs @@ -35,13 +35,13 @@ using System.Windows.Forms; using Greenshot.Capturing; using Greenshot.Configuration; +using Greenshot.Core; using Greenshot.Drawing; using Greenshot.Drawing.Fields; using Greenshot.Drawing.Fields.Binding; -//using Greenshot.Help; +using Greenshot.Editor; using Greenshot.Helpers; using Greenshot.Plugin; -using Greenshot.Core; namespace Greenshot.Forms { /// @@ -51,7 +51,8 @@ namespace Greenshot.Forms { private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm)); - private AppConfig conf = AppConfig.GetInstance(); + private EditorConfiguration conf = IniConfig.GetIniSection(); + private CoreConfiguration coreConf = IniConfig.GetIniSection(); private ILanguage lang; private string lastSaveFullPath; @@ -85,7 +86,7 @@ namespace Greenshot.Forms { InitializeComponent(); // Restore to previous location - FormHelper.RestoreGeometry(this, conf.Editor_WindowSize, conf.Editor_WindowLocation, conf.Editor_WindowState, conf.Editor_Previous_Screenbounds); + FormHelper.RestoreGeometry(this, conf.EditorWindowSize, conf.EditorWindowLocation, conf.EditorWindowState, conf.EditorPreviousScreenbounds); // Intial "saved" flag for asking if the image needs to be save saved = outputMade; @@ -541,7 +542,7 @@ namespace Greenshot.Forms { #region help void HelpToolStripMenuItem1Click(object sender, System.EventArgs e) { - new HelpBrowserForm(conf.Ui_Language).Show(); + new HelpBrowserForm(coreConf.Language).Show(); } void AboutToolStripMenuItemClick(object sender, System.EventArgs e) { @@ -592,8 +593,8 @@ namespace Greenshot.Forms { } } // persist our geometry string. - FormHelper.StoreGeometry(this, out conf.Editor_WindowSize, out conf.Editor_WindowLocation, out conf.Editor_WindowState, out conf.Editor_Previous_Screenbounds); - conf.Store(); + FormHelper.StoreGeometry(this, out conf.EditorWindowSize, out conf.EditorWindowLocation, out conf.EditorWindowState, out conf.EditorPreviousScreenbounds); + IniConfig.Save(); surface.Dispose(); @@ -861,7 +862,7 @@ namespace Greenshot.Forms { void SaveElementsToolStripMenuItemClick(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Greenshot templates (*.gst)|*.gst"; - saveFileDialog.FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(conf.Output_File_FilenamePattern, surface.CaptureDetails); + saveFileDialog.FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConf.OutputFileFilenamePattern, surface.CaptureDetails); DialogResult dialogResult = saveFileDialog.ShowDialog(); if(dialogResult.Equals(DialogResult.OK)) { using (Stream streamWrite = File.OpenWrite(saveFileDialog.FileName)) { diff --git a/GreenshotEditor/GreenshotEditor.csproj b/GreenshotEditor/GreenshotEditor.csproj index ce0d7aed9..b6e3b572a 100644 --- a/GreenshotEditor/GreenshotEditor.csproj +++ b/GreenshotEditor/GreenshotEditor.csproj @@ -54,6 +54,7 @@ + @@ -140,6 +141,7 @@ + "$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs" diff --git a/GreenshotEditor/Helpers/FormHelper.cs b/GreenshotEditor/Helpers/FormHelper.cs index bd1e4d3f3..3d6a6876f 100644 --- a/GreenshotEditor/Helpers/FormHelper.cs +++ b/GreenshotEditor/Helpers/FormHelper.cs @@ -25,14 +25,14 @@ using System.Windows.Forms; namespace Greenshot.Helpers { public class FormHelper { #region static - public static void RestoreGeometry(Form formIn, Size size, Point location, String state, Rectangle previousScreenbounds) { + public static void RestoreGeometry(Form formIn, Size size, Point location, FormWindowState state, Rectangle previousScreenbounds) { Rectangle screenbounds = WindowCapture.GetScreenBounds(); // Used default settings if no previous screenbounds were given if (previousScreenbounds == Rectangle.Empty) { previousScreenbounds = screenbounds; } - if (state != "Maximized" && state != "Normal") { + if (state != FormWindowState.Maximized && state != FormWindowState.Normal) { // Form was most likely minimized, should NOT use size/location!! formIn.WindowState = FormWindowState.Normal; return; @@ -51,17 +51,15 @@ namespace Greenshot.Helpers { } // Set state - if (state == "Maximized") { - formIn.WindowState = FormWindowState.Maximized; - } else if (state == "Normal") { - formIn.WindowState = FormWindowState.Normal; + if (state == FormWindowState.Maximized || state == FormWindowState.Normal) { + formIn.WindowState = state; } } - public static void StoreGeometry(Form formIn, out Size size, out Point location, out String state, out Rectangle previousScreenbounds ) { + public static void StoreGeometry(Form formIn, out Size size, out Point location, out FormWindowState state, out Rectangle previousScreenbounds ) { size = formIn.Size; location = formIn.Location; - state = formIn.WindowState.ToString(); + state = formIn.WindowState; previousScreenbounds = WindowCapture.GetScreenBounds(); } #endregion