mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Configuration refactoring: added EditorConfiguration
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@846 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e176d18dc3
commit
a73c3cfb15
4 changed files with 65 additions and 16 deletions
48
GreenshotEditor/Configuration/EditorConfiguration.cs
Normal file
48
GreenshotEditor/Configuration/EditorConfiguration.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 {
|
||||
/// <summary>
|
||||
/// Description of CoreConfiguration.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
/// <summary>
|
||||
|
@ -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<EditorConfiguration>();
|
||||
private CoreConfiguration coreConf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
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)) {
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Configuration\EditorConfiguration.cs" />
|
||||
<Compile Include="Controls\BindableToolStripButton.cs" />
|
||||
<Compile Include="Controls\BindableToolStripComboBox.cs" />
|
||||
<Compile Include="Controls\BindableToolStripDropDownButton.cs" />
|
||||
|
@ -140,6 +141,7 @@
|
|||
<Folder Include="Forms" />
|
||||
<Folder Include="Controls" />
|
||||
<Folder Include="Helpers" />
|
||||
<Folder Include="Configuration" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"</PreBuildEvent>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue