Merges from Branch 0.8

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@789 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2010-08-06 18:33:56 +00:00
commit b6e44aae1e
7 changed files with 169 additions and 83 deletions

View file

@ -60,42 +60,51 @@ namespace Greenshot {
Thread.CurrentThread.Name = Application.ProductName;
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
// Setup log4j, currently the file is called log4net.xml
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
if (File.Exists(log4netFilename)) {
log4net.Config.XmlConfigurator.Configure(new FileInfo(log4netFilename));
} else {
MessageBox.Show("Can't find file " + LOG4NET_FILE);
}
// Setup the LOG
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
// Setup log4j, currently the file is called log4net.xml
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
if (File.Exists(log4netFilename)) {
log4net.Config.XmlConfigurator.Configure(new FileInfo(log4netFilename));
} else {
MessageBox.Show("Can't find file " + LOG4NET_FILE);
}
// Setup the LOG
LOG = log4net.LogManager.GetLogger(typeof(MainForm));
// Log the startup
LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false));
try {
// Fix for Bug 2495900, Multi-user Environment
// check whether there's an local instance running already
// 1) Create Mutex
try {
applicationMutex = new Mutex(false, @"Local\F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08");
// 2) Get the right to it, this returns false if it's already locked
// 1) Create Mutex
applicationMutex = new Mutex(false, @"Local\F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08");
// 2) Get the right to it, this returns false if it's already locked
if (!applicationMutex.WaitOne(0, false)) {
isAlreadyRunning = true;
isAlreadyRunning = true;
}
} catch (Exception e) {
LOG.Error("Can't create Mutex, for now we assume it's already there.", e);
isAlreadyRunning = true;
}
if (args.Length > 0 && LOG.IsDebugEnabled) {
StringBuilder argumentString = new StringBuilder();
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
argumentString.Append("[").Append(args[argumentNr]).Append("] ");
}
LOG.Debug("Greenshot arguments: " + argumentString.ToString());
}
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
string argument = args[argumentNr];
// Help
if (argument.Equals("--help")) {
if (argument.ToLower().Equals("/help")) {
// Try to attach to the console
bool attachedToConsole = User32.AttachConsole(User32.ATTACH_PARENT_PROCESS);
// If attach didn't work, open a console
@ -104,7 +113,7 @@ namespace Greenshot {
}
StringBuilder helpOutput = new StringBuilder();
helpOutput.AppendLine();
if (argumentNr + 1 < args.Length && args[argumentNr + 1].Equals("configure")) {
if (argumentNr + 1 < args.Length && args[argumentNr + 1].ToLower().Equals("configure")) {
helpOutput.AppendLine("Available configuration settings:");
Properties properties = AppConfig.GetAvailableProperties();
@ -115,32 +124,32 @@ namespace Greenshot {
helpOutput.AppendLine("Greenshot commandline options:");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--help");
helpOutput.AppendLine("\t/help");
helpOutput.AppendLine("\t\tThis help.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--help configure");
helpOutput.AppendLine("\t/help configure");
helpOutput.AppendLine("\t\tA detailed listing of available settings for the configure command.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--exit");
helpOutput.AppendLine("\t/exit");
helpOutput.AppendLine("\t\tTries to close all running instances.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--configure [property=value] ...");
helpOutput.AppendLine("\t/configure [property=value] [property=value] ...");
helpOutput.AppendLine("\t\tChange the configuration of Greenshot via the commandline.");
helpOutput.AppendLine("\t\tExample to change the language to English: greenshot.exe --configure Ui_Language=en-US");
helpOutput.AppendLine("\t\tExample to change the destination: greenshot.exe --configure Output_File_Path=\"C:\\Documents and Settings\\\"");
helpOutput.AppendLine("\t\tExample to change the language to English: greenshot.exe /configure Ui_Language=en-US");
helpOutput.AppendLine("\t\tExample to change the destination: greenshot.exe /configure Output_File_Path=\"C:\\Documents and Settings\\\"");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--openfile [filename]");
helpOutput.AppendLine("\t/openfile [filename]");
helpOutput.AppendLine("\t\tOpen the bitmap file in the running Greenshot instance or start a new instance");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t--norun");
helpOutput.AppendLine("\t/norun");
helpOutput.AppendLine("\t\tCan be used if someone only wants to change the configuration.");
helpOutput.AppendLine("\t\tAs soon as this option is found Greenshot exits if not and there is no running instance it will stay running.");
helpOutput.AppendLine("\t\tExample: greenshot.exe --configure Output_File_Path=\"C:\\Documents and Settings\\\" --exit");
helpOutput.AppendLine("\t\tExample: greenshot.exe /configure Output_File_Path=\"C:\\Documents and Settings\\\" --exit");
}
Console.WriteLine(helpOutput.ToString());
@ -153,7 +162,7 @@ namespace Greenshot {
}
// exit application
if (argument.Equals("--exit")) {
if (argument.ToLower().Equals("/exit")) {
try {
LOG.Info("Sending all instances the exit command.");
// Pass Exit to running instance, if any
@ -166,7 +175,7 @@ namespace Greenshot {
}
// Modify configuration
if (argument.Equals("--configure")) {
if (argument.ToLower().Equals("/configure")) {
LOG.Debug("Setting configuration!");
conf = AppConfig.GetInstance();
Properties properties = new Properties();
@ -191,12 +200,12 @@ namespace Greenshot {
}
// Make an exit possible
if (argument.Equals("--norun")) {
if (argument.ToLower().Equals("/norun")) {
FreeMutex();
return;
}
return;
}
if (argument.Equals("--openfile")) {
if (argument.ToLower().Equals("/openfile")) {
string filename = args[++argumentNr];
filesToOpen.Add(filename);
}
@ -360,7 +369,7 @@ namespace Greenshot {
}
}
}
public ContextMenuStrip MainMenu {
get {return contextMenu;}
}
@ -405,12 +414,11 @@ namespace Greenshot {
instance = null;
exit();
}
void MainFormActivated(object sender, EventArgs e) {
Hide();
ShowInTaskbar = false;
}
#endregion
#region key handlers
@ -502,7 +510,7 @@ namespace Greenshot {
}
void Contextmenu_exitClick(object sender, EventArgs e) {
exit();
Application.Exit();
}
private void InitializeQuickSettingsMenu() {
@ -644,7 +652,7 @@ namespace Greenshot {
}
// Remove the application mutex
FreeMutex();
// make the icon invisible otherwise it stays even after exit!!
if (notifyIcon != null) {
notifyIcon.Visible = false;

View file

@ -8,57 +8,57 @@ This will even work when Greenshot is already running!
Greenshot commandline options:
--help
/help
This help
--help configure
/help configure
A list of the options that can be set
--exit
/exit
Try to close all running instances, could be used for installers
--configure [property=value] ...
/configure [property=value] ...
Change the configuration of Greenshot via the commandline, multiple properties can be specified after each other.
Example to change the language to English: greenshot.exe --configure Ui_Language=en-US
Example to change the destination: greenshot.exe --configure Output_File_Path="C:\Documents and Settings\"
Example to change the language to English: greenshot.exe /configure Ui_Language=en-US
Example to change the destination: greenshot.exe /configure Output_File_Path="C:\Documents and Settings\"
--openfile [filename]
/openfile [filename]
Open the bitmap file in the running Greenshot instance or start a new instance
--norun
/norun
Use as last option if you don't want the started executable to spawn a Greenshot instance.
e.g. when you only want to change settings but don't want to have a running Greenshot afterwards.
With the --configure option many settings can be change, the --help configure will give a list of all available settings!
With the /configure option many settings can be change, the /help configure will give a list of all available settings!
Here are some described in detail:
General_RegisterHotkeys=Boolean
This setting specified if the hotkeys will be registed, can be used to let Greenshot run side by side with other applications.
All functions are than only available via the context menu of the Systray icon.
Default is true.
Example to change: greenshot.exe --configure General_RegisterHotkeys=false
Example to change: greenshot.exe /configure General_RegisterHotkeys=false
General_IsFirstLaunch=Boolean
This setting is actually for Greenshot internal usage, it specifies if someone already has used Greenshot or if it is the first start.
If this is true Greenshot will show a balloon at the Systray Icon.
Default is true, will be false after the first start.
Example to change: greenshot.exe --configure General_IsFirstLaunch=false
Example to change: greenshot.exe /configure General_IsFirstLaunch=false
Capture_Mousepointer=Boolean
This setting, which is available in the settings window, specifies if Greenshot will capture the mouse cursor.
Default is true.
Example to change: greenshot.exe --configure Capture_Mousepointer=false
Example to change: greenshot.exe /configure Capture_Mousepointer=false
Capture_Windows_Interactive=Boolean
This setting, which is available in the settings window, specifies if Greenshot will capture the current active window or will make it possible for the user to select a window with the mouse.
Default is false.
Example to change: greenshot.exe --configure Capture_Windows_Interactive=true
Example to change: greenshot.exe /configure Capture_Windows_Interactive=true
Capture_Wait_Time=Int32
This setting, which is available in the settings window, specifies how many milliseconds Greenshot will wait after the capture is started.
Usually there is no need to change this setting, but sometimes it might help with refresh problems and the captured picture is not what is expected.
Default is 100.
Example to change: greenshot.exe --configure Capture_Wait_Time=300
Example to change: greenshot.exe /configure Capture_Wait_Time=300
Ui_Language=String
This setting, which is available in the settings window, specifies the used language.
@ -66,66 +66,67 @@ Languages should be set with their full "IETF" code, like "de-DE", "en-US" or "e
The available language should be installed, otherwise a fallback at "en-US" will be made.
It's also possible to specify only the first characters, like "en" for English, but there is no garantee what "variant" will be used.
Default is the language selected in the installer.
Example to change: greenshot.exe --configure Ui_Language=en-US
Example to change: greenshot.exe /configure Ui_Language=en-US
Ui_Effects_Flashlight=Boolean
This setting, which is available in the settings window, specifies if the "flashlight" effect is shown after each capture.
Default is false.
Example to change: greenshot.exe --configure Ui_Effects_Flashlight=true
Example to change: greenshot.exe /configure Ui_Effects_Flashlight=true
Ui_Effects_CameraSound=Boolean
This setting, which is available in the settings window, specifies if the camera sound is played after each capture.
Default is true.
Example to change: greenshot.exe --configure Ui_Effects_CameraSound=false
Example to change: greenshot.exe /configure Ui_Effects_CameraSound=false
Output_File_Path=String
This setting, which is available in the settings window, specifies the default location for all captures.
Default is the users desktop.
Example to change: greenshot.exe --configure Output_File_Path="C:\Documents and Settings\"
Example to change: greenshot.exe /configure Output_File_Path="C:\Documents and Settings\"
Output_File_FilenamePattern=String
This setting, which is available in the settings window, specifies the default filename pattern.
Default is "%title%_%YYYY%-%MM%-%DD%_%hh%-%mm%-%ss%".
Example to change: greenshot.exe --configure Output_File_FilenamePattern="%hostname%\%user%\%title%-%NUM%"
Example to change: greenshot.exe /configure Output_File_FilenamePattern="%hostname%\%user%\%title%-%NUM%"
Output_File_Format=String
This setting, which is available in the settings window, specifies the default file type.
Default is "Png", available formats are: "Bmp", "Jpeg", "Gif" and "Png"
Example to change: greenshot.exe --configure Output_File_Format=Gif
Example to change: greenshot.exe /configure Output_File_Format=Gif
Output_File_CopyPathToClipboard=Boolean
This setting, which is available in the settings window, specifies if the path of the written file will be pasted to the clipboard.
Default is false
Example to change: greenshot.exe --configure Output_File_CopyPathToClipboard=true
Example to change: greenshot.exe /configure Output_File_CopyPathToClipboard=true
Output_File_JpegQuality=Int32
This setting, which is available in the settings window, specifies the quality for the files that are written as Jpeg.
Default is 80
Example to change: greenshot.exe --configure Output_File_JpegQuality=50
Example to change: greenshot.exe /configure Output_File_JpegQuality=50
Output_File_PromptJpegQuality=Boolean
This setting, which is available in the settings window, specifies if the Jpeg settings should be asked at every save.
Default is false
Example to change: greenshot.exe --configure Output_File_PromptJpegQuality=true
Example to change: greenshot.exe /configure Output_File_PromptJpegQuality=true
Output_File_IncrementingNumber=Int32
This setting specifies the number which is used in the filename pattern as "%NUM%".
Default is 0, will increment at every save.
Example to change: greenshot.exe --configure Output_File_IncrementingNumber=10
Example to change: greenshot.exe /configure Output_File_IncrementingNumber=10
Output_FileAs_Fullpath=String
This setting specifies the location of the last saved file, used when the "save" option is selected.
Default is "desktop\dummy.png", will change at every save. Can't think of a reason to set it...
Example to change: greenshot.exe --configure Output_FileAs_Fullpath="C:\tmp\greenshot.png"
Example to change: greenshot.exe /configure Output_FileAs_Fullpath="C:\tmp\greenshot.png"
Editor_WindowState=String
This setting specifies the state the Greenshot Image Editor opens, used internally for making the Editor open at the same location as it was closed.
Default is empty, the setting is changed at every window close. Possible settings: "Normal" or "Maximized".
Example to change: greenshot.exe /configure Editor_WindowState=Maximized
Finally there are multiple Printer options which should explain themselves:
Output_Print_PromptOptions=Boolean
Output_Print_AllowRotate=Boolean
Output_Print_AllowEnlarge=Boolean
Output_Print_AllowShrink=Boolean
Output_Print_Center=Boolean
Output_Print_Timestamp=Boolean
Editor_WindowState=String
This setting specifies the state the Greenshot Image Editor opens, used internally for making the Editor open at the same location as it was closed.
Default is empty, the setting is changed at every window close. Possible settings: "Normal" or "Maximized".
Example to change: greenshot.exe --configure Editor_WindowState=Maximized

View file

@ -2,17 +2,26 @@
[CustomMessages]
de.dotnetfx20lp_title=.NET Framework 2.0 Sprachpaket: Deutsch
nl.dotnetfx20lp_title=
en.dotnetfx20lp_title=
de.dotnetfx20lp_size=1,8 MB
dotnetfx20lp_size=1,8 MB
;http://www.microsoft.com/globaldev/reference/lcid-all.mspx
de.dotnetfx20lp_lcid=1031
dotnetfx20lp_lcid=1031
nl.dotnetfx20lp_url=
nl.dotnetfx20lp_url_x64=
nl.dotnetfx20lp_url_ia64=
en.dotnetfx20lp_url=
en.dotnetfx20lp_url_x64=
en.dotnetfx20lp_url_ia64=
de.dotnetfx20lp_url=http://download.microsoft.com/download/2/9/7/29768238-56c3-4ea6-abba-4c5246f2bc81/langpack.exe
de.dotnetfx20lp_url_x64=http://download.microsoft.com/download/2/e/f/2ef250ba-a868-4074-a4c9-249004866f87/langpack.exe
de.dotnetfx20lp_url_ia64=http://download.microsoft.com/download/8/9/8/898c5670-5e74-41c4-82fc-68dd837af627/langpack.exe
[Code]
procedure dotnetfx20lp();
var

View file

@ -1,18 +1,27 @@
//http://www.microsoft.com/downloads/details.aspx?FamilyID=1cc39ffe-a2aa-4548-91b3-855a2de99304
[CustomMessages]
nl.dotnetfx20sp1lp_title=.NET Framework 2.0 SP1 Taalpakket: Nederlands
de.dotnetfx20sp1lp_title=.NET Framework 2.0 SP1 Sprachpaket: Deutsch
en.dotnetfx20sp1lp_title=
de.dotnetfx20sp1lp_size=3,4 MB
dotnetfx20sp1lp_size=3,4 MB
;http://www.microsoft.com/globaldev/reference/lcid-all.mspx
de.dotnetfx20sp1lp_lcid=1031
dotnetfx20sp1lp_lcid=1031
nl.dotnetfx20sp1lp_url=http://download.microsoft.com/download/1/5/d/15de28a3-f1d1-459f-9583-d168cfa05e3f/NetFx20SP1_x86nl.exe
nl.dotnetfx20sp1lp_url_x64=
nl.dotnetfx20sp1lp_url_ia64=
en.dotnetfx20sp1lp_url=
en.dotnetfx20sp1lp_url_x64=
en.dotnetfx20sp1lp_url_ia64=
de.dotnetfx20sp1lp_url=http://download.microsoft.com/download/8/a/a/8aab7e6a-5e58-4e83-be99-f5fb49fe811e/NetFx20SP1_x86de.exe
de.dotnetfx20sp1lp_url_x64=http://download.microsoft.com/download/1/4/2/1425872f-c564-4ab2-8c9e-344afdaecd44/NetFx20SP1_x64de.exe
de.dotnetfx20sp1lp_url_ia64=http://download.microsoft.com/download/a/0/b/a0bef431-19d8-433c-9f42-6e2824a8cb90/NetFx20SP1_ia64de.exe
[Code]
procedure dotnetfx20sp1lp();
var

View file

@ -1,12 +1,22 @@
//http://www.microsoft.com/downloads/details.aspx?FamilyID=c69789e0-a4fa-4b2e-a6b5-3b3695825992
[CustomMessages]
nl.dotnetfx20sp2lp_title=.NET Framework 2.0 SP2 Taalpakket: Nederlands
de.dotnetfx20sp2lp_title=.NET Framework 2.0 SP2 Sprachpaket: Deutsch
en.dotnetfx20sp2lp_title=
de.dotnetfx20sp2lp_size=3,4 MB
dotnetfx20sp2lp_size=3,4 MB
;http://www.microsoft.com/globaldev/reference/lcid-all.mspx
de.dotnetfx20sp2lp_lcid=1031
dotnetfx20sp2lp_lcid=1031
en.dotnetfx20sp2lp_url=
en.dotnetfx20sp2lp_url_x64=
en.dotnetfx20sp2lp_url_ia64=
nl.dotnetfx20sp2lp_url=http://download.microsoft.com/download/7/a/5/7a5ca52b-08ac-40f5-9a6d-6cce78b1db28/NetFx20SP2_x86nl.exe
nl.dotnetfx20sp2lp_url_x64=
nl.dotnetfx20sp2lp_url_ia64=
de.dotnetfx20sp2lp_url=http://download.microsoft.com/download/0/b/1/0b175c8e-34bd-46c0-bfcd-af8d33770c58/netfx20sp2_x86de.exe
de.dotnetfx20sp2lp_url_x64=http://download.microsoft.com/download/4/e/c/4ec67a11-879d-4550-9c25-fd9ab4261b46/netfx20sp2_x64de.exe

View file

@ -1,9 +1,6 @@
#define ExeName "Greenshot"
#define Version "0.9.0.$WCREV$"
; Mutex is no longer needed!
;#define Mutex "F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08"
; Include the scripts to install .NET Framework 2.0
; See http://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx
#include "scripts\products.iss"
@ -160,6 +157,59 @@ begin
ProductNextButtonClick(CurPage);
end;
// Build a list of greenshot parameters from the supplied installer parameters
function GetParamsForGS(argument: String): String;
var
i: Integer;
parametersString: String;
currentParameter: String;
equalsSignPos: Integer;
foundStart: Boolean;
foundNoRun: Boolean;
foundLanguage: Boolean;
begin
foundNoRun := false;
foundLanguage := false;
foundStart := false;
for i:= 0 to ParamCount() do begin
currentParameter := ParamStr(i);
// check if norun is supplied
if Lowercase(currentParameter) = '/norun' then begin
foundNoRun := true;
continue;
end;
if foundStart then begin
equalsSignPos := Pos('=', currentParameter);
if equalsSignPos > 0 then begin
if Pos('Ui_Language', currentParameter) > 0 then begin
// Was language supplied?
foundLanguage := true;
end;
// Make sure the parameter is in quotes
Insert('"', currentParameter, equalsSignPos + 1);
parametersString := parametersString + ' ' + currentParameter + '"';
end;
end
else begin
if Lowercase(currentParameter) = '/configure' then begin
foundStart := true;
end;
end;
end;
if not foundLanguage then begin
parametersString := parametersString + ' Ui_Language=' + ExpandConstant('{language}');
end;
if foundNoRun then begin
parametersString := parametersString + ' /norun';
end;
// For debugging comment out the following
//MsgBox(parametersString, mbInformation, MB_OK);
Result := parametersString;
end;
function InitializeSetup(): Boolean;
begin
// Enhance installer otherwise .NET installations won't work
@ -204,8 +254,6 @@ begin
UnloadDLL(ExpandConstant('{app}\IssProc.dll'));
end;
[Run]
Filename: {app}\{#ExeName}.exe; Description: {cm:startgreenshot}; Parameters: --configure Ui_Language={language}; WorkingDir: {app}; Flags: nowait postinstall runasoriginaluser
Filename: {app}\{#ExeName}.exe; Description: {cm:startgreenshot}; Parameters: /configure {code:GetParamsForGS}; WorkingDir: {app}; Flags: nowait postinstall runasoriginaluser
[InstallDelete]
Name: {app}; Type: filesandordirs; Languages:
Name: {userstartup}\{#ExeName}.lnk; Type: files; Languages:
Name: {commonstartup}\{#ExeName}.lnk; Type: files; Languages:
Name: {app}; Type: filesandordirs;

View file

@ -196,6 +196,7 @@ namespace Greenshot {
this.combobox_language.Name = "combobox_language";
this.combobox_language.Size = new System.Drawing.Size(213, 21);
this.combobox_language.TabIndex = 0;
this.combobox_language.MaxDropDownItems = 15;
//
// combobox_primaryimageformat
//