mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
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:
parent
3115c927b7
commit
e11450f56f
7 changed files with 161 additions and 17 deletions
|
@ -32,12 +32,13 @@ using Greenshot.Helpers;
|
||||||
using Greenshot.Configuration;
|
using Greenshot.Configuration;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace Greenshot {
|
namespace Greenshot {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The about form
|
/// The about form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AboutForm : BaseForm {
|
public partial class AboutForm : AnimatingBaseForm {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
|
||||||
private Bitmap gBitmap = new Bitmap(90, 90, PixelFormat.Format32bppRgb);
|
private Bitmap gBitmap = new Bitmap(90, 90, PixelFormat.Format32bppRgb);
|
||||||
private ColorAnimator backgroundAnimation;
|
private ColorAnimator backgroundAnimation;
|
||||||
|
|
27
Greenshot/Forms/AnimatingBaseForm.cs
Normal file
27
Greenshot/Forms/AnimatingBaseForm.cs
Normal 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 {
|
||||||
|
}
|
||||||
|
}
|
|
@ -140,6 +140,9 @@
|
||||||
<Compile Include="Forms\ImageEditorForm.Designer.cs">
|
<Compile Include="Forms\ImageEditorForm.Designer.cs">
|
||||||
<DependentUpon>ImageEditorForm.cs</DependentUpon>
|
<DependentUpon>ImageEditorForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Forms\AnimatingBaseForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Forms\LanguageDialog.cs">
|
<Compile Include="Forms\LanguageDialog.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -186,6 +189,7 @@
|
||||||
<Compile Include="Helpers\CopyData.cs" />
|
<Compile Include="Helpers\CopyData.cs" />
|
||||||
<Compile Include="Helpers\GeometryHelper.cs" />
|
<Compile Include="Helpers\GeometryHelper.cs" />
|
||||||
<Compile Include="Helpers\DestinationHelper.cs" />
|
<Compile Include="Helpers\DestinationHelper.cs" />
|
||||||
|
<None Include="Helpers\HookHelper.cs" />
|
||||||
<Compile Include="Helpers\IECaptureHelper.cs" />
|
<Compile Include="Helpers\IECaptureHelper.cs" />
|
||||||
<Compile Include="Helpers\IEInterop\IEContainer.cs" />
|
<Compile Include="Helpers\IEInterop\IEContainer.cs" />
|
||||||
<Compile Include="Helpers\ProcessorHelper.cs" />
|
<Compile Include="Helpers\ProcessorHelper.cs" />
|
||||||
|
|
96
Greenshot/Helpers/HookHelper.cs
Normal file
96
Greenshot/Helpers/HookHelper.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -143,10 +143,10 @@ Root: HKCU; Subkey: Software\Microsoft\Windows\CurrentVersion\Run; ValueType: st
|
||||||
; HKEY_LOCAL_MACHINE - for all users
|
; 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
|
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
|
; Register our own filetype
|
||||||
;Root: HKCR; Subkey: ".gsb"; ValueType: string; ValueName: ""; ValueData: "GreenshotFile"; Flags: uninsdeletevalue
|
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"; 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\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: "GreenshotFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\Greenshot.EXE"" --openfile ""%1"""
|
||||||
[Icons]
|
[Icons]
|
||||||
Name: {group}\{#ExeName}; Filename: {app}\{#ExeName}.exe; WorkingDir: {app}
|
Name: {group}\{#ExeName}; Filename: {app}\{#ExeName}.exe; WorkingDir: {app}
|
||||||
Name: {group}\Uninstall {#ExeName}; Filename: {uninstallexe}; WorkingDir: {app}; AppUserModelID: "{#ExeName}.{#ExeName}"
|
Name: {group}\Uninstall {#ExeName}; Filename: {uninstallexe}; WorkingDir: {app}; AppUserModelID: "{#ExeName}.{#ExeName}"
|
||||||
|
|
|
@ -28,8 +28,7 @@ namespace GreenshotPlugin.Controls {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extend this Form to have the possibility for animations on your form
|
/// Extend this Form to have the possibility for animations on your form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AnimatingForm : Form {
|
public class AnimatingForm : GreenshotForm {
|
||||||
protected static CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
|
|
||||||
private int vRefresh = 0;
|
private int vRefresh = 0;
|
||||||
private Timer timer = null;
|
private Timer timer = null;
|
||||||
|
|
||||||
|
@ -111,6 +110,8 @@ namespace GreenshotPlugin.Controls {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method will be called every frame, so implement your animation/redraw logic here.
|
/// This method will be called every frame, so implement your animation/redraw logic here.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void Animate();
|
protected virtual void Animate() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
|
@ -30,8 +29,12 @@ using System.ComponentModel.Design;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace GreenshotPlugin.Controls {
|
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));
|
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 static IDictionary<Type, FieldInfo[]> reflectionCache = new Dictionary<Type, FieldInfo[]>();
|
||||||
private IComponentChangeService m_changeService;
|
private IComponentChangeService m_changeService;
|
||||||
private bool isDesignModeLanguageSet = false;
|
private bool isDesignModeLanguageSet = false;
|
||||||
|
@ -40,12 +43,31 @@ namespace GreenshotPlugin.Controls {
|
||||||
private IDictionary<string, Control> designTimeControls;
|
private IDictionary<string, Control> designTimeControls;
|
||||||
private IDictionary<string, ToolStripItem> designTimeToolStripItems;
|
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.")]
|
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
|
||||||
public string LanguageKey {
|
public string LanguageKey {
|
||||||
get;
|
get;
|
||||||
set;
|
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 {
|
protected bool ManualLanguageApply {
|
||||||
get {
|
get {
|
||||||
return applyLanguageManually;
|
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>
|
/// <summary>
|
||||||
/// Code to initialize the language etc during design time
|
/// Code to initialize the language etc during design time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue