mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Added logic which forces the greenshot.ini to be created in the startup-path (where the executable is) when there is no log4net.xml available. This is useful when someone just wants to use the greenshot.exe
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1607 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
89c2b7a9e7
commit
83570e855b
4 changed files with 28 additions and 5 deletions
|
@ -145,7 +145,7 @@ namespace Greenshot {
|
|||
helpOutput.AppendLine();
|
||||
helpOutput.AppendLine();
|
||||
helpOutput.AppendLine("\t/language [language code]");
|
||||
helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-EN.");
|
||||
helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-US.");
|
||||
helpOutput.AppendLine();
|
||||
helpOutput.AppendLine();
|
||||
helpOutput.AppendLine("\t[filename]");
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
[IniSection("Core", Description="Greenshot core configuration")]
|
||||
public class CoreConfiguration : IniSection {
|
||||
[IniProperty("Language", Description="The language in IETF format (e.g. en-EN)")]
|
||||
[IniProperty("Language", Description="The language in IETF format (e.g. en-US)")]
|
||||
public string Language;
|
||||
|
||||
[IniProperty("RegionHotkey", Description="Hotkey for starting the region capture", DefaultValue="PrintScreen")]
|
||||
|
|
|
@ -23,6 +23,7 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using IniFile;
|
||||
using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Config;
|
||||
|
@ -58,6 +59,7 @@ namespace GreenshotPlugin.Core {
|
|||
using (Stream stream = assem.GetManifestResourceStream("GreenshotPlugin.log4net-embedded.xml")) {
|
||||
XmlConfigurator.Configure(stream);
|
||||
isLog4NetConfigured = true;
|
||||
IniConfig.ForceIniInStartupPath();
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace IniFile {
|
|||
return portable;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the ini config
|
||||
/// </summary>
|
||||
|
@ -60,6 +61,24 @@ namespace IniFile {
|
|||
WatchConfigFile(true);
|
||||
}
|
||||
|
||||
public static void ForceIniInStartupPath() {
|
||||
if (portableCheckMade) {
|
||||
throw new Exception("ForceLocal should be called before any file is read");
|
||||
}
|
||||
portable = false;
|
||||
portableCheckMade = true;
|
||||
string applicationStartupPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
if (applicationName == null || configName == null) {
|
||||
Init();
|
||||
}
|
||||
string forcedIni = Path.Combine(applicationStartupPath, applicationName + INI_EXTENSION);
|
||||
if (!File.Exists(forcedIni)) {
|
||||
using (File.Create(forcedIni)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default init
|
||||
/// </summary>
|
||||
|
@ -87,7 +106,7 @@ namespace IniFile {
|
|||
// Monitor the ini file
|
||||
watcher = new FileSystemWatcher();
|
||||
watcher.Path = Path.GetDirectoryName(iniLocation);
|
||||
watcher.Filter = "*.ini";
|
||||
watcher.Filter = "greenshot.ini";
|
||||
watcher.NotifyFilter = NotifyFilters.LastWrite;
|
||||
watcher.Changed += new FileSystemEventHandler(ConfigFileChanged);
|
||||
}
|
||||
|
@ -158,7 +177,9 @@ namespace IniFile {
|
|||
if (portable) {
|
||||
string pafConfigPath = Path.Combine(applicationStartupPath, @"Data\Settings");
|
||||
try {
|
||||
Directory.CreateDirectory(pafConfigPath);
|
||||
if (!Directory.Exists(pafConfigPath)) {
|
||||
Directory.CreateDirectory(pafConfigPath);
|
||||
}
|
||||
iniFilePath = Path.Combine(pafConfigPath, configFilename);
|
||||
} catch(Exception e) {
|
||||
LOG.InfoFormat("Portable mode NOT possible, couldn't create directory '{0}'! Reason: {1}", pafConfigPath, e.Message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue