Fix .xml loading

This commit is contained in:
Julien Richard 2023-11-11 19:01:40 +01:00
commit b12ace28e4
No known key found for this signature in database
4 changed files with 12 additions and 5 deletions

View file

@ -20,6 +20,7 @@
*/ */
using System; using System;
using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@ -265,6 +266,12 @@ namespace Greenshot.Base.Core
return exceptionText.ToString(); return exceptionText.ToString();
} }
/// <summary>
/// Returns the directory where the application is located
/// </summary>
public static string GetApplicationFolder()
=> Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
} }
/// <summary> /// <summary>

View file

@ -73,7 +73,7 @@ namespace Greenshot.Base.Core
try try
{ {
string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string applicationFolder = EnvironmentInfo.GetApplicationFolder();
// PAF Path // PAF Path
if (applicationFolder != null) if (applicationFolder != null)

View file

@ -21,9 +21,9 @@
using System; using System;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using Greenshot.Base.Core;
namespace Greenshot.Editor.Controls.Emoji namespace Greenshot.Editor.Controls.Emoji
{ {
@ -32,7 +32,7 @@ namespace Greenshot.Editor.Controls.Emoji
/// </summary> /// </summary>
public static class EmojiData public static class EmojiData
{ {
private const string EmojisXmlFilePath = "emojis.xml"; private static readonly string EmojisXmlFilePath = Path.Combine(EnvironmentInfo.GetApplicationFolder(), "emojis.xml");
public static Emojis Data { get; private set; } = new(); public static Emojis Data { get; private set; } = new();

View file

@ -24,6 +24,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Reflection; using System.Reflection;
using Greenshot.Base.Core;
using SixLabors.Fonts; using SixLabors.Fonts;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.Drawing.Processing;
@ -41,8 +42,7 @@ namespace Greenshot.Editor.Drawing.Emoji
private static readonly Lazy<FontFamily> TwemojiFontFamily = new(() => private static readonly Lazy<FontFamily> TwemojiFontFamily = new(() =>
{ {
var exeDirectory = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); var twemojiFontFile = Path.Combine(EnvironmentInfo.GetApplicationFolder(), "Twemoji.Mozilla.ttf");
var twemojiFontFile = Path.Combine(exeDirectory, "Twemoji.Mozilla.ttf");
if (!File.Exists(twemojiFontFile)) if (!File.Exists(twemojiFontFile))
{ {
throw new FileNotFoundException($"Can't find {twemojiFontFile}, bad installation?"); throw new FileNotFoundException($"Can't find {twemojiFontFile}, bad installation?");