Fixed problems in the designer with the last changes, also added some future code which is disabled. And uncommented the "Greenshot-filetype" registration in the installer.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2375 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-11 11:51:41 +00:00
parent 3115c927b7
commit e11450f56f
7 changed files with 161 additions and 17 deletions

View file

@ -32,12 +32,13 @@ using Greenshot.Helpers;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
using GreenshotPlugin.Controls;
namespace Greenshot {
/// <summary>
/// The about form
/// </summary>
public partial class AboutForm : BaseForm {
public partial class AboutForm : AnimatingBaseForm {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
private Bitmap gBitmap = new Bitmap(90, 90, PixelFormat.Format32bppRgb);
private ColorAnimator backgroundAnimation;

View file

@ -0,0 +1,27 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 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 GreenshotPlugin.Controls;
namespace Greenshot {
public class AnimatingBaseForm : AnimatingForm {
}
}

View file

@ -140,6 +140,9 @@
<Compile Include="Forms\ImageEditorForm.Designer.cs">
<DependentUpon>ImageEditorForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\AnimatingBaseForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\LanguageDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -186,6 +189,7 @@
<Compile Include="Helpers\CopyData.cs" />
<Compile Include="Helpers\GeometryHelper.cs" />
<Compile Include="Helpers\DestinationHelper.cs" />
<None Include="Helpers\HookHelper.cs" />
<Compile Include="Helpers\IECaptureHelper.cs" />
<Compile Include="Helpers\IEInterop\IEContainer.cs" />
<Compile Include="Helpers\ProcessorHelper.cs" />

View file

@ -0,0 +1,96 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 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.Text;
using GreenshotPlugin.UnmanagedHelpers;
using System.Diagnostics;
using GreenshotPlugin.Core;
namespace Greenshot.Helpers {
public class HookHelper {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(HookHelper));
private static List<IntPtr> hooks = new List<IntPtr>();
private static WinEventDelegate _winEventProc;
private static uint oleEventThread = 0;
/// <summary>
/// Remove the made hooks
/// </summary>
public static void Unhook() {
LOG.Debug("Cleaning winEvent hooks");
foreach (IntPtr hook in hooks) {
if (hook != IntPtr.Zero) {
User32.UnhookWinEvent(hook);
}
}
}
/// <summary>
/// Hook the WinEvents we are interested in
/// </summary>
public static void Hook() {
LOG.Debug("Starting winEvent hooks");
_winEventProc = new WinEventDelegate(WinEventProc);
int processID = 0; //Process.GetCurrentProcess().Id;
hooks.Add(User32.SetWinEventHook(WinEvent.EVENT_OBJECT_CREATE, WinEvent.EVENT_OBJECT_HIDE, IntPtr.Zero, _winEventProc, processID, 0, WinEventHookFlags.WINEVENT_SKIPOWNPROCESS));
hooks.Add(User32.SetWinEventHook(WinEvent.EVENT_OBJECT_LOCATIONCHANGE, WinEvent.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, _winEventProc, 0, 0, WinEventHookFlags.WINEVENT_SKIPOWNPROCESS));
hooks.Add(User32.SetWinEventHook(WinEvent.EVENT_SYSTEM_MENUSTART, WinEvent.EVENT_SYSTEM_MENUPOPUPEND, IntPtr.Zero, _winEventProc, processID, 0, WinEventHookFlags.WINEVENT_SKIPOWNPROCESS));
}
/// <summary>
/// Handle the WinEvent
/// </summary>
/// <param name="hWinEventHook">The Hook IntPtr</param>
/// <param name="eventType">Event Type to handle, enum WinEvent</param>
/// <param name="hwnd">Window handle which caused the event</param>
/// <param name="idObject">Object ID, enum EventObjects</param>
/// <param name="idChild">Child ID of the window</param>
/// <param name="dwEventThread">Thread which generated the ID</param>
/// <param name="dwmsEventTime"></param>
private static void WinEventProc(IntPtr hWinEventHook, WinEvent eventType, IntPtr hwnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime) {
// Check if it's an event generated by a Window
if (hwnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW) {
// Other events do not interest us.
return;
}
String classname = null;
// Check if the event was generated by the OLE Event Thread, which causes a lot of create/destroy
if (oleEventThread != 0 && dwEventThread == oleEventThread) {
return;
}
// Only get the classname when it's not a destroy (classname is not available)
if (eventType == WinEvent.EVENT_OBJECT_CREATE) {
classname = WindowDetails.GetClassName(hwnd);
// Make sure the OleMainThreadWndClass events are ignored.
if (oleEventThread == 0) {
if (classname == "OleMainThreadWndClass") {
oleEventThread = dwEventThread;
return;
}
}
}
LOG.DebugFormat("eventType={0},hwnd={1},classname={4},idObject={2},idChild={3},dwEventThread={5}", eventType, hwnd, idObject, idChild, classname, dwEventThread);
}
}
}

View file

@ -143,10 +143,10 @@ Root: HKCU; Subkey: Software\Microsoft\Windows\CurrentVersion\Run; ValueType: st
; HKEY_LOCAL_MACHINE - for all users
Root: HKLM; Subkey: Software\Microsoft\Windows\CurrentVersion\Run; ValueType: string; ValueName: {#ExeName}; ValueData: {app}\{#ExeName}.exe; Permissions: users-modify; Flags: uninsdeletevalue; Tasks: startup; Check: IsAdminLoggedOn
; Register our own filetype
;Root: HKCR; Subkey: ".gsb"; ValueType: string; ValueName: ""; ValueData: "GreenshotFile"; Flags: uninsdeletevalue
;Root: HKCR; Subkey: "GreenshotFile"; ValueType: string; ValueName: ""; ValueData: "Greenshot File"; Flags: uninsdeletekey
;Root: HKCR; Subkey: "GreenshotFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\Greenshot.EXE,0"
;Root: HKCR; Subkey: "GreenshotFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\Greenshot.EXE"" --openfile ""%1"""
Root: HKCR; Subkey: ".greenshot"; ValueType: string; ValueName: ""; ValueData: "GreenshotFile"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "GreenshotFile"; ValueType: string; ValueName: ""; ValueData: "Greenshot File"; Flags: uninsdeletekey
Root: HKCR; Subkey: "GreenshotFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\Greenshot.EXE,0"
Root: HKCR; Subkey: "GreenshotFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\Greenshot.EXE"" --openfile ""%1"""
[Icons]
Name: {group}\{#ExeName}; Filename: {app}\{#ExeName}.exe; WorkingDir: {app}
Name: {group}\Uninstall {#ExeName}; Filename: {uninstallexe}; WorkingDir: {app}; AppUserModelID: "{#ExeName}.{#ExeName}"

View file

@ -28,8 +28,7 @@ namespace GreenshotPlugin.Controls {
/// <summary>
/// Extend this Form to have the possibility for animations on your form
/// </summary>
public abstract class AnimatingForm : Form {
protected static CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
public class AnimatingForm : GreenshotForm {
private int vRefresh = 0;
private Timer timer = null;
@ -111,6 +110,8 @@ namespace GreenshotPlugin.Controls {
/// <summary>
/// This method will be called every frame, so implement your animation/redraw logic here.
/// </summary>
protected abstract void Animate();
protected virtual void Animate() {
throw new NotImplementedException();
}
}
}

View file

@ -20,7 +20,6 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using GreenshotPlugin.Core;
@ -30,8 +29,12 @@ using System.ComponentModel.Design;
using System.IO;
namespace GreenshotPlugin.Controls {
public abstract class GreenshotForm : AnimatingForm, IGreenshotLanguageBindable {
/// <summary>
/// This form is used for automatically binding the elements of the form to the language
/// </summary>
public class GreenshotForm : Form, IGreenshotLanguageBindable {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm));
protected static CoreConfiguration coreConfiguration;
private static IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>();
private IComponentChangeService m_changeService;
private bool isDesignModeLanguageSet = false;
@ -40,12 +43,31 @@ namespace GreenshotPlugin.Controls {
private IDictionary<string, Control> designTimeControls;
private IDictionary<string, ToolStripItem> designTimeToolStripItems;
static GreenshotForm() {
if (!IsInDesignMode) {
coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
}
}
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
/// <summary>
/// Used to check the designmode during a constructor
/// </summary>
/// <returns></returns>
protected static bool IsInDesignMode {
get {
if (Application.ExecutablePath.IndexOf("devenv.exe", StringComparison.OrdinalIgnoreCase) > -1) {
return true;
}
return false;
}
}
protected bool ManualLanguageApply {
get {
return applyLanguageManually;
@ -64,13 +86,6 @@ namespace GreenshotPlugin.Controls {
}
}
/// <summary>
/// Normally a Greenshot form doesn't animate
/// </summary>
protected override void Animate() {
throw new NotImplementedException();
}
/// <summary>
/// Code to initialize the language etc during design time
/// </summary>