mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Making the initial stuff working, getting an installer, when running from VS.
This commit is contained in:
parent
a63bf734d4
commit
57e2044839
1023 changed files with 20896 additions and 19456 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
|
@ -264,8 +264,8 @@ namespace Greenshot.IniFile {
|
|||
{
|
||||
return;
|
||||
}
|
||||
IDictionary<string, string> fixedPropertiesForSection;
|
||||
if (!_fixedProperties.TryGetValue(section.IniSectionAttribute.Name, out fixedPropertiesForSection))
|
||||
|
||||
if (!_fixedProperties.TryGetValue(section.IniSectionAttribute.Name, out var fixedPropertiesForSection))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -326,8 +326,7 @@ namespace Greenshot.IniFile {
|
|||
/// <param name="sectionName"></param>
|
||||
/// <returns></returns>
|
||||
public static IniSection GetIniSection(string sectionName) {
|
||||
IniSection returnValue;
|
||||
SectionMap.TryGetValue(sectionName, out returnValue);
|
||||
SectionMap.TryGetValue(sectionName, out var returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
@ -426,41 +425,39 @@ namespace Greenshot.IniFile {
|
|||
{
|
||||
Directory.CreateDirectory(iniPath);
|
||||
}
|
||||
using (var memoryStream = new MemoryStream()) {
|
||||
using (TextWriter writer = new StreamWriter(memoryStream, Encoding.UTF8)) {
|
||||
foreach (var section in SectionMap.Values) {
|
||||
section.Write(writer, false);
|
||||
// Add empty line after section
|
||||
writer.WriteLine();
|
||||
section.IsDirty = false;
|
||||
}
|
||||
writer.WriteLine();
|
||||
// Write left over properties
|
||||
foreach (string sectionName in _sections.Keys) {
|
||||
// Check if the section is one that is "registered", if so skip it!
|
||||
if (SectionMap.ContainsKey(sectionName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writer.WriteLine("; The section {0} hasn't been 'claimed' since the last start of Greenshot, therefor it doesn't have additional information here!", sectionName);
|
||||
writer.WriteLine("; The reason could be that the section {0} just hasn't been used, a plugin has an error and can't claim it or maybe the whole section {0} is obsolete.", sectionName);
|
||||
// Write section name
|
||||
writer.WriteLine("[{0}]", sectionName);
|
||||
var properties = _sections[sectionName];
|
||||
// Loop and write properties
|
||||
foreach (string propertyName in properties.Keys) {
|
||||
writer.WriteLine("{0}={1}", propertyName, properties[propertyName]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
// Don't forget to flush the buffer
|
||||
writer.Flush();
|
||||
// Now write the created .ini string to the real file
|
||||
using (FileStream fileStream = new FileStream(iniLocation, FileMode.Create, FileAccess.Write)) {
|
||||
memoryStream.WriteTo(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using var memoryStream = new MemoryStream();
|
||||
using TextWriter writer = new StreamWriter(memoryStream, Encoding.UTF8);
|
||||
foreach (var section in SectionMap.Values) {
|
||||
section.Write(writer, false);
|
||||
// Add empty line after section
|
||||
writer.WriteLine();
|
||||
section.IsDirty = false;
|
||||
}
|
||||
writer.WriteLine();
|
||||
// Write left over properties
|
||||
foreach (string sectionName in _sections.Keys) {
|
||||
// Check if the section is one that is "registered", if so skip it!
|
||||
if (SectionMap.ContainsKey(sectionName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writer.WriteLine("; The section {0} hasn't been 'claimed' since the last start of Greenshot, therefor it doesn't have additional information here!", sectionName);
|
||||
writer.WriteLine("; The reason could be that the section {0} just hasn't been used, a plugin has an error and can't claim it or maybe the whole section {0} is obsolete.", sectionName);
|
||||
// Write section name
|
||||
writer.WriteLine("[{0}]", sectionName);
|
||||
var properties = _sections[sectionName];
|
||||
// Loop and write properties
|
||||
foreach (string propertyName in properties.Keys) {
|
||||
writer.WriteLine("{0}={1}", propertyName, properties[propertyName]);
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
// Don't forget to flush the buffer
|
||||
writer.Flush();
|
||||
// Now write the created .ini string to the real file
|
||||
using FileStream fileStream = new FileStream(iniLocation, FileMode.Create, FileAccess.Write);
|
||||
memoryStream.WriteTo(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
|
@ -41,39 +41,39 @@ namespace Greenshot.IniFile {
|
|||
/// <returns></returns>
|
||||
public static IDictionary<string, IDictionary<string, string>> Read(string path, Encoding encoding) {
|
||||
var ini = new Dictionary<string, IDictionary<string, string>>();
|
||||
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1024)) {
|
||||
using (var streamReader = new StreamReader(fileStream, encoding)) {
|
||||
IDictionary<string, string> nameValues = new Dictionary<string, string>();
|
||||
while (!streamReader.EndOfStream) {
|
||||
string line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string cleanLine = line.Trim();
|
||||
if (cleanLine.Length == 0 || cleanLine.StartsWith(Comment)) {
|
||||
continue;
|
||||
}
|
||||
if (cleanLine.StartsWith(SectionStart)) {
|
||||
string section = line.Replace(SectionStart, string.Empty).Replace(SectionEnd, string.Empty).Trim();
|
||||
if (!ini.TryGetValue(section, out nameValues))
|
||||
{
|
||||
nameValues = new Dictionary<string, string>();
|
||||
ini.Add(section, nameValues);
|
||||
}
|
||||
} else {
|
||||
string[] keyvalueSplitter = line.Split(Assignment, 2);
|
||||
string name = keyvalueSplitter[0];
|
||||
string inivalue = keyvalueSplitter.Length > 1 ? keyvalueSplitter[1] : null;
|
||||
if (nameValues.ContainsKey(name)) {
|
||||
nameValues[name] = inivalue;
|
||||
} else {
|
||||
nameValues.Add(name, inivalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1024))
|
||||
{
|
||||
using var streamReader = new StreamReader(fileStream, encoding);
|
||||
IDictionary<string, string> nameValues = new Dictionary<string, string>();
|
||||
while (!streamReader.EndOfStream) {
|
||||
string line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string cleanLine = line.Trim();
|
||||
if (cleanLine.Length == 0 || cleanLine.StartsWith(Comment)) {
|
||||
continue;
|
||||
}
|
||||
if (cleanLine.StartsWith(SectionStart)) {
|
||||
string section = line.Replace(SectionStart, string.Empty).Replace(SectionEnd, string.Empty).Trim();
|
||||
if (!ini.TryGetValue(section, out nameValues))
|
||||
{
|
||||
nameValues = new Dictionary<string, string>();
|
||||
ini.Add(section, nameValues);
|
||||
}
|
||||
} else {
|
||||
string[] keyvalueSplitter = line.Split(Assignment, 2);
|
||||
string name = keyvalueSplitter[0];
|
||||
string inivalue = keyvalueSplitter.Length > 1 ? keyvalueSplitter[1] : null;
|
||||
if (nameValues.ContainsKey(name)) {
|
||||
nameValues[name] = inivalue;
|
||||
} else {
|
||||
nameValues.Add(name, inivalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ini;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
|
@ -147,8 +147,7 @@ namespace Greenshot.IniFile {
|
|||
try {
|
||||
iniValue.SetValueFromProperties(properties);
|
||||
if (iniValue.Attributes.Encrypted) {
|
||||
string stringValue = iniValue.Value as string;
|
||||
if (stringValue != null && stringValue.Length > 2) {
|
||||
if (iniValue.Value is string stringValue && stringValue.Length > 2) {
|
||||
iniValue.Value = stringValue.Decrypt();
|
||||
}
|
||||
}
|
||||
|
@ -178,16 +177,14 @@ namespace Greenshot.IniFile {
|
|||
|
||||
foreach (IniValue value in Values.Values) {
|
||||
if (value.Attributes.Encrypted) {
|
||||
string stringValue = value.Value as string;
|
||||
if (stringValue != null && stringValue.Length > 2) {
|
||||
if (value.Value is string stringValue && stringValue.Length > 2) {
|
||||
value.Value = stringValue.Encrypt();
|
||||
}
|
||||
}
|
||||
// Write the value
|
||||
value.Write(writer, onlyProperties);
|
||||
if (value.Attributes.Encrypted) {
|
||||
string stringValue = value.Value as string;
|
||||
if (stringValue != null && stringValue.Length > 2) {
|
||||
if (value.Value is string stringValue && stringValue.Length > 2) {
|
||||
value.Value = stringValue.Decrypt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue