mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Merge branch 'master' into tweaks
This commit is contained in:
commit
162badae3b
58 changed files with 1232 additions and 318 deletions
|
@ -23,11 +23,11 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Channels.Ipc;
|
||||
using System.Security.Permissions;
|
||||
using System.Threading;
|
||||
|
||||
namespace ShareX.HelpersLib
|
||||
|
@ -36,15 +36,15 @@ public class ApplicationInstanceManager : IDisposable
|
|||
{
|
||||
private static readonly string MutexName = "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC";
|
||||
private static readonly string AppName = "ShareX";
|
||||
private static readonly string PipeName = $"{Environment.MachineName}-{Environment.UserName}-{AppName}";
|
||||
private static readonly string SemaphoreName = PipeName + "Semaphore";
|
||||
private static readonly string EventName = string.Format("{0}-{1}-{2}", Environment.MachineName, Environment.UserName, AppName);
|
||||
private static readonly string SemaphoreName = string.Format("{0}{1}", EventName, "Semaphore");
|
||||
|
||||
public bool IsSingleInstance { get; private set; }
|
||||
public bool IsFirstInstance { get; private set; }
|
||||
|
||||
private Mutex mutex;
|
||||
private Semaphore semaphore;
|
||||
private NamedPipeServerStream pipeServer;
|
||||
private IpcServerChannel serverChannel;
|
||||
|
||||
public ApplicationInstanceManager(bool isSingleInstance, string[] args, EventHandler<InstanceCallbackEventArgs> callback)
|
||||
{
|
||||
|
@ -74,29 +74,45 @@ public ApplicationInstanceManager(bool isSingleInstance, string[] args, EventHan
|
|||
public void Dispose()
|
||||
{
|
||||
if (IsFirstInstance)
|
||||
{
|
||||
if (mutex != null)
|
||||
{
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
|
||||
mutex.Dispose();
|
||||
semaphore?.Dispose();
|
||||
pipeServer?.Dispose();
|
||||
if (serverChannel != null)
|
||||
{
|
||||
ChannelServices.UnregisterChannel(serverChannel);
|
||||
}
|
||||
|
||||
if (semaphore != null)
|
||||
{
|
||||
semaphore.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateFirstInstance(EventHandler<InstanceCallbackEventArgs> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
semaphore = new Semaphore(1, 1, SemaphoreName, out var createdNew);
|
||||
bool createdNew;
|
||||
|
||||
using (EventWaitHandle eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, EventName, out createdNew))
|
||||
{
|
||||
// Mixing single instance and multi instance (via command line parameter) copies of the program can
|
||||
// result in CreateFirstInstance being called if it isn't really the first one. Make sure this is
|
||||
// really first instance by detecting if the semaphore was created
|
||||
// really first instance by detecting if EventWaitHandle was created
|
||||
if (!createdNew)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CreateServer(callback);
|
||||
semaphore = new Semaphore(1, 1, SemaphoreName);
|
||||
ThreadPool.RegisterWaitForSingleObject(eventWaitHandle, WaitOrTimerCallback, callback, Timeout.Infinite, false);
|
||||
|
||||
RegisterRemoteType(AppName);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -108,11 +124,19 @@ private void CreateMultipleInstance(string[] args)
|
|||
{
|
||||
try
|
||||
{
|
||||
semaphore = Semaphore.OpenExisting(SemaphoreName);
|
||||
InstanceProxy.CommandLineArgs = args;
|
||||
|
||||
// Wait until the server is ready to accept data
|
||||
using (EventWaitHandle eventWaitHandle = EventWaitHandle.OpenExisting(EventName))
|
||||
{
|
||||
semaphore = Semaphore.OpenExisting(SemaphoreName);
|
||||
semaphore.WaitOne();
|
||||
SendDataToServer(args);
|
||||
UpdateRemoteObject(AppName);
|
||||
|
||||
if (eventWaitHandle != null)
|
||||
{
|
||||
eventWaitHandle.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -122,67 +146,69 @@ private void CreateMultipleInstance(string[] args)
|
|||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void SendDataToServer(string[] args)
|
||||
private void UpdateRemoteObject(string uri)
|
||||
{
|
||||
using (var pipeClient = new NamedPipeClientStream(".", PipeName, PipeDirection.Out))
|
||||
{
|
||||
pipeClient.Connect();
|
||||
IpcClientChannel clientChannel = new IpcClientChannel();
|
||||
ChannelServices.RegisterChannel(clientChannel, true);
|
||||
|
||||
var pipeData = new InstanceCallbackEventArgs
|
||||
{
|
||||
CommandLineArgs = args
|
||||
};
|
||||
InstanceProxy proxy = Activator.GetObject(typeof(InstanceProxy), string.Format("ipc://{0}{1}{2}/{2}", Environment.MachineName, Environment.UserName, uri)) as InstanceProxy;
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(pipeData));
|
||||
pipeClient.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
if (proxy != null)
|
||||
{
|
||||
proxy.SetCommandLineArgs(InstanceProxy.CommandLineArgs);
|
||||
}
|
||||
|
||||
private void CreateServer(EventHandler<InstanceCallbackEventArgs> callback)
|
||||
{
|
||||
pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
|
||||
pipeServer.BeginWaitForConnection(ConnectionCallback, callback);
|
||||
ChannelServices.UnregisterChannel(clientChannel);
|
||||
}
|
||||
|
||||
private void ConnectionCallback(IAsyncResult ar)
|
||||
private void RegisterRemoteType(string uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
pipeServer.EndWaitForConnection(ar);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Operation got aborted as part of program exit.
|
||||
return;
|
||||
serverChannel = new IpcServerChannel(Environment.MachineName + Environment.UserName + uri);
|
||||
ChannelServices.RegisterChannel(serverChannel, true);
|
||||
|
||||
RemotingConfiguration.RegisterWellKnownServiceType(typeof(InstanceProxy), uri, WellKnownObjectMode.Singleton);
|
||||
}
|
||||
|
||||
var callback = ar.AsyncState as EventHandler<InstanceCallbackEventArgs>;
|
||||
var sr = new StreamReader(pipeServer, Encoding.UTF8);
|
||||
try
|
||||
private void WaitOrTimerCallback(object state, bool timedOut)
|
||||
{
|
||||
EventHandler<InstanceCallbackEventArgs> callback = state as EventHandler<InstanceCallbackEventArgs>;
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
var data = sr.ReadToEnd();
|
||||
callback(this, JsonConvert.DeserializeObject<InstanceCallbackEventArgs>(data));
|
||||
}
|
||||
try
|
||||
{
|
||||
callback(state, new InstanceCallbackEventArgs(InstanceProxy.CommandLineArgs));
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Close the existing server
|
||||
sr.Dispose();
|
||||
|
||||
// Create a new server
|
||||
CreateServer(callback);
|
||||
|
||||
// Signal that we are ready to accept a new connection
|
||||
if (semaphore != null)
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
|
||||
internal class InstanceProxy : MarshalByRefObject
|
||||
{
|
||||
public static string[] CommandLineArgs { get; internal set; }
|
||||
|
||||
public void SetCommandLineArgs(string[] commandLineArgs)
|
||||
{
|
||||
CommandLineArgs = commandLineArgs;
|
||||
}
|
||||
}
|
||||
|
||||
public class InstanceCallbackEventArgs : EventArgs
|
||||
{
|
||||
[JsonProperty]
|
||||
public string[] CommandLineArgs { get; internal set; }
|
||||
public string[] CommandLineArgs { get; private set; }
|
||||
|
||||
internal InstanceCallbackEventArgs(string[] commandLineArgs)
|
||||
{
|
||||
CommandLineArgs = commandLineArgs;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,11 +46,18 @@ public bool CheckCommand(string command)
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
string text = string.Format("Command: \"{0}\"", Command);
|
||||
string text = "";
|
||||
|
||||
if (IsCommand)
|
||||
{
|
||||
text += "-";
|
||||
}
|
||||
|
||||
text += Command;
|
||||
|
||||
if (!string.IsNullOrEmpty(Parameter))
|
||||
{
|
||||
text += string.Format(" Parameter: \"{0}\"", Parameter);
|
||||
text += " \"" + Parameter + "\"";
|
||||
}
|
||||
|
||||
return text;
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
@ -38,6 +39,7 @@ public class GradientInfo
|
|||
|
||||
public List<GradientStop> Colors { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsValid => Colors != null && Colors.Count > 0;
|
||||
|
||||
public GradientInfo()
|
||||
|
|
|
@ -220,10 +220,8 @@ private void OnImportCompleted()
|
|||
}
|
||||
}
|
||||
|
||||
private void tsmiImportClipboard_Click(object sender, EventArgs e)
|
||||
public void ImportJson(string json)
|
||||
{
|
||||
string json = ClipboardHelpers.GetText(true);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
OnImportRequested(json);
|
||||
|
@ -231,6 +229,18 @@ private void tsmiImportClipboard_Click(object sender, EventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void tsmiImportClipboard_Click(object sender, EventArgs e)
|
||||
{
|
||||
string json = ClipboardHelpers.GetText(true);
|
||||
ImportJson(json);
|
||||
}
|
||||
|
||||
public void ImportFile(string filePath)
|
||||
{
|
||||
string json = File.ReadAllText(filePath, Encoding.UTF8);
|
||||
OnImportRequested(json);
|
||||
}
|
||||
|
||||
private void tsmiImportFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
string filter = "Settings (*.json)|*.json|All files (*.*)|*.*";
|
||||
|
@ -246,8 +256,7 @@ private void tsmiImportFile_Click(object sender, EventArgs e)
|
|||
{
|
||||
foreach (string filename in ofd.FileNames)
|
||||
{
|
||||
string json = File.ReadAllText(filename, Encoding.UTF8);
|
||||
OnImportRequested(json);
|
||||
ImportFile(filename);
|
||||
}
|
||||
|
||||
OnImportCompleted();
|
||||
|
|
|
@ -188,4 +188,13 @@ public enum ImageCombinerAlignment
|
|||
Center,
|
||||
RightOrBottom
|
||||
}
|
||||
|
||||
public enum ImageInterpolationMode // Localized
|
||||
{
|
||||
HighQualityBicubic,
|
||||
Bicubic,
|
||||
HighQualityBilinear,
|
||||
Bilinear,
|
||||
NearestNeighbor
|
||||
}
|
||||
}
|
|
@ -197,7 +197,7 @@ private void nudLocation_ValueChanged(object sender, EventArgs e)
|
|||
{
|
||||
if (isReady)
|
||||
{
|
||||
GradientStop gradientStop = GetSelectedGradientStop(out ListViewItem lvi);
|
||||
GradientStop gradientStop = GetSelectedGradientStop();
|
||||
|
||||
if (gradientStop != null)
|
||||
{
|
||||
|
|
|
@ -791,12 +791,20 @@ public static bool BrowseFolder(string title, TextBox tb, string initialDirector
|
|||
return false;
|
||||
}
|
||||
|
||||
public static string GetVariableFolderPath(string path)
|
||||
public static string GetVariableFolderPath(string path, bool supportCustomSpecialFolders = false)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (supportCustomSpecialFolders)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> specialFolder in HelpersOptions.ShareXSpecialFolders)
|
||||
{
|
||||
path = path.Replace(specialFolder.Value, $"%{specialFolder.Key}%", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Environment.SpecialFolder specialFolder in GetEnums<Environment.SpecialFolder>())
|
||||
{
|
||||
path = path.Replace(Environment.GetFolderPath(specialFolder), $"%{specialFolder}%", StringComparison.OrdinalIgnoreCase);
|
||||
|
@ -811,12 +819,20 @@ public static string GetVariableFolderPath(string path)
|
|||
return path;
|
||||
}
|
||||
|
||||
public static string ExpandFolderVariables(string path)
|
||||
public static string ExpandFolderVariables(string path, bool supportCustomSpecialFolders = false)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (supportCustomSpecialFolders)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> specialFolder in HelpersOptions.ShareXSpecialFolders)
|
||||
{
|
||||
path = path.Replace($"%{specialFolder.Key}%", specialFolder.Value, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Environment.SpecialFolder specialFolder in GetEnums<Environment.SpecialFolder>())
|
||||
{
|
||||
path = path.Replace($"%{specialFolder}%", Environment.GetFolderPath(specialFolder), StringComparison.OrdinalIgnoreCase);
|
||||
|
@ -908,7 +924,7 @@ public static long GetFileSize(string path)
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static void CreateDirectoryFromDirectoryPath(string directoryPath)
|
||||
public static void CreateDirectory(string directoryPath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
|
||||
{
|
||||
|
@ -930,7 +946,7 @@ public static void CreateDirectoryFromFilePath(string filePath)
|
|||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
string directoryPath = Path.GetDirectoryName(filePath);
|
||||
CreateDirectoryFromDirectoryPath(directoryPath);
|
||||
CreateDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -955,7 +971,7 @@ public static string CopyFile(string filePath, string destinationFolder, bool ov
|
|||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destinationFilePath = Path.Combine(destinationFolder, fileName);
|
||||
CreateDirectoryFromDirectoryPath(destinationFolder);
|
||||
CreateDirectory(destinationFolder);
|
||||
File.Copy(filePath, destinationFilePath, overwrite);
|
||||
return destinationFilePath;
|
||||
}
|
||||
|
@ -969,7 +985,7 @@ public static string MoveFile(string filePath, string destinationFolder, bool ov
|
|||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destinationFilePath = Path.Combine(destinationFolder, fileName);
|
||||
CreateDirectoryFromDirectoryPath(destinationFolder);
|
||||
CreateDirectory(destinationFolder);
|
||||
|
||||
if (overwrite && File.Exists(destinationFilePath))
|
||||
{
|
||||
|
@ -1015,7 +1031,7 @@ public static string BackupFileWeekly(string filePath, string destinationFolder)
|
|||
|
||||
if (!File.Exists(newFilePath))
|
||||
{
|
||||
CreateDirectoryFromDirectoryPath(destinationFolder);
|
||||
CreateDirectory(destinationFolder);
|
||||
File.Copy(filePath, newFilePath, false);
|
||||
return newFilePath;
|
||||
}
|
||||
|
@ -1035,7 +1051,7 @@ public static void BackupFileMonthly(string filePath, string destinationFolder)
|
|||
|
||||
if (!File.Exists(newFilePath))
|
||||
{
|
||||
CreateDirectoryFromDirectoryPath(destinationFolder);
|
||||
CreateDirectory(destinationFolder);
|
||||
File.Copy(filePath, newFilePath, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2078,5 +2078,23 @@ public static Size GetImageFileDimensions(string filePath)
|
|||
|
||||
return Size.Empty;
|
||||
}
|
||||
|
||||
public static InterpolationMode GetInterpolationMode(ImageInterpolationMode interpolationMode)
|
||||
{
|
||||
switch (interpolationMode)
|
||||
{
|
||||
default:
|
||||
case ImageInterpolationMode.HighQualityBicubic:
|
||||
return InterpolationMode.HighQualityBicubic;
|
||||
case ImageInterpolationMode.Bicubic:
|
||||
return InterpolationMode.Bicubic;
|
||||
case ImageInterpolationMode.HighQualityBilinear:
|
||||
return InterpolationMode.HighQualityBilinear;
|
||||
case ImageInterpolationMode.Bilinear:
|
||||
return InterpolationMode.Bilinear;
|
||||
case ImageInterpolationMode.NearestNeighbor:
|
||||
return InterpolationMode.NearestNeighbor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,5 +40,6 @@ public static class HelpersOptions
|
|||
public static List<Color> RecentColors { get; set; } = new List<Color>();
|
||||
public static string LastSaveDirectory { get; set; } = "";
|
||||
public static bool URLEncodeIgnoreEmoji { get; set; } = false;
|
||||
public static Dictionary<string, string> ShareXSpecialFolders { get; set; } = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
106
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
106
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
|
@ -146,7 +146,7 @@ internal static string adjectives {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add image effects / watermark.
|
||||
/// Looks up a localized string similar to Add image effects.
|
||||
/// </summary>
|
||||
internal static string AfterCaptureTasks_AddImageEffects {
|
||||
get {
|
||||
|
@ -2058,51 +2058,6 @@ internal static string ImageDestination_FileUploader {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageEditorInterpolationMode_Bicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageEditorInterpolationMode_Bicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageEditorInterpolationMode_Bilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageEditorInterpolationMode_Bilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageEditorInterpolationMode_HighQualityBicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageEditorInterpolationMode_HighQualityBicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageEditorInterpolationMode_HighQualityBilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageEditorInterpolationMode_HighQualityBilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Nearest neighbor.
|
||||
/// </summary>
|
||||
internal static string ImageEditorInterpolationMode_NearestNeighbor {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageEditorInterpolationMode_NearestNeighbor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto size.
|
||||
/// </summary>
|
||||
|
@ -2148,6 +2103,51 @@ internal static string ImageEditorStartMode_PreviousState {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_Bicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_Bicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_Bilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_Bilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_HighQualityBicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_HighQualityBicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_HighQualityBilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_HighQualityBilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Nearest neighbor.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_NearestNeighbor {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_NearestNeighbor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Big square.
|
||||
/// </summary>
|
||||
|
@ -2251,9 +2251,19 @@ internal static System.Drawing.Bitmap Loading {
|
|||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap LoadingSmall {
|
||||
internal static System.Drawing.Bitmap LoadingSmallBlack {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LoadingSmall", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("LoadingSmallBlack", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap LoadingSmallWhite {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LoadingSmallWhite", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
<data name="TextDestination_CustomTextUploader" xml:space="preserve">
|
||||
<value>Custom text uploader</value>
|
||||
</data>
|
||||
<data name="ImageEditorInterpolationMode_HighQualityBicubic" xml:space="preserve">
|
||||
<data name="ImageInterpolationMode_HighQualityBicubic" xml:space="preserve">
|
||||
<value>High quality bicubic</value>
|
||||
</data>
|
||||
<data name="ProxyMethod_None" xml:space="preserve">
|
||||
|
@ -477,7 +477,7 @@ Would you like to download it?</value>
|
|||
<value>Manual</value>
|
||||
</data>
|
||||
<data name="AfterCaptureTasks_AddImageEffects" xml:space="preserve">
|
||||
<value>Add image effects / watermark</value>
|
||||
<value>Add image effects</value>
|
||||
</data>
|
||||
<data name="AfterCaptureTasks_DeleteFile" xml:space="preserve">
|
||||
<value>Delete file locally</value>
|
||||
|
@ -683,7 +683,7 @@ Would you like to download and install it?</value>
|
|||
<data name="HotkeyType_ScreenRecorderGIF_Category" xml:space="preserve">
|
||||
<value>Screen record</value>
|
||||
</data>
|
||||
<data name="ImageEditorInterpolationMode_Bilinear" xml:space="preserve">
|
||||
<data name="ImageInterpolationMode_Bilinear" xml:space="preserve">
|
||||
<value>Bilinear</value>
|
||||
</data>
|
||||
<data name="WavFileNameEditor_EditValue_Browse_for_a_sound_file___" xml:space="preserve">
|
||||
|
@ -710,7 +710,7 @@ Would you like to download and install it?</value>
|
|||
<data name="Extensions_AddContextMenu_Paste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
</data>
|
||||
<data name="ImageEditorInterpolationMode_HighQualityBilinear" xml:space="preserve">
|
||||
<data name="ImageInterpolationMode_HighQualityBilinear" xml:space="preserve">
|
||||
<value>High quality bilinear</value>
|
||||
</data>
|
||||
<data name="LinearGradientMode_ForwardDiagonal" xml:space="preserve">
|
||||
|
@ -734,7 +734,7 @@ Would you like to download and install it?</value>
|
|||
<data name="RegionCaptureAction_RemoveShapeCancelCapture" xml:space="preserve">
|
||||
<value>Remove shape or cancel capture</value>
|
||||
</data>
|
||||
<data name="ImageEditorInterpolationMode_NearestNeighbor" xml:space="preserve">
|
||||
<data name="ImageInterpolationMode_NearestNeighbor" xml:space="preserve">
|
||||
<value>Nearest neighbor</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_un_User_name" xml:space="preserve">
|
||||
|
@ -746,7 +746,7 @@ Would you like to download and install it?</value>
|
|||
<data name="DownloaderForm_ChangeStatus_Status___0_" xml:space="preserve">
|
||||
<value>Status: {0}</value>
|
||||
</data>
|
||||
<data name="ImageEditorInterpolationMode_Bicubic" xml:space="preserve">
|
||||
<data name="ImageInterpolationMode_Bicubic" xml:space="preserve">
|
||||
<value>Bicubic</value>
|
||||
</data>
|
||||
<data name="CodeMenu_Create_Close" xml:space="preserve">
|
||||
|
@ -1193,9 +1193,6 @@ Would you like to download and install it?</value>
|
|||
<data name="AmazonS3StorageClass_STANDARD_IA" xml:space="preserve">
|
||||
<value>Amazon S3 Standard-Infrequent Access</value>
|
||||
</data>
|
||||
<data name="LoadingSmall" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LoadingSmall.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="RandomNonAmbiguousAlphanumericCharRepeatUsingN" xml:space="preserve">
|
||||
<value>Random non ambiguous alphanumeric char. Repeat using {n}</value>
|
||||
</data>
|
||||
|
@ -1250,4 +1247,10 @@ Would you like to download and install it?</value>
|
|||
<data name="AmazonS3StorageClass_ONEZONE_IA" xml:space="preserve">
|
||||
<value>Amazon S3 One Zone-Infrequent Access</value>
|
||||
</data>
|
||||
<data name="LoadingSmallBlack" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LoadingSmallBlack.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="LoadingSmallWhite" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LoadingSmallWhite.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
BIN
ShareX.HelpersLib/Resources/LoadingSmallWhite.gif
Normal file
BIN
ShareX.HelpersLib/Resources/LoadingSmallWhite.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 847 B |
|
@ -161,7 +161,7 @@ private bool SaveInternal(string filePath)
|
|||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
backupFilePath = Path.Combine(BackupFolder, fileName);
|
||||
Helpers.CreateDirectoryFromDirectoryPath(BackupFolder);
|
||||
Helpers.CreateDirectory(BackupFolder);
|
||||
}
|
||||
|
||||
File.Replace(tempFilePath, filePath, backupFilePath);
|
||||
|
|
|
@ -1473,7 +1473,10 @@
|
|||
<None Include="Resources\ShareX_Icon_White.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\LoadingSmall.gif" />
|
||||
<None Include="Resources\LoadingSmallBlack.gif" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\LoadingSmallWhite.gif" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -132,6 +132,12 @@ private static void ApplyCustomThemeToControl(Control control)
|
|||
lv.BackColor = Theme.LightBackgroundColor;
|
||||
lv.SupportCustomTheme();
|
||||
return;
|
||||
case SplitContainerCustomSplitter sccs:
|
||||
sccs.SplitterColor = Theme.BackgroundColor;
|
||||
sccs.SplitterLineColor = Theme.BorderColor;
|
||||
sccs.Panel1.BackColor = Theme.BackgroundColor;
|
||||
sccs.Panel2.BackColor = Theme.BackgroundColor;
|
||||
break;
|
||||
case SplitContainer sc:
|
||||
sc.Panel1.BackColor = Theme.BackgroundColor;
|
||||
sc.Panel2.BackColor = Theme.BackgroundColor;
|
||||
|
|
|
@ -45,7 +45,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
|
|||
|
||||
if (dlg.ShowDialog())
|
||||
{
|
||||
value = Helpers.GetVariableFolderPath(dlg.FileName);
|
||||
value = Helpers.GetVariableFolderPath(dlg.FileName, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
|
|||
|
||||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
value = Helpers.GetVariableFolderPath(filePath);
|
||||
value = Helpers.GetVariableFolderPath(filePath, true);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
@ -215,7 +215,7 @@ private void StartDownload()
|
|||
btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel;
|
||||
|
||||
string folderPath = Path.Combine(Path.GetTempPath(), "ShareX");
|
||||
Helpers.CreateDirectoryFromDirectoryPath(folderPath);
|
||||
Helpers.CreateDirectory(folderPath);
|
||||
DownloadLocation = Path.Combine(folderPath, Filename);
|
||||
|
||||
fileDownloader = new FileDownloader(URL, DownloadLocation, Proxy, AcceptHeader);
|
||||
|
|
|
@ -38,7 +38,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// pbLoading
|
||||
//
|
||||
this.pbLoading.Image = global::ShareX.HelpersLib.Properties.Resources.LoadingSmall;
|
||||
this.pbLoading.Image = global::ShareX.HelpersLib.Properties.Resources.LoadingSmallBlack;
|
||||
resources.ApplyResources(this.pbLoading, "pbLoading");
|
||||
this.pbLoading.Name = "pbLoading";
|
||||
this.pbLoading.TabStop = false;
|
||||
|
|
|
@ -60,6 +60,18 @@ public void CheckUpdate(UpdateChecker updateChecker)
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateLoadingImage()
|
||||
{
|
||||
if (ShareXResources.IsDarkTheme)
|
||||
{
|
||||
pbLoading.Image = Resources.LoadingSmallWhite;
|
||||
}
|
||||
else
|
||||
{
|
||||
pbLoading.Image = Resources.LoadingSmallBlack;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckingUpdate()
|
||||
{
|
||||
updateChecker.CheckUpdate();
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace ShareX.HelpersLib
|
|||
{
|
||||
public static class ZipManager
|
||||
{
|
||||
public static void Extract(string archivePath, string destination, bool retainDirectoryStructure = true, List<string> fileFilter = null)
|
||||
public static void Extract(string archivePath, string destination, bool retainDirectoryStructure = true, Func<ZipArchiveEntry, bool> filter = null)
|
||||
{
|
||||
using (ZipArchive archive = ZipFile.OpenRead(archivePath))
|
||||
{
|
||||
|
@ -40,31 +40,21 @@ public static void Extract(string archivePath, string destination, bool retainDi
|
|||
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
string entryName = entry.Name;
|
||||
|
||||
if (fileFilter != null)
|
||||
{
|
||||
bool match = false;
|
||||
|
||||
foreach (string file in fileFilter)
|
||||
{
|
||||
if (file.Equals(entryName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match)
|
||||
if (filter != null && !filter(entry))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
string entryName;
|
||||
|
||||
if (retainDirectoryStructure)
|
||||
{
|
||||
entryName = entry.FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
entryName = entry.Name;
|
||||
}
|
||||
|
||||
string fullPath = Path.GetFullPath(Path.Combine(fullName, entryName));
|
||||
|
||||
|
@ -97,7 +87,20 @@ public static void Compress(string source, string archivePath, CompressionLevel
|
|||
ZipFile.CreateFromDirectory(source, archivePath, compression, false);
|
||||
}
|
||||
|
||||
public static void Compress(string archivePath, List<string> files, string workingDirectory = "", CompressionLevel compression = CompressionLevel.Optimal)
|
||||
public static void Compress(string archivePath, List<string> files, CompressionLevel compression = CompressionLevel.Optimal)
|
||||
{
|
||||
Dictionary<string, string> entries = new Dictionary<string, string>();
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
string fileName = Path.GetFileName(file);
|
||||
entries.Add(file, fileName);
|
||||
}
|
||||
|
||||
Compress(archivePath, entries, compression);
|
||||
}
|
||||
|
||||
public static void Compress(string archivePath, Dictionary<string, string> files, CompressionLevel compression = CompressionLevel.Optimal)
|
||||
{
|
||||
if (File.Exists(archivePath))
|
||||
{
|
||||
|
@ -106,13 +109,14 @@ public static void Compress(string archivePath, List<string> files, string worki
|
|||
|
||||
using (ZipArchive archive = ZipFile.Open(archivePath, ZipArchiveMode.Update))
|
||||
{
|
||||
foreach (string file in files)
|
||||
foreach (KeyValuePair<string, string> file in files)
|
||||
{
|
||||
string filePath = Path.Combine(workingDirectory, file);
|
||||
string sourceFilePath = file.Key;
|
||||
|
||||
if (File.Exists(filePath))
|
||||
if (File.Exists(sourceFilePath))
|
||||
{
|
||||
archive.CreateEntryFromFile(filePath, file, compression);
|
||||
string entryName = file.Value;
|
||||
archive.CreateEntryFromFile(sourceFilePath, entryName, compression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
|
||||
namespace ShareX.ImageEffectsLib
|
||||
|
@ -49,6 +50,12 @@ public class DrawImage : ImageEffect
|
|||
[DefaultValue(typeof(Size), "0, 0")]
|
||||
public Size Size { get; set; }
|
||||
|
||||
[DefaultValue(ImageInterpolationMode.HighQualityBicubic), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public ImageInterpolationMode InterpolationMode { get; set; }
|
||||
|
||||
[DefaultValue(CompositingMode.SourceOver)]
|
||||
public CompositingMode CompositingMode { get; set; }
|
||||
|
||||
[DefaultValue(true), Description("If image watermark size bigger than source image then don't draw it.")]
|
||||
public bool AutoHide { get; set; }
|
||||
|
||||
|
@ -59,7 +66,7 @@ public DrawImage()
|
|||
|
||||
public override Bitmap Apply(Bitmap bmp)
|
||||
{
|
||||
string imageFilePath = Helpers.ExpandFolderVariables(ImageLocation);
|
||||
string imageFilePath = Helpers.ExpandFolderVariables(ImageLocation, true);
|
||||
|
||||
if (!string.IsNullOrEmpty(imageFilePath) && File.Exists(imageFilePath))
|
||||
{
|
||||
|
@ -97,7 +104,9 @@ public override Bitmap Apply(Bitmap bmp)
|
|||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.SetHighQuality();
|
||||
g.InterpolationMode = ImageHelpers.GetInterpolationMode(InterpolationMode);
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
g.CompositingMode = CompositingMode;
|
||||
g.DrawImage(bmp2, imageRectangle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public DrawParticles()
|
|||
|
||||
public override Bitmap Apply(Bitmap bmp)
|
||||
{
|
||||
string imageFolder = Helpers.ExpandFolderVariables(ImageFolder);
|
||||
string imageFolder = Helpers.ExpandFolderVariables(ImageFolder, true);
|
||||
|
||||
if (!string.IsNullOrEmpty(imageFolder) && Directory.Exists(imageFolder))
|
||||
{
|
||||
|
|
108
ShareX.ImageEffectsLib/ImageEffectPackager.cs
Normal file
108
ShareX.ImageEffectsLib/ImageEffectPackager.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2020 ShareX Team
|
||||
|
||||
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 2
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.ImageEffectsLib
|
||||
{
|
||||
public static class ImageEffectPackager
|
||||
{
|
||||
private const string ConfigFileName = "Config.json";
|
||||
|
||||
public static string Package(string outputFilePath, string configJson, string assetsFolderPath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(outputFilePath))
|
||||
{
|
||||
string outputFolder = Path.GetDirectoryName(outputFilePath);
|
||||
Helpers.CreateDirectory(outputFolder);
|
||||
|
||||
string configFilePath = Path.Combine(outputFolder, ConfigFileName);
|
||||
File.WriteAllText(configFilePath, configJson, Encoding.UTF8);
|
||||
|
||||
Dictionary<string, string> files = new Dictionary<string, string>();
|
||||
files.Add(configFilePath, ConfigFileName);
|
||||
|
||||
if (!string.IsNullOrEmpty(assetsFolderPath) && Directory.Exists(assetsFolderPath))
|
||||
{
|
||||
string parentFolderPath = Directory.GetParent(assetsFolderPath).FullName;
|
||||
int entryNamePosition = parentFolderPath.Length + 1;
|
||||
|
||||
foreach (string assetPath in Directory.EnumerateFiles(assetsFolderPath, "*.*", SearchOption.AllDirectories).Where(x => Helpers.IsImageFile(x)))
|
||||
{
|
||||
string entryName = assetPath.Substring(entryNamePosition);
|
||||
files.Add(assetPath, entryName);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ZipManager.Compress(outputFilePath, files);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(configFilePath);
|
||||
}
|
||||
|
||||
return outputFilePath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string ExtractPackage(string packageFilePath, string destination)
|
||||
{
|
||||
string configJson = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(packageFilePath) && File.Exists(packageFilePath) && !string.IsNullOrEmpty(destination))
|
||||
{
|
||||
ZipManager.Extract(packageFilePath, destination, true, entry =>
|
||||
{
|
||||
if (Helpers.IsImageFile(entry.Name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (configJson == null && entry.FullName.Equals(ConfigFileName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using (Stream stream = entry.Open())
|
||||
using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
configJson = streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
return configJson;
|
||||
}
|
||||
}
|
||||
}
|
135
ShareX.ImageEffectsLib/ImageEffectPackagerForm.Designer.cs
generated
Normal file
135
ShareX.ImageEffectsLib/ImageEffectPackagerForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,135 @@
|
|||
namespace ShareX.ImageEffectsLib
|
||||
{
|
||||
partial class ImageEffectPackagerForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnPackage = new System.Windows.Forms.Button();
|
||||
this.lblAssetsFolderPath = new System.Windows.Forms.Label();
|
||||
this.lblPackageFilePath = new System.Windows.Forms.Label();
|
||||
this.txtPackageFilePath = new System.Windows.Forms.TextBox();
|
||||
this.btnPackageFilePathBrowse = new System.Windows.Forms.Button();
|
||||
this.txtAssetsFolderPath = new System.Windows.Forms.TextBox();
|
||||
this.btnAssetsFolderPathBrowse = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnPackage
|
||||
//
|
||||
this.btnPackage.Location = new System.Drawing.Point(16, 112);
|
||||
this.btnPackage.Name = "btnPackage";
|
||||
this.btnPackage.Size = new System.Drawing.Size(384, 24);
|
||||
this.btnPackage.TabIndex = 0;
|
||||
this.btnPackage.Text = "Package";
|
||||
this.btnPackage.UseVisualStyleBackColor = true;
|
||||
this.btnPackage.Click += new System.EventHandler(this.btnPackage_Click);
|
||||
//
|
||||
// lblAssetsFolderPath
|
||||
//
|
||||
this.lblAssetsFolderPath.AutoSize = true;
|
||||
this.lblAssetsFolderPath.Location = new System.Drawing.Point(13, 16);
|
||||
this.lblAssetsFolderPath.Name = "lblAssetsFolderPath";
|
||||
this.lblAssetsFolderPath.Size = new System.Drawing.Size(94, 13);
|
||||
this.lblAssetsFolderPath.TabIndex = 1;
|
||||
this.lblAssetsFolderPath.Text = "Assets folder path:";
|
||||
//
|
||||
// lblPackageFilePath
|
||||
//
|
||||
this.lblPackageFilePath.AutoSize = true;
|
||||
this.lblPackageFilePath.Location = new System.Drawing.Point(13, 64);
|
||||
this.lblPackageFilePath.Name = "lblPackageFilePath";
|
||||
this.lblPackageFilePath.Size = new System.Drawing.Size(93, 13);
|
||||
this.lblPackageFilePath.TabIndex = 4;
|
||||
this.lblPackageFilePath.Text = "Package file path:";
|
||||
//
|
||||
// txtPackageFilePath
|
||||
//
|
||||
this.txtPackageFilePath.Location = new System.Drawing.Point(16, 80);
|
||||
this.txtPackageFilePath.Name = "txtPackageFilePath";
|
||||
this.txtPackageFilePath.Size = new System.Drawing.Size(344, 20);
|
||||
this.txtPackageFilePath.TabIndex = 5;
|
||||
this.txtPackageFilePath.TextChanged += new System.EventHandler(this.txtPackageFilePath_TextChanged);
|
||||
//
|
||||
// btnPackageFilePathBrowse
|
||||
//
|
||||
this.btnPackageFilePathBrowse.Location = new System.Drawing.Point(368, 79);
|
||||
this.btnPackageFilePathBrowse.Name = "btnPackageFilePathBrowse";
|
||||
this.btnPackageFilePathBrowse.Size = new System.Drawing.Size(32, 23);
|
||||
this.btnPackageFilePathBrowse.TabIndex = 6;
|
||||
this.btnPackageFilePathBrowse.Text = "...";
|
||||
this.btnPackageFilePathBrowse.UseVisualStyleBackColor = true;
|
||||
this.btnPackageFilePathBrowse.Click += new System.EventHandler(this.btnPackageFilePathBrowse_Click);
|
||||
//
|
||||
// txtAssetsFolderPath
|
||||
//
|
||||
this.txtAssetsFolderPath.Location = new System.Drawing.Point(16, 32);
|
||||
this.txtAssetsFolderPath.Name = "txtAssetsFolderPath";
|
||||
this.txtAssetsFolderPath.Size = new System.Drawing.Size(344, 20);
|
||||
this.txtAssetsFolderPath.TabIndex = 2;
|
||||
this.txtAssetsFolderPath.TextChanged += new System.EventHandler(this.txtAssetsFolderPath_TextChanged);
|
||||
//
|
||||
// btnAssetsFolderPathBrowse
|
||||
//
|
||||
this.btnAssetsFolderPathBrowse.Location = new System.Drawing.Point(368, 31);
|
||||
this.btnAssetsFolderPathBrowse.Name = "btnAssetsFolderPathBrowse";
|
||||
this.btnAssetsFolderPathBrowse.Size = new System.Drawing.Size(32, 23);
|
||||
this.btnAssetsFolderPathBrowse.TabIndex = 3;
|
||||
this.btnAssetsFolderPathBrowse.Text = "...";
|
||||
this.btnAssetsFolderPathBrowse.UseVisualStyleBackColor = true;
|
||||
this.btnAssetsFolderPathBrowse.Click += new System.EventHandler(this.btnAssetsFolderPathBrowse_Click);
|
||||
//
|
||||
// ImageEffectPackagerForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(417, 150);
|
||||
this.Controls.Add(this.btnAssetsFolderPathBrowse);
|
||||
this.Controls.Add(this.txtAssetsFolderPath);
|
||||
this.Controls.Add(this.btnPackageFilePathBrowse);
|
||||
this.Controls.Add(this.txtPackageFilePath);
|
||||
this.Controls.Add(this.lblPackageFilePath);
|
||||
this.Controls.Add(this.lblAssetsFolderPath);
|
||||
this.Controls.Add(this.btnPackage);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "ImageEffectPackagerForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ShareX - Image effect packager";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button btnPackage;
|
||||
private System.Windows.Forms.Label lblAssetsFolderPath;
|
||||
private System.Windows.Forms.Label lblPackageFilePath;
|
||||
private System.Windows.Forms.TextBox txtPackageFilePath;
|
||||
private System.Windows.Forms.Button btnPackageFilePathBrowse;
|
||||
private System.Windows.Forms.TextBox txtAssetsFolderPath;
|
||||
private System.Windows.Forms.Button btnAssetsFolderPathBrowse;
|
||||
}
|
||||
}
|
113
ShareX.ImageEffectsLib/ImageEffectPackagerForm.cs
Normal file
113
ShareX.ImageEffectsLib/ImageEffectPackagerForm.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2020 ShareX Team
|
||||
|
||||
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 2
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ImageEffectsLib
|
||||
{
|
||||
public partial class ImageEffectPackagerForm : Form
|
||||
{
|
||||
public string ImageEffectJson { get; private set; }
|
||||
public string ImageEffectName { get; private set; }
|
||||
public string ShareXImageEffectsFolderPath { get; private set; }
|
||||
public string AssetsFolderPath { get; set; }
|
||||
public string PackageFilePath { get; set; }
|
||||
|
||||
public ImageEffectPackagerForm(string json, string name, string imageEffectsFolderPath)
|
||||
{
|
||||
ImageEffectJson = json;
|
||||
ImageEffectName = name;
|
||||
ShareXImageEffectsFolderPath = imageEffectsFolderPath;
|
||||
|
||||
InitializeComponent();
|
||||
ShareXResources.ApplyTheme(this);
|
||||
|
||||
AssetsFolderPath = Path.Combine(ShareXImageEffectsFolderPath, ImageEffectName);
|
||||
txtAssetsFolderPath.Text = AssetsFolderPath;
|
||||
PackageFilePath = AssetsFolderPath + ".sxie";
|
||||
txtPackageFilePath.Text = PackageFilePath;
|
||||
}
|
||||
|
||||
private void txtAssetsFolderPath_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
AssetsFolderPath = txtAssetsFolderPath.Text;
|
||||
}
|
||||
|
||||
private void btnAssetsFolderPathBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
Helpers.BrowseFolder(txtAssetsFolderPath, ShareXImageEffectsFolderPath);
|
||||
}
|
||||
|
||||
private void txtPackageFilePath_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
PackageFilePath = txtPackageFilePath.Text;
|
||||
}
|
||||
|
||||
private void btnPackageFilePathBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||
{
|
||||
sfd.DefaultExt = "sxie";
|
||||
sfd.FileName = ImageEffectName + ".sxie";
|
||||
sfd.Filter = "ShareX image effect (*.sxie)|*.sxie";
|
||||
sfd.InitialDirectory = ShareXImageEffectsFolderPath;
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
txtPackageFilePath.Text = sfd.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnPackage_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(AssetsFolderPath) && !AssetsFolderPath.StartsWith(ShareXImageEffectsFolderPath + "\\", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// TODO: Translate
|
||||
MessageBox.Show("Assets folder must be inside ShareX image effects folder.", "ShareX - " + "Invalid assets folder path",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
string outputFilePath = ImageEffectPackager.Package(PackageFilePath, ImageEffectJson, AssetsFolderPath);
|
||||
|
||||
if (!string.IsNullOrEmpty(outputFilePath) && File.Exists(outputFilePath))
|
||||
{
|
||||
Helpers.OpenFolderWithFile(outputFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.ShowError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ShareX.ImageEffectsLib/ImageEffectPackagerForm.resx
Normal file
120
ShareX.ImageEffectsLib/ImageEffectPackagerForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
40
ShareX.ImageEffectsLib/ImageEffectsForm.Designer.cs
generated
40
ShareX.ImageEffectsLib/ImageEffectsForm.Designer.cs
generated
|
@ -56,7 +56,13 @@ private void InitializeComponent()
|
|||
this.btnRefresh = new System.Windows.Forms.Button();
|
||||
this.btnDuplicatePreset = new System.Windows.Forms.Button();
|
||||
this.lblPresets = new System.Windows.Forms.Label();
|
||||
this.btnPackager = new System.Windows.Forms.Button();
|
||||
this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter();
|
||||
this.cmsLoadImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit();
|
||||
this.scMain.Panel1.SuspendLayout();
|
||||
this.scMain.Panel2.SuspendLayout();
|
||||
this.scMain.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pgSettings
|
||||
|
@ -139,9 +145,9 @@ private void InitializeComponent()
|
|||
//
|
||||
// pbResult
|
||||
//
|
||||
resources.ApplyResources(this.pbResult, "pbResult");
|
||||
this.pbResult.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.pbResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
resources.ApplyResources(this.pbResult, "pbResult");
|
||||
this.pbResult.DrawCheckeredBackground = true;
|
||||
this.pbResult.EnableRightClickMenu = true;
|
||||
this.pbResult.FullscreenOnClick = true;
|
||||
|
@ -259,12 +265,36 @@ private void InitializeComponent()
|
|||
resources.ApplyResources(this.lblPresets, "lblPresets");
|
||||
this.lblPresets.Name = "lblPresets";
|
||||
//
|
||||
// btnPackager
|
||||
//
|
||||
resources.ApplyResources(this.btnPackager, "btnPackager");
|
||||
this.btnPackager.Name = "btnPackager";
|
||||
this.btnPackager.UseVisualStyleBackColor = true;
|
||||
this.btnPackager.Click += new System.EventHandler(this.btnPackager_Click);
|
||||
//
|
||||
// scMain
|
||||
//
|
||||
resources.ApplyResources(this.scMain, "scMain");
|
||||
this.scMain.Name = "scMain";
|
||||
//
|
||||
// scMain.Panel1
|
||||
//
|
||||
this.scMain.Panel1.Controls.Add(this.pgSettings);
|
||||
//
|
||||
// scMain.Panel2
|
||||
//
|
||||
this.scMain.Panel2.Controls.Add(this.pbResult);
|
||||
this.scMain.SplitterColor = System.Drawing.Color.White;
|
||||
this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189)))));
|
||||
//
|
||||
// ImageEffectsForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.CancelButton = this.btnClose;
|
||||
this.Controls.Add(this.scMain);
|
||||
this.Controls.Add(this.btnPackager);
|
||||
this.Controls.Add(this.lblPresets);
|
||||
this.Controls.Add(this.btnDuplicatePreset);
|
||||
this.Controls.Add(this.btnRefresh);
|
||||
|
@ -283,13 +313,15 @@ private void InitializeComponent()
|
|||
this.Controls.Add(this.btnClear);
|
||||
this.Controls.Add(this.btnRemove);
|
||||
this.Controls.Add(this.btnAdd);
|
||||
this.Controls.Add(this.pgSettings);
|
||||
this.Controls.Add(this.lvEffects);
|
||||
this.Controls.Add(this.pbResult);
|
||||
this.Name = "ImageEffectsForm";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Shown += new System.EventHandler(this.ImageEffectsForm_Shown);
|
||||
this.cmsLoadImage.ResumeLayout(false);
|
||||
this.scMain.Panel1.ResumeLayout(false);
|
||||
this.scMain.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit();
|
||||
this.scMain.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -323,6 +355,8 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Button btnRefresh;
|
||||
private System.Windows.Forms.Button btnDuplicatePreset;
|
||||
private System.Windows.Forms.Label lblPresets;
|
||||
private System.Windows.Forms.Button btnPackager;
|
||||
private HelpersLib.SplitContainerCustomSplitter scMain;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ namespace ShareX.ImageEffectsLib
|
|||
{
|
||||
public partial class ImageEffectsForm : Form
|
||||
{
|
||||
public static bool IsInstanceActive => instance != null && !instance.IsDisposed;
|
||||
|
||||
private static ImageEffectsForm instance;
|
||||
|
||||
public event Action<Bitmap> ImageProcessRequested;
|
||||
|
||||
public bool AutoGeneratePreviewImage { get; set; }
|
||||
|
@ -48,6 +52,8 @@ public partial class ImageEffectsForm : Form
|
|||
|
||||
public ImageEffectsForm(Bitmap bmp, List<ImageEffectPreset> presets, int selectedPresetIndex)
|
||||
{
|
||||
pauseUpdate = true;
|
||||
|
||||
InitializeComponent();
|
||||
ShareXResources.ApplyTheme(this);
|
||||
|
||||
|
@ -64,9 +70,24 @@ public ImageEffectsForm(Bitmap bmp, List<ImageEffectPreset> presets, int selecte
|
|||
}
|
||||
|
||||
SelectedPresetIndex = selectedPresetIndex;
|
||||
|
||||
eiImageEffects.ObjectType = typeof(ImageEffectPreset);
|
||||
eiImageEffects.SerializationBinder = new TypeNameSerializationBinder("ShareX.ImageEffectsLib", "ShareX.ImageEffectsLib");
|
||||
|
||||
AddAllEffectsToContextMenu();
|
||||
LoadSettings();
|
||||
|
||||
pauseUpdate = false;
|
||||
}
|
||||
|
||||
public static ImageEffectsForm GetFormInstance(List<ImageEffectPreset> presets, int selectedPresetIndex)
|
||||
{
|
||||
if (!IsInstanceActive)
|
||||
{
|
||||
instance = new ImageEffectsForm(null, presets, selectedPresetIndex);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void EnableToolMode(Action<Bitmap> imageProcessRequested, string filePath = null)
|
||||
|
@ -85,6 +106,11 @@ public void EditorMode()
|
|||
btnClose.Text = Resources.ImageEffectsForm_EditorMode_Cancel;
|
||||
}
|
||||
|
||||
public void ImportImageEffect(string json)
|
||||
{
|
||||
eiImageEffects.ImportJson(json);
|
||||
}
|
||||
|
||||
protected void OnImageProcessRequested(Bitmap bmp)
|
||||
{
|
||||
ImageProcessRequested?.Invoke(bmp);
|
||||
|
@ -161,8 +187,6 @@ private void AddEffectToContextMenu(string groupName, params Type[] imageEffects
|
|||
|
||||
private void LoadSettings()
|
||||
{
|
||||
pauseUpdate = true;
|
||||
|
||||
foreach (ImageEffectPreset preset in Presets)
|
||||
{
|
||||
cbPresets.Items.Add(preset);
|
||||
|
@ -174,8 +198,6 @@ private void LoadSettings()
|
|||
}
|
||||
|
||||
UpdateControlStates();
|
||||
|
||||
pauseUpdate = false;
|
||||
}
|
||||
|
||||
private ImageEffectPreset GetSelectedPreset()
|
||||
|
@ -201,7 +223,9 @@ private void AddPreset(ImageEffectPreset preset)
|
|||
{
|
||||
Presets.Add(preset);
|
||||
cbPresets.Items.Add(preset);
|
||||
ignorePresetsSelectedIndexChanged = true;
|
||||
cbPresets.SelectedIndex = cbPresets.Items.Count - 1;
|
||||
ignorePresetsSelectedIndexChanged = false;
|
||||
LoadPreset(preset);
|
||||
txtPresetName.Focus();
|
||||
}
|
||||
|
@ -419,7 +443,6 @@ private void LoadPreset(ImageEffectPreset preset)
|
|||
|
||||
private void ImageEffectsForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
LoadSettings();
|
||||
this.ForceActivate();
|
||||
}
|
||||
|
||||
|
@ -461,11 +484,11 @@ private void btnDuplicatePreset_Click(object sender, EventArgs e)
|
|||
}
|
||||
|
||||
private void cbPresets_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!ignorePresetsSelectedIndexChanged)
|
||||
{
|
||||
SelectedPresetIndex = cbPresets.SelectedIndex;
|
||||
|
||||
if (!ignorePresetsSelectedIndexChanged)
|
||||
{
|
||||
ImageEffectPreset preset = GetSelectedPreset();
|
||||
if (preset != null)
|
||||
{
|
||||
|
@ -565,7 +588,7 @@ private void lvEffects_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
||||
private void lvEffects_ItemChecked(object sender, ItemCheckedEventArgs e)
|
||||
{
|
||||
if (e.Item != null && e.Item.Tag is ImageEffect)
|
||||
if (e.Item != null && e.Item.Focused && e.Item.Tag is ImageEffect)
|
||||
{
|
||||
ImageEffect imageEffect = (ImageEffect)e.Item.Tag;
|
||||
imageEffect.Enabled = e.Item.Checked;
|
||||
|
@ -608,6 +631,33 @@ private void eiImageEffects_ImportRequested(object obj)
|
|||
}
|
||||
}
|
||||
|
||||
private void btnPackager_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImageEffectPreset preset = GetSelectedPreset();
|
||||
|
||||
if (preset != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(preset.Name))
|
||||
{
|
||||
// TODO: Translate
|
||||
MessageBox.Show("Preset name cannot be empty.", "ShareX - " + "Missing preset name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
string json = eiImageEffects.Serialize(preset);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
using (ImageEffectPackagerForm packagerForm = new ImageEffectPackagerForm(json, preset.Name,
|
||||
HelpersOptions.ShareXSpecialFolders["ShareXImageEffects"]))
|
||||
{
|
||||
packagerForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiLoadImageFromFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
string filePath = ImageHelpers.OpenImageFileDialog();
|
||||
|
|
|
@ -118,15 +118,15 @@
|
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="pgSettings.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left</value>
|
||||
<data name="pgSettings.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="pgSettings.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>184, 72</value>
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="pgSettings.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>336, 424</value>
|
||||
<value>330, 424</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="pgSettings.TabIndex" type="System.Int32, mscorlib">
|
||||
|
@ -139,10 +139,10 @@
|
|||
<value>System.Windows.Forms.PropertyGrid, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>pgSettings.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
<value>scMain.Panel1</value>
|
||||
</data>
|
||||
<data name=">>pgSettings.ZOrder" xml:space="preserve">
|
||||
<value>20</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="btnAdd.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>408, 40</value>
|
||||
|
@ -166,14 +166,11 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnAdd.ZOrder" xml:space="preserve">
|
||||
<value>19</value>
|
||||
<value>21</value>
|
||||
</data>
|
||||
<data name="lvEffects.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left</value>
|
||||
</data>
|
||||
<data name="chEffect.Width" type="System.Int32, mscorlib">
|
||||
<value>164</value>
|
||||
</data>
|
||||
<data name="lvEffects.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>8, 72</value>
|
||||
</data>
|
||||
|
@ -193,7 +190,10 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lvEffects.ZOrder" xml:space="preserve">
|
||||
<value>21</value>
|
||||
<value>22</value>
|
||||
</data>
|
||||
<data name="chEffect.Width" type="System.Int32, mscorlib">
|
||||
<value>164</value>
|
||||
</data>
|
||||
<data name="btnRemove.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>520, 40</value>
|
||||
|
@ -217,7 +217,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnRemove.ZOrder" xml:space="preserve">
|
||||
<value>18</value>
|
||||
<value>20</value>
|
||||
</data>
|
||||
<data name="btnClear.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>744, 40</value>
|
||||
|
@ -241,7 +241,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnClear.ZOrder" xml:space="preserve">
|
||||
<value>17</value>
|
||||
<value>19</value>
|
||||
</data>
|
||||
<data name="btnDuplicate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>632, 40</value>
|
||||
|
@ -265,7 +265,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnDuplicate.ZOrder" xml:space="preserve">
|
||||
<value>16</value>
|
||||
<value>18</value>
|
||||
</data>
|
||||
<data name="btnSaveImage.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
|
@ -274,13 +274,13 @@
|
|||
<value>True</value>
|
||||
</data>
|
||||
<data name="btnSaveImage.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>328, 504</value>
|
||||
<value>456, 504</value>
|
||||
</data>
|
||||
<data name="btnSaveImage.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>120, 24</value>
|
||||
</data>
|
||||
<data name="btnSaveImage.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>19</value>
|
||||
<value>20</value>
|
||||
</data>
|
||||
<data name="btnSaveImage.Text" xml:space="preserve">
|
||||
<value>Save image...</value>
|
||||
|
@ -298,7 +298,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnSaveImage.ZOrder" xml:space="preserve">
|
||||
<value>15</value>
|
||||
<value>17</value>
|
||||
</data>
|
||||
<data name="eiImageEffects.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
|
@ -322,16 +322,16 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>eiImageEffects.ZOrder" xml:space="preserve">
|
||||
<value>14</value>
|
||||
<value>16</value>
|
||||
</data>
|
||||
<data name="pbResult.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
<data name="pbResult.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="pbResult.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>528, 72</value>
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="pbResult.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>432, 424</value>
|
||||
<value>440, 424</value>
|
||||
</data>
|
||||
<data name="pbResult.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>16</value>
|
||||
|
@ -343,10 +343,10 @@
|
|||
<value>ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.1.1.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>pbResult.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
<value>scMain.Panel2</value>
|
||||
</data>
|
||||
<data name=">>pbResult.ZOrder" xml:space="preserve">
|
||||
<value>22</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="cmsEffects.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
|
@ -364,23 +364,11 @@
|
|||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="mbLoadImage.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>200, 504</value>
|
||||
<value>328, 504</value>
|
||||
</data>
|
||||
<metadata name="cmsLoadImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>126, 17</value>
|
||||
</metadata>
|
||||
<data name="tsmiLoadImageFromFile.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>130, 22</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromFile.Text" xml:space="preserve">
|
||||
<value>From file...</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromClipboard.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>130, 22</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromClipboard.Text" xml:space="preserve">
|
||||
<value>From clipboard</value>
|
||||
</data>
|
||||
<data name="cmsLoadImage.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>131, 48</value>
|
||||
</data>
|
||||
|
@ -394,7 +382,7 @@
|
|||
<value>120, 24</value>
|
||||
</data>
|
||||
<data name="mbLoadImage.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>18</value>
|
||||
<value>19</value>
|
||||
</data>
|
||||
<data name="mbLoadImage.Text" xml:space="preserve">
|
||||
<value>Load image</value>
|
||||
|
@ -412,7 +400,19 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>mbLoadImage.ZOrder" xml:space="preserve">
|
||||
<value>13</value>
|
||||
<value>15</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromFile.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>130, 22</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromFile.Text" xml:space="preserve">
|
||||
<value>From file...</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromClipboard.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>130, 22</value>
|
||||
</data>
|
||||
<data name="tsmiLoadImageFromClipboard.Text" xml:space="preserve">
|
||||
<value>From clipboard</value>
|
||||
</data>
|
||||
<data name="btnAddPreset.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>408, 8</value>
|
||||
|
@ -436,7 +436,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnAddPreset.ZOrder" xml:space="preserve">
|
||||
<value>12</value>
|
||||
<value>14</value>
|
||||
</data>
|
||||
<data name="btnRemovePreset.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>552, 8</value>
|
||||
|
@ -460,7 +460,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnRemovePreset.ZOrder" xml:space="preserve">
|
||||
<value>11</value>
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name="cbPresets.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>104, 10</value>
|
||||
|
@ -481,7 +481,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbPresets.ZOrder" xml:space="preserve">
|
||||
<value>10</value>
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="lblPresetName.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -508,7 +508,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblPresetName.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="txtPresetName.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>104, 42</value>
|
||||
|
@ -529,7 +529,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>txtPresetName.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
|
@ -556,7 +556,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnClose.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="btnOK.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
|
@ -586,19 +586,19 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnOK.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="btnUploadImage.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnUploadImage.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>456, 504</value>
|
||||
<value>584, 504</value>
|
||||
</data>
|
||||
<data name="btnUploadImage.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>120, 24</value>
|
||||
</data>
|
||||
<data name="btnUploadImage.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>20</value>
|
||||
<value>21</value>
|
||||
</data>
|
||||
<data name="btnUploadImage.Text" xml:space="preserve">
|
||||
<value>Upload image</value>
|
||||
|
@ -616,7 +616,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnUploadImage.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="btnRefresh.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>856, 40</value>
|
||||
|
@ -640,7 +640,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnRefresh.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="btnDuplicatePreset.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>696, 8</value>
|
||||
|
@ -664,7 +664,7 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnDuplicatePreset.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="lblPresets.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -691,7 +691,88 @@
|
|||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblPresets.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnPackager.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnPackager.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>200, 504</value>
|
||||
</data>
|
||||
<data name="btnPackager.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>120, 24</value>
|
||||
</data>
|
||||
<data name="btnPackager.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>18</value>
|
||||
</data>
|
||||
<data name="btnPackager.Text" xml:space="preserve">
|
||||
<value>Packager...</value>
|
||||
</data>
|
||||
<data name=">>btnPackager.Name" xml:space="preserve">
|
||||
<value>btnPackager</value>
|
||||
</data>
|
||||
<data name=">>btnPackager.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>btnPackager.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnPackager.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="scMain.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="scMain.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>184, 72</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel1.Name" xml:space="preserve">
|
||||
<value>scMain.Panel1</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel1.Parent" xml:space="preserve">
|
||||
<value>scMain</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel2.Name" xml:space="preserve">
|
||||
<value>scMain.Panel2</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel2.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel2.Parent" xml:space="preserve">
|
||||
<value>scMain</value>
|
||||
</data>
|
||||
<data name=">>scMain.Panel2.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="scMain.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>776, 424</value>
|
||||
</data>
|
||||
<data name="scMain.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>330</value>
|
||||
</data>
|
||||
<data name="scMain.SplitterWidth" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="scMain.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>22</value>
|
||||
</data>
|
||||
<data name=">>scMain.Name" xml:space="preserve">
|
||||
<value>scMain</value>
|
||||
</data>
|
||||
<data name=">>scMain.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=13.1.1.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>scMain.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>scMain.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -130,6 +131,13 @@
|
|||
<Compile Include="Adjustments\Hue.cs" />
|
||||
<Compile Include="Adjustments\Inverse.cs" />
|
||||
<Compile Include="Adjustments\Saturation.cs" />
|
||||
<Compile Include="ImageEffectPackager.cs" />
|
||||
<Compile Include="ImageEffectPackagerForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImageEffectPackagerForm.Designer.cs">
|
||||
<DependentUpon>ImageEffectPackagerForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ImageEffectPreset.cs" />
|
||||
<Compile Include="Manipulations\AutoCrop.cs" />
|
||||
<Compile Include="Manipulations\Crop.cs" />
|
||||
|
@ -174,6 +182,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ImageEffectPackagerForm.resx">
|
||||
<DependentUpon>ImageEffectPackagerForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImageEffectsForm.de.resx">
|
||||
<DependentUpon>ImageEffectsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ShareX.ImageEffectsLib
|
|||
public partial class WatermarkForm : Form
|
||||
{
|
||||
private WatermarkConfig config;
|
||||
private bool IsGuiReady;
|
||||
private bool isReady;
|
||||
|
||||
public WatermarkForm(WatermarkConfig watermarkConfig)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ private void WatermarkUI_Load(object sender, EventArgs e)
|
|||
|
||||
txtWatermarkImageLocation.Text = config.Image.ImageLocation;
|
||||
|
||||
IsGuiReady = true;
|
||||
isReady = true;
|
||||
UpdatePreview();
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ private void WatermarkUI_Resize(object sender, EventArgs e)
|
|||
|
||||
private void UpdatePreview()
|
||||
{
|
||||
if (IsGuiReady)
|
||||
if (isReady)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(pbPreview.ClientSize.Width, pbPreview.ClientSize.Height))
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.MediaLib
|
||||
|
@ -59,7 +58,7 @@ public static bool ExtractFFmpeg(string archivePath, string extractPath)
|
|||
{
|
||||
try
|
||||
{
|
||||
ZipManager.Extract(archivePath, extractPath, false, new List<string>() { "ffmpeg.exe" });
|
||||
ZipManager.Extract(archivePath, extractPath, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
|
|
@ -178,7 +178,7 @@ private string GetOutputDirectory()
|
|||
break;
|
||||
}
|
||||
|
||||
Helpers.CreateDirectoryFromDirectoryPath(directory);
|
||||
Helpers.CreateDirectory(directory);
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
|
|
@ -318,15 +318,6 @@ public enum ImageEditorStartMode // Localized
|
|||
Fullscreen
|
||||
}
|
||||
|
||||
public enum ImageEditorInterpolationMode // Localized
|
||||
{
|
||||
HighQualityBicubic,
|
||||
Bicubic,
|
||||
HighQualityBilinear,
|
||||
Bilinear,
|
||||
NearestNeighbor
|
||||
}
|
||||
|
||||
public enum ImageInsertMethod
|
||||
{
|
||||
Center,
|
||||
|
|
|
@ -33,12 +33,12 @@ namespace ShareX.ScreenCaptureLib
|
|||
public partial class ImageSizeForm : Form
|
||||
{
|
||||
public Size ImageSize { get; private set; }
|
||||
public ImageEditorInterpolationMode InterpolationMode { get; private set; }
|
||||
public ImageInterpolationMode InterpolationMode { get; private set; }
|
||||
|
||||
private double widthRatio, heightRatio;
|
||||
private bool ignoreValueChanged = true;
|
||||
|
||||
public ImageSizeForm(Size size, ImageEditorInterpolationMode interpolationMode)
|
||||
public ImageSizeForm(Size size, ImageInterpolationMode interpolationMode)
|
||||
{
|
||||
InitializeComponent();
|
||||
ShareXResources.ApplyTheme(this);
|
||||
|
@ -56,7 +56,7 @@ public ImageSizeForm(Size size, ImageEditorInterpolationMode interpolationMode)
|
|||
nudWidth.TextChanged += NudWidth_TextChanged;
|
||||
nudHeight.TextChanged += NudHeight_TextChanged;
|
||||
|
||||
cbResampling.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageEditorInterpolationMode>());
|
||||
cbResampling.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageInterpolationMode>());
|
||||
cbResampling.SelectedIndex = (int)InterpolationMode;
|
||||
|
||||
ignoreValueChanged = false;
|
||||
|
@ -119,7 +119,7 @@ private void cbAspectRatio_CheckedChanged(object sender, EventArgs e)
|
|||
|
||||
private void cbResampling_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
InterpolationMode = (ImageEditorInterpolationMode)cbResampling.SelectedIndex;
|
||||
InterpolationMode = (ImageInterpolationMode)cbResampling.SelectedIndex;
|
||||
}
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -747,6 +747,9 @@
|
|||
<data name="tsmiAlignmentBottom.Text" xml:space="preserve">
|
||||
<value>Bottom</value>
|
||||
</data>
|
||||
<data name="lblTip.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="lblTip.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
|
|
|
@ -89,7 +89,7 @@ public class RegionCaptureOptions
|
|||
public WindowState ImageEditorWindowState = new WindowState();
|
||||
public bool AutoCloseEditorOnTask = false;
|
||||
public bool ShowEditorPanTip = true;
|
||||
public ImageEditorInterpolationMode ImageEditorResizeInterpolationMode = ImageEditorInterpolationMode.Bicubic;
|
||||
public ImageInterpolationMode ImageEditorResizeInterpolationMode = ImageInterpolationMode.Bicubic;
|
||||
public Size EditorNewImageSize = new Size(800, 600);
|
||||
public bool EditorNewImageTransparent = false;
|
||||
public Color EditorNewImageBackgroundColor = Color.White;
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
|
@ -74,7 +75,7 @@ public class AnnotationOptions
|
|||
public Color TextFillColor { get; set; } = PrimaryColor;
|
||||
|
||||
// Image drawing
|
||||
public ImageEditorInterpolationMode ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor;
|
||||
public ImageInterpolationMode ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;
|
||||
public string LastImageFilePath { get; set; }
|
||||
|
||||
// Step drawing
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class ImageDrawingShape : BaseDrawingShape
|
|||
public override ShapeType ShapeType { get; } = ShapeType.DrawingImage;
|
||||
|
||||
public Image Image { get; protected set; }
|
||||
public ImageEditorInterpolationMode ImageInterpolationMode { get; protected set; }
|
||||
public ImageInterpolationMode ImageInterpolationMode { get; protected set; }
|
||||
|
||||
public override void OnConfigLoad()
|
||||
{
|
||||
|
@ -79,7 +80,7 @@ protected void DrawImage(Graphics g)
|
|||
if (Image != null)
|
||||
{
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
g.InterpolationMode = Manager.GetInterpolationMode(ImageInterpolationMode);
|
||||
g.InterpolationMode = ImageHelpers.GetInterpolationMode(ImageInterpolationMode);
|
||||
|
||||
g.DrawImage(Image, Rectangle);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
@ -34,7 +35,7 @@ public class MagnifyDrawingShape : EllipseDrawingShape
|
|||
public override ShapeType ShapeType { get; } = ShapeType.DrawingMagnify;
|
||||
|
||||
public int MagnifyStrength { get; set; } = 200;
|
||||
public ImageEditorInterpolationMode ImageInterpolationMode { get; set; }
|
||||
public ImageInterpolationMode ImageInterpolationMode { get; set; }
|
||||
|
||||
public MagnifyDrawingShape()
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ public override void OnConfigSave()
|
|||
public override void OnDraw(Graphics g)
|
||||
{
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
g.InterpolationMode = Manager.GetInterpolationMode(ImageInterpolationMode);
|
||||
g.InterpolationMode = ImageHelpers.GetInterpolationMode(ImageInterpolationMode);
|
||||
|
||||
using (GraphicsPath gp = new GraphicsPath())
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ public class StickerDrawingShape : ImageDrawingShape
|
|||
|
||||
public override void OnConfigLoad()
|
||||
{
|
||||
ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor;
|
||||
ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;
|
||||
}
|
||||
|
||||
public override void OnConfigSave()
|
||||
|
|
|
@ -1928,7 +1928,7 @@ private void ChangeImageSize()
|
|||
|
||||
if (size != oldSize)
|
||||
{
|
||||
InterpolationMode interpolationMode = GetInterpolationMode(Options.ImageEditorResizeInterpolationMode);
|
||||
InterpolationMode interpolationMode = ImageHelpers.GetInterpolationMode(Options.ImageEditorResizeInterpolationMode);
|
||||
Bitmap bmp = ImageHelpers.ResizeImage(Form.Canvas, size, interpolationMode);
|
||||
|
||||
if (bmp != null)
|
||||
|
@ -1942,24 +1942,6 @@ private void ChangeImageSize()
|
|||
Form.Resume();
|
||||
}
|
||||
|
||||
internal InterpolationMode GetInterpolationMode(ImageEditorInterpolationMode interpolationMode)
|
||||
{
|
||||
switch (interpolationMode)
|
||||
{
|
||||
default:
|
||||
case ImageEditorInterpolationMode.HighQualityBicubic:
|
||||
return InterpolationMode.HighQualityBicubic;
|
||||
case ImageEditorInterpolationMode.Bicubic:
|
||||
return InterpolationMode.Bicubic;
|
||||
case ImageEditorInterpolationMode.HighQualityBilinear:
|
||||
return InterpolationMode.HighQualityBilinear;
|
||||
case ImageEditorInterpolationMode.Bilinear:
|
||||
return InterpolationMode.Bilinear;
|
||||
case ImageEditorInterpolationMode.NearestNeighbor:
|
||||
return InterpolationMode.NearestNeighbor;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeCanvasSize()
|
||||
{
|
||||
Form.Pause();
|
||||
|
|
|
@ -506,10 +506,10 @@ internal void CreateToolbar()
|
|||
tsddbShapeOptions.DropDownItems.Add(tslnudCornerRadius);
|
||||
|
||||
tscbImageInterpolationMode = new ToolStripLabeledComboBox(Resources.ShapeManager_CreateToolbar_InterpolationMode);
|
||||
tscbImageInterpolationMode.Content.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageEditorInterpolationMode>());
|
||||
tscbImageInterpolationMode.Content.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageInterpolationMode>());
|
||||
tscbImageInterpolationMode.Content.SelectedIndexChanged += (sender, e) =>
|
||||
{
|
||||
AnnotationOptions.ImageInterpolationMode = (ImageEditorInterpolationMode)tscbImageInterpolationMode.Content.SelectedIndex;
|
||||
AnnotationOptions.ImageInterpolationMode = (ImageInterpolationMode)tscbImageInterpolationMode.Content.SelectedIndex;
|
||||
tscbImageInterpolationMode.Invalidate();
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
|
|
|
@ -25,7 +25,6 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -343,7 +342,7 @@ private static void CopyFFmpeg(string destination, bool include32bit, bool inclu
|
|||
if (!File.Exists(FFmpeg32bit))
|
||||
{
|
||||
string filename = SetupHelpers.DownloadFile("https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-4.2.2-win32-static.zip");
|
||||
ZipManager.Extract(filename, ".", false, new List<string>() { "ffmpeg.exe" });
|
||||
ZipManager.Extract(filename, ".", false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
|
||||
File.Move("ffmpeg.exe", FFmpeg32bit);
|
||||
}
|
||||
|
||||
|
@ -355,7 +354,7 @@ private static void CopyFFmpeg(string destination, bool include32bit, bool inclu
|
|||
if (!File.Exists(FFmpeg64bit))
|
||||
{
|
||||
string filename = SetupHelpers.DownloadFile("https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-4.2.2-win64-static.zip");
|
||||
ZipManager.Extract(filename, ".", false, new List<string>() { "ffmpeg.exe" });
|
||||
ZipManager.Extract(filename, ".", false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
|
||||
File.Move("ffmpeg.exe", FFmpeg64bit);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SharedAssemblyInfo.cs">
|
||||
|
|
|
@ -151,7 +151,7 @@ private void SetPermissions(string fileID, GoogleDrivePermissionRole role, Googl
|
|||
{
|
||||
if (!CheckAuthorization()) return;
|
||||
|
||||
string url = string.Format("https://www.googleapis.com/drive/v3/files/{0}/permissions", fileID);
|
||||
string url = string.Format("https://www.googleapis.com/drive/v3/files/{0}/permissions?supportsAllDrives=true", fileID);
|
||||
|
||||
string json = JsonConvert.SerializeObject(new
|
||||
{
|
||||
|
|
|
@ -61,6 +61,8 @@ public AboutForm()
|
|||
#else
|
||||
if (!Program.PortableApps)
|
||||
{
|
||||
uclUpdate.UpdateLoadingImage();
|
||||
|
||||
UpdateChecker updateChecker = Program.UpdateManager.CreateUpdateChecker();
|
||||
uclUpdate.CheckUpdate(updateChecker);
|
||||
}
|
||||
|
|
|
@ -315,13 +315,6 @@ public void UpdateControls()
|
|||
|
||||
InitHotkeys();
|
||||
|
||||
#if !WindowsStore
|
||||
if (!Program.Portable && !IntegrationHelpers.CheckCustomUploaderExtension())
|
||||
{
|
||||
IntegrationHelpers.CreateCustomUploaderExtension(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
IsReady = true;
|
||||
}
|
||||
|
||||
|
@ -957,6 +950,7 @@ private void AfterApplicationSettingsJobs()
|
|||
HelpersOptions.RotateImageByExifOrientationData = Program.Settings.RotateImageByExifOrientationData;
|
||||
HelpersOptions.BrowserPath = Program.Settings.BrowserPath;
|
||||
HelpersOptions.RecentColors = Program.Settings.RecentColors;
|
||||
Program.UpdateHelpersSpecialFolders();
|
||||
|
||||
TaskManager.RecentManager.MaxCount = Program.Settings.RecentTasksMaxCount;
|
||||
|
||||
|
@ -1057,19 +1051,29 @@ public void UseCommandLineArgs(List<CLICommand> commands)
|
|||
|
||||
foreach (CLICommand command in commands)
|
||||
{
|
||||
DebugHelper.WriteLine("CommandLine: " + command.Command);
|
||||
DebugHelper.WriteLine("CommandLine: " + command);
|
||||
|
||||
if (command.IsCommand && command.Command.Equals("CustomUploader", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (command.IsCommand)
|
||||
{
|
||||
TaskHelpers.AddCustomUploader(command.Parameter);
|
||||
if (command.Command.Equals("CustomUploader", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
TaskHelpers.ImportCustomUploader(command.Parameter);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command.IsCommand && (CheckCLIHotkey(command) || CheckCLIWorkflow(command)))
|
||||
if (command.Command.Equals("ImageEffect", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
TaskHelpers.ImportImageEffect(command.Parameter);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CheckCLIHotkey(command) || CheckCLIWorkflow(command))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (URLHelpers.IsValidURL(command.Command))
|
||||
{
|
||||
|
|
|
@ -813,12 +813,7 @@ private void chkShowImageEffectsWindowAfterCapture_CheckedChanged(object sender,
|
|||
|
||||
private void btnImageEffects_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (ImageEffectsForm imageEffectsForm = new ImageEffectsForm(null, TaskSettings.ImageSettings.ImageEffectPresets,
|
||||
TaskSettings.ImageSettings.SelectedImageEffectPreset))
|
||||
{
|
||||
imageEffectsForm.ShowDialog();
|
||||
TaskSettings.ImageSettings.SelectedImageEffectPreset = imageEffectsForm.SelectedPresetIndex;
|
||||
}
|
||||
TaskHelpers.OpenImageEffectsSingleton(TaskSettings);
|
||||
}
|
||||
|
||||
private void nudThumbnailWidth_ValueChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -62,6 +62,15 @@ public static class IntegrationHelpers
|
|||
private static readonly string ShellCustomUploaderCommandPath = $@"{ShellCustomUploaderAssociatePath}\shell\open\command";
|
||||
private static readonly string ShellCustomUploaderCommandValue = $"{ApplicationPath} -CustomUploader \"%1\"";
|
||||
|
||||
private static readonly string ShellImageEffectExtensionPath = @"Software\Classes\.sxie";
|
||||
private static readonly string ShellImageEffectExtensionValue = "ShareX.sxie";
|
||||
private static readonly string ShellImageEffectAssociatePath = $@"Software\Classes\{ShellImageEffectExtensionValue}";
|
||||
private static readonly string ShellImageEffectAssociateValue = "ShareX image effect";
|
||||
private static readonly string ShellImageEffectIconPath = $@"{ShellImageEffectAssociatePath}\DefaultIcon";
|
||||
private static readonly string ShellImageEffectIconValue = $"{ApplicationPath},0";
|
||||
private static readonly string ShellImageEffectCommandPath = $@"{ShellImageEffectAssociatePath}\shell\open\command";
|
||||
private static readonly string ShellImageEffectCommandValue = $"{ApplicationPath} -ImageEffect \"%1\"";
|
||||
|
||||
private static readonly string ChromeNativeMessagingHosts = @"SOFTWARE\Google\Chrome\NativeMessagingHosts\com.getsharex.sharex";
|
||||
private static readonly string FirefoxNativeMessagingHosts = @"SOFTWARE\Mozilla\NativeMessagingHosts\ShareX";
|
||||
|
||||
|
@ -214,6 +223,57 @@ private static void UnregisterCustomUploaderExtension()
|
|||
RegistryHelpers.RemoveRegistry(ShellCustomUploaderAssociatePath, true);
|
||||
}
|
||||
|
||||
public static bool CheckImageEffectExtension()
|
||||
{
|
||||
try
|
||||
{
|
||||
return RegistryHelpers.CheckRegistry(ShellImageEffectExtensionPath, null, ShellImageEffectExtensionValue) &&
|
||||
RegistryHelpers.CheckRegistry(ShellImageEffectCommandPath, null, ShellImageEffectCommandValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CreateImageEffectExtension(bool create)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (create)
|
||||
{
|
||||
UnregisterImageEffectExtension();
|
||||
RegisterImageEffectExtension();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnregisterImageEffectExtension();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterImageEffectExtension()
|
||||
{
|
||||
RegistryHelpers.CreateRegistry(ShellImageEffectExtensionPath, ShellImageEffectExtensionValue);
|
||||
RegistryHelpers.CreateRegistry(ShellImageEffectAssociatePath, ShellImageEffectAssociateValue);
|
||||
RegistryHelpers.CreateRegistry(ShellImageEffectIconPath, ShellImageEffectIconValue);
|
||||
RegistryHelpers.CreateRegistry(ShellImageEffectCommandPath, ShellImageEffectCommandValue);
|
||||
|
||||
NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
private static void UnregisterImageEffectExtension()
|
||||
{
|
||||
RegistryHelpers.RemoveRegistry(ShellImageEffectExtensionPath);
|
||||
RegistryHelpers.RemoveRegistry(ShellImageEffectAssociatePath, true);
|
||||
}
|
||||
|
||||
public static bool CheckChromeExtensionSupport()
|
||||
{
|
||||
try
|
||||
|
@ -401,6 +461,7 @@ public static void Uninstall()
|
|||
CreateShellContextMenuButton(false);
|
||||
CreateEditShellContextMenuButton(false);
|
||||
CreateCustomUploaderExtension(false);
|
||||
CreateImageEffectExtension(false);
|
||||
CreateSendToMenuButton(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,6 +232,7 @@ public static string ScreenshotsFolder
|
|||
}
|
||||
|
||||
public static string ToolsFolder => Path.Combine(PersonalFolder, "Tools");
|
||||
public static string ImageEffectsFolder => Path.Combine(PersonalFolder, "ImageEffects");
|
||||
public static string ScreenRecorderCacheFilePath => Path.Combine(PersonalFolder, "ScreenRecorder.avi");
|
||||
public static string DefaultFFmpegFilePath => Path.Combine(ToolsFolder, "ffmpeg.exe");
|
||||
public static string ChromeHostManifestFilePath => Path.Combine(ToolsFolder, "Chrome-host-manifest.json");
|
||||
|
@ -315,6 +316,8 @@ private static void Run()
|
|||
|
||||
IgnoreHotkeyWarning = CLI.IsCommandExist("NoHotkeys");
|
||||
|
||||
CreateParentFolders();
|
||||
RegisterExtensions();
|
||||
CheckPuushMode();
|
||||
DebugWriteFlags();
|
||||
CleanTempFiles();
|
||||
|
@ -323,10 +326,9 @@ private static void Run()
|
|||
|
||||
Uploader.UpdateServicePointManager();
|
||||
UpdateManager = new GitHubUpdateManager("ShareX", "ShareX", Dev, Portable);
|
||||
|
||||
LanguageHelper.ChangeLanguage(Settings.Language);
|
||||
|
||||
Helpers.TryFixHandCursor();
|
||||
|
||||
DebugHelper.WriteLine("MainForm init started.");
|
||||
MainForm = new MainForm();
|
||||
DebugHelper.WriteLine("MainForm init finished.");
|
||||
|
@ -470,6 +472,43 @@ private static void UpdatePersonalPath()
|
|||
}
|
||||
}
|
||||
|
||||
private static void CreateParentFolders()
|
||||
{
|
||||
if (!Sandbox && Directory.Exists(PersonalFolder))
|
||||
{
|
||||
Helpers.CreateDirectory(SettingManager.BackupFolder);
|
||||
Helpers.CreateDirectory(ImageEffectsFolder);
|
||||
Helpers.CreateDirectory(LogsFolder);
|
||||
Helpers.CreateDirectory(ScreenshotsParentFolder);
|
||||
Helpers.CreateDirectory(ToolsFolder);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterExtensions()
|
||||
{
|
||||
#if !WindowsStore
|
||||
if (!Portable)
|
||||
{
|
||||
if (!IntegrationHelpers.CheckCustomUploaderExtension())
|
||||
{
|
||||
IntegrationHelpers.CreateCustomUploaderExtension(true);
|
||||
}
|
||||
|
||||
if (!IntegrationHelpers.CheckImageEffectExtension())
|
||||
{
|
||||
IntegrationHelpers.CreateImageEffectExtension(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void UpdateHelpersSpecialFolders()
|
||||
{
|
||||
Dictionary<string, string> specialFolders = new Dictionary<string, string>();
|
||||
specialFolders.Add("ShareXImageEffects", ImageEffectsFolder);
|
||||
HelpersOptions.ShareXSpecialFolders = specialFolders;
|
||||
}
|
||||
|
||||
private static void MigratePersonalPathConfig()
|
||||
{
|
||||
if (File.Exists(PreviousPersonalPathConfigFilePath))
|
||||
|
|
|
@ -352,17 +352,17 @@ public static bool Export(string archivePath, bool settings, bool history)
|
|||
|
||||
if (settings)
|
||||
{
|
||||
files.Add(ApplicationConfigFilename);
|
||||
files.Add(HotkeysConfigFilename);
|
||||
files.Add(UploadersConfigFilename);
|
||||
files.Add(ApplicationConfigFilePath);
|
||||
files.Add(HotkeysConfigFilePath);
|
||||
files.Add(UploadersConfigFilePath);
|
||||
}
|
||||
|
||||
if (history)
|
||||
{
|
||||
files.Add(Program.HistoryFilename);
|
||||
files.Add(Program.HistoryFilePath);
|
||||
}
|
||||
|
||||
ZipManager.Compress(archivePath, files, Program.PersonalFolder);
|
||||
ZipManager.Compress(archivePath, files);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
|
|
@ -578,7 +578,7 @@ public static void PrintImage(Image img)
|
|||
}
|
||||
}
|
||||
|
||||
public static Bitmap AddImageEffects(Bitmap bmp, TaskSettingsImage taskSettingsImage)
|
||||
public static Bitmap ApplyImageEffects(Bitmap bmp, TaskSettingsImage taskSettingsImage)
|
||||
{
|
||||
if (bmp != null && !bmp.PixelFormat.HasFlag(PixelFormat.Indexed))
|
||||
{
|
||||
|
@ -1061,6 +1061,28 @@ public static void OpenImageEffects(TaskSettings taskSettings = null)
|
|||
}
|
||||
}
|
||||
|
||||
public static ImageEffectsForm OpenImageEffectsSingleton(TaskSettings taskSettings = null)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = Program.DefaultTaskSettings;
|
||||
|
||||
bool firstInstance = !ImageEffectsForm.IsInstanceActive;
|
||||
|
||||
ImageEffectsForm imageEffectsForm = ImageEffectsForm.GetFormInstance(taskSettings.ImageSettings.ImageEffectPresets,
|
||||
taskSettings.ImageSettings.SelectedImageEffectPreset);
|
||||
|
||||
if (firstInstance)
|
||||
{
|
||||
imageEffectsForm.FormClosed += (sender, e) => taskSettings.ImageSettings.SelectedImageEffectPreset = imageEffectsForm.SelectedPresetIndex;
|
||||
imageEffectsForm.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
imageEffectsForm.ForceActivate();
|
||||
}
|
||||
|
||||
return imageEffectsForm;
|
||||
}
|
||||
|
||||
public static void OpenMonitorTest()
|
||||
{
|
||||
using (MonitorTestForm monitorTestForm = new MonitorTestForm())
|
||||
|
@ -1566,7 +1588,7 @@ public static Screenshot GetScreenshot(TaskSettings taskSettings = null)
|
|||
return screenshot;
|
||||
}
|
||||
|
||||
public static void AddCustomUploader(string filePath)
|
||||
public static void ImportCustomUploader(string filePath)
|
||||
{
|
||||
if (Program.UploadersConfig != null)
|
||||
{
|
||||
|
@ -1595,7 +1617,7 @@ public static void AddCustomUploader(string filePath)
|
|||
if (cui.DestinationType.HasFlag(CustomUploaderDestinationType.TextUploader)) destinations.Add("texts");
|
||||
if (cui.DestinationType.HasFlag(CustomUploaderDestinationType.FileUploader)) destinations.Add("files");
|
||||
if (cui.DestinationType.HasFlag(CustomUploaderDestinationType.URLShortener) ||
|
||||
(cui.DestinationType.HasFlag(CustomUploaderDestinationType.URLSharingService))) destinations.Add("urls");
|
||||
cui.DestinationType.HasFlag(CustomUploaderDestinationType.URLSharingService)) destinations.Add("urls");
|
||||
|
||||
string destinationsText = string.Join("/", destinations);
|
||||
|
||||
|
@ -1666,6 +1688,30 @@ public static void AddCustomUploader(string filePath)
|
|||
}
|
||||
}
|
||||
|
||||
public static void ImportImageEffect(string filePath)
|
||||
{
|
||||
string configJson = null;
|
||||
|
||||
try
|
||||
{
|
||||
configJson = ImageEffectPackager.ExtractPackage(filePath, Program.ImageEffectsFolder);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.ShowError();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(configJson))
|
||||
{
|
||||
ImageEffectsForm imageEffectsForm = OpenImageEffectsSingleton(Program.DefaultTaskSettings);
|
||||
|
||||
if (imageEffectsForm != null)
|
||||
{
|
||||
imageEffectsForm.ImportImageEffect(configJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenActionsToolbar()
|
||||
{
|
||||
ActionsToolbarForm.Instance.ForceActivate();
|
||||
|
|
|
@ -575,7 +575,7 @@ private bool DoAfterCaptureJobs()
|
|||
|
||||
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
|
||||
{
|
||||
Image = TaskHelpers.AddImageEffects(Image, Info.TaskSettings.ImageSettingsReference);
|
||||
Image = TaskHelpers.ApplyImageEffects(Image, Info.TaskSettings.ImageSettingsReference);
|
||||
|
||||
if (Image == null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue