Revert "Merge branch 'master' into tweaks"

This reverts commit 162badae3b, reversing
changes made to e0f2812f3d.
This commit is contained in:
Michael Delpach 2020-06-29 06:10:21 +08:00
parent 162badae3b
commit 195c0f2f8a
58 changed files with 327 additions and 1241 deletions

View file

@ -23,11 +23,11 @@
#endregion License Information (GPL v3)
using Newtonsoft.Json;
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using System.Security.Permissions;
using System.IO;
using System.IO.Pipes;
using System.Text;
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 EventName = string.Format("{0}-{1}-{2}", Environment.MachineName, Environment.UserName, AppName);
private static readonly string SemaphoreName = string.Format("{0}{1}", EventName, "Semaphore");
private static readonly string PipeName = $"{Environment.MachineName}-{Environment.UserName}-{AppName}";
private static readonly string SemaphoreName = PipeName + "Semaphore";
public bool IsSingleInstance { get; private set; }
public bool IsFirstInstance { get; private set; }
private Mutex mutex;
private Semaphore semaphore;
private IpcServerChannel serverChannel;
private NamedPipeServerStream pipeServer;
public ApplicationInstanceManager(bool isSingleInstance, string[] args, EventHandler<InstanceCallbackEventArgs> callback)
{
@ -75,44 +75,28 @@ public void Dispose()
{
if (IsFirstInstance)
{
if (mutex != null)
{
mutex.ReleaseMutex();
}
if (serverChannel != null)
{
ChannelServices.UnregisterChannel(serverChannel);
}
if (semaphore != null)
{
semaphore.Close();
}
mutex.ReleaseMutex();
}
mutex.Dispose();
semaphore?.Dispose();
pipeServer?.Dispose();
}
private void CreateFirstInstance(EventHandler<InstanceCallbackEventArgs> callback)
{
try
{
bool createdNew;
using (EventWaitHandle eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, EventName, out createdNew))
semaphore = new Semaphore(1, 1, SemaphoreName, out var 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
if (!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 EventWaitHandle was created
if (!createdNew)
{
return;
}
semaphore = new Semaphore(1, 1, SemaphoreName);
ThreadPool.RegisterWaitForSingleObject(eventWaitHandle, WaitOrTimerCallback, callback, Timeout.Infinite, false);
RegisterRemoteType(AppName);
return;
}
CreateServer(callback);
}
catch (Exception e)
{
@ -124,19 +108,11 @@ private void CreateMultipleInstance(string[] args)
{
try
{
InstanceProxy.CommandLineArgs = args;
semaphore = Semaphore.OpenExisting(SemaphoreName);
using (EventWaitHandle eventWaitHandle = EventWaitHandle.OpenExisting(EventName))
{
semaphore = Semaphore.OpenExisting(SemaphoreName);
semaphore.WaitOne();
UpdateRemoteObject(AppName);
if (eventWaitHandle != null)
{
eventWaitHandle.Set();
}
}
// Wait until the server is ready to accept data
semaphore.WaitOne();
SendDataToServer(args);
}
catch (Exception e)
{
@ -146,69 +122,67 @@ private void CreateMultipleInstance(string[] args)
Environment.Exit(0);
}
private void UpdateRemoteObject(string uri)
private void SendDataToServer(string[] args)
{
IpcClientChannel clientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(clientChannel, true);
InstanceProxy proxy = Activator.GetObject(typeof(InstanceProxy), string.Format("ipc://{0}{1}{2}/{2}", Environment.MachineName, Environment.UserName, uri)) as InstanceProxy;
if (proxy != null)
using (var pipeClient = new NamedPipeClientStream(".", PipeName, PipeDirection.Out))
{
proxy.SetCommandLineArgs(InstanceProxy.CommandLineArgs);
}
pipeClient.Connect();
ChannelServices.UnregisterChannel(clientChannel);
}
private void RegisterRemoteType(string uri)
{
serverChannel = new IpcServerChannel(Environment.MachineName + Environment.UserName + uri);
ChannelServices.RegisterChannel(serverChannel, true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(InstanceProxy), uri, WellKnownObjectMode.Singleton);
}
private void WaitOrTimerCallback(object state, bool timedOut)
{
EventHandler<InstanceCallbackEventArgs> callback = state as EventHandler<InstanceCallbackEventArgs>;
if (callback != null)
{
try
var pipeData = new InstanceCallbackEventArgs
{
callback(state, new InstanceCallbackEventArgs(InstanceProxy.CommandLineArgs));
}
finally
{
if (semaphore != null)
{
semaphore.Release();
}
}
CommandLineArgs = args
};
var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(pipeData));
pipeClient.Write(bytes, 0, bytes.Length);
}
}
}
[Serializable]
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
internal class InstanceProxy : MarshalByRefObject
{
public static string[] CommandLineArgs { get; internal set; }
public void SetCommandLineArgs(string[] commandLineArgs)
private void CreateServer(EventHandler<InstanceCallbackEventArgs> callback)
{
CommandLineArgs = commandLineArgs;
pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
pipeServer.BeginWaitForConnection(ConnectionCallback, callback);
}
private void ConnectionCallback(IAsyncResult ar)
{
try
{
pipeServer.EndWaitForConnection(ar);
}
catch (ObjectDisposedException)
{
// Operation got aborted as part of program exit.
return;
}
var callback = ar.AsyncState as EventHandler<InstanceCallbackEventArgs>;
var sr = new StreamReader(pipeServer, Encoding.UTF8);
try
{
if (callback != null)
{
var data = sr.ReadToEnd();
callback(this, JsonConvert.DeserializeObject<InstanceCallbackEventArgs>(data));
}
}
finally
{
// Close the existing server
sr.Dispose();
// Create a new server
CreateServer(callback);
// Signal that we are ready to accept a new connection
semaphore.Release();
}
}
}
public class InstanceCallbackEventArgs : EventArgs
{
public string[] CommandLineArgs { get; private set; }
internal InstanceCallbackEventArgs(string[] commandLineArgs)
{
CommandLineArgs = commandLineArgs;
}
[JsonProperty]
public string[] CommandLineArgs { get; internal set; }
}
}

View file

@ -46,18 +46,11 @@ public bool CheckCommand(string command)
public override string ToString()
{
string text = "";
if (IsCommand)
{
text += "-";
}
text += Command;
string text = string.Format("Command: \"{0}\"", Command);
if (!string.IsNullOrEmpty(Parameter))
{
text += " \"" + Parameter + "\"";
text += string.Format(" Parameter: \"{0}\"", Parameter);
}
return text;

View file

@ -23,7 +23,6 @@
#endregion License Information (GPL v3)
using Newtonsoft.Json;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
@ -39,7 +38,6 @@ public class GradientInfo
public List<GradientStop> Colors { get; set; }
[JsonIgnore]
public bool IsValid => Colors != null && Colors.Count > 0;
public GradientInfo()

View file

@ -220,8 +220,10 @@ private void OnImportCompleted()
}
}
public void ImportJson(string json)
private void tsmiImportClipboard_Click(object sender, EventArgs e)
{
string json = ClipboardHelpers.GetText(true);
if (!string.IsNullOrEmpty(json))
{
OnImportRequested(json);
@ -229,18 +231,6 @@ public void ImportJson(string json)
}
}
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 (*.*)|*.*";
@ -256,7 +246,8 @@ private void tsmiImportFile_Click(object sender, EventArgs e)
{
foreach (string filename in ofd.FileNames)
{
ImportFile(filename);
string json = File.ReadAllText(filename, Encoding.UTF8);
OnImportRequested(json);
}
OnImportCompleted();

View file

@ -188,13 +188,4 @@ public enum ImageCombinerAlignment
Center,
RightOrBottom
}
public enum ImageInterpolationMode // Localized
{
HighQualityBicubic,
Bicubic,
HighQualityBilinear,
Bilinear,
NearestNeighbor
}
}

View file

@ -197,7 +197,7 @@ private void nudLocation_ValueChanged(object sender, EventArgs e)
{
if (isReady)
{
GradientStop gradientStop = GetSelectedGradientStop();
GradientStop gradientStop = GetSelectedGradientStop(out ListViewItem lvi);
if (gradientStop != null)
{

View file

@ -791,20 +791,12 @@ public static bool BrowseFolder(string title, TextBox tb, string initialDirector
return false;
}
public static string GetVariableFolderPath(string path, bool supportCustomSpecialFolders = false)
public static string GetVariableFolderPath(string path)
{
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);
@ -819,20 +811,12 @@ public static string GetVariableFolderPath(string path, bool supportCustomSpecia
return path;
}
public static string ExpandFolderVariables(string path, bool supportCustomSpecialFolders = false)
public static string ExpandFolderVariables(string path)
{
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);
@ -924,7 +908,7 @@ public static long GetFileSize(string path)
return -1;
}
public static void CreateDirectory(string directoryPath)
public static void CreateDirectoryFromDirectoryPath(string directoryPath)
{
if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
{
@ -946,7 +930,7 @@ public static void CreateDirectoryFromFilePath(string filePath)
if (!string.IsNullOrEmpty(filePath))
{
string directoryPath = Path.GetDirectoryName(filePath);
CreateDirectory(directoryPath);
CreateDirectoryFromDirectoryPath(directoryPath);
}
}
@ -971,7 +955,7 @@ public static string CopyFile(string filePath, string destinationFolder, bool ov
{
string fileName = Path.GetFileName(filePath);
string destinationFilePath = Path.Combine(destinationFolder, fileName);
CreateDirectory(destinationFolder);
CreateDirectoryFromDirectoryPath(destinationFolder);
File.Copy(filePath, destinationFilePath, overwrite);
return destinationFilePath;
}
@ -985,7 +969,7 @@ public static string MoveFile(string filePath, string destinationFolder, bool ov
{
string fileName = Path.GetFileName(filePath);
string destinationFilePath = Path.Combine(destinationFolder, fileName);
CreateDirectory(destinationFolder);
CreateDirectoryFromDirectoryPath(destinationFolder);
if (overwrite && File.Exists(destinationFilePath))
{
@ -1031,7 +1015,7 @@ public static string BackupFileWeekly(string filePath, string destinationFolder)
if (!File.Exists(newFilePath))
{
CreateDirectory(destinationFolder);
CreateDirectoryFromDirectoryPath(destinationFolder);
File.Copy(filePath, newFilePath, false);
return newFilePath;
}
@ -1051,7 +1035,7 @@ public static void BackupFileMonthly(string filePath, string destinationFolder)
if (!File.Exists(newFilePath))
{
CreateDirectory(destinationFolder);
CreateDirectoryFromDirectoryPath(destinationFolder);
File.Copy(filePath, newFilePath, false);
}
}

View file

@ -2078,23 +2078,5 @@ 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;
}
}
}
}

View file

@ -40,6 +40,5 @@ 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>();
}
}

View file

@ -146,7 +146,7 @@ internal class Resources {
}
/// <summary>
/// Looks up a localized string similar to Add image effects.
/// Looks up a localized string similar to Add image effects / watermark.
/// </summary>
internal static string AfterCaptureTasks_AddImageEffects {
get {
@ -2058,6 +2058,51 @@ internal class Resources {
}
}
/// <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>
@ -2103,51 +2148,6 @@ internal class Resources {
}
}
/// <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,19 +2251,9 @@ internal class Resources {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap LoadingSmallBlack {
internal static System.Drawing.Bitmap LoadingSmall {
get {
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);
object obj = ResourceManager.GetObject("LoadingSmall", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View file

@ -135,7 +135,7 @@
<data name="TextDestination_CustomTextUploader" xml:space="preserve">
<value>Custom text uploader</value>
</data>
<data name="ImageInterpolationMode_HighQualityBicubic" xml:space="preserve">
<data name="ImageEditorInterpolationMode_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</value>
<value>Add image effects / watermark</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="ImageInterpolationMode_Bilinear" xml:space="preserve">
<data name="ImageEditorInterpolationMode_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="ImageInterpolationMode_HighQualityBilinear" xml:space="preserve">
<data name="ImageEditorInterpolationMode_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="ImageInterpolationMode_NearestNeighbor" xml:space="preserve">
<data name="ImageEditorInterpolationMode_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="ImageInterpolationMode_Bicubic" xml:space="preserve">
<data name="ImageEditorInterpolationMode_Bicubic" xml:space="preserve">
<value>Bicubic</value>
</data>
<data name="CodeMenu_Create_Close" xml:space="preserve">
@ -1193,6 +1193,9 @@ 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>
@ -1247,10 +1250,4 @@ 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>

View file

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 847 B

View file

@ -161,7 +161,7 @@ private bool SaveInternal(string filePath)
{
string fileName = Path.GetFileName(filePath);
backupFilePath = Path.Combine(BackupFolder, fileName);
Helpers.CreateDirectory(BackupFolder);
Helpers.CreateDirectoryFromDirectoryPath(BackupFolder);
}
File.Replace(tempFilePath, filePath, backupFilePath);

View file

@ -1473,10 +1473,7 @@
<None Include="Resources\ShareX_Icon_White.ico" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\LoadingSmallBlack.gif" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\LoadingSmallWhite.gif" />
<None Include="Resources\LoadingSmall.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.

View file

@ -132,12 +132,6 @@ 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;

View file

@ -45,7 +45,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
if (dlg.ShowDialog())
{
value = Helpers.GetVariableFolderPath(dlg.FileName, true);
value = Helpers.GetVariableFolderPath(dlg.FileName);
}
}

View file

@ -42,7 +42,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
if (!string.IsNullOrEmpty(filePath))
{
value = Helpers.GetVariableFolderPath(filePath, true);
value = Helpers.GetVariableFolderPath(filePath);
}
return value;

View file

@ -215,7 +215,7 @@ private void StartDownload()
btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel;
string folderPath = Path.Combine(Path.GetTempPath(), "ShareX");
Helpers.CreateDirectory(folderPath);
Helpers.CreateDirectoryFromDirectoryPath(folderPath);
DownloadLocation = Path.Combine(folderPath, Filename);
fileDownloader = new FileDownloader(URL, DownloadLocation, Proxy, AcceptHeader);

View file

@ -38,7 +38,7 @@ private void InitializeComponent()
//
// pbLoading
//
this.pbLoading.Image = global::ShareX.HelpersLib.Properties.Resources.LoadingSmallBlack;
this.pbLoading.Image = global::ShareX.HelpersLib.Properties.Resources.LoadingSmall;
resources.ApplyResources(this.pbLoading, "pbLoading");
this.pbLoading.Name = "pbLoading";
this.pbLoading.TabStop = false;

View file

@ -60,18 +60,6 @@ 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();

View file

@ -32,7 +32,7 @@ namespace ShareX.HelpersLib
{
public static class ZipManager
{
public static void Extract(string archivePath, string destination, bool retainDirectoryStructure = true, Func<ZipArchiveEntry, bool> filter = null)
public static void Extract(string archivePath, string destination, bool retainDirectoryStructure = true, List<string> fileFilter = null)
{
using (ZipArchive archive = ZipFile.OpenRead(archivePath))
{
@ -40,21 +40,31 @@ public static void Extract(string archivePath, string destination, bool retainDi
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (filter != null && !filter(entry))
{
continue;
}
string entryName = entry.Name;
string entryName;
if (fileFilter != null)
{
bool match = false;
foreach (string file in fileFilter)
{
if (file.Equals(entryName, StringComparison.OrdinalIgnoreCase))
{
match = true;
break;
}
}
if (!match)
{
continue;
}
}
if (retainDirectoryStructure)
{
entryName = entry.FullName;
}
else
{
entryName = entry.Name;
}
string fullPath = Path.GetFullPath(Path.Combine(fullName, entryName));
@ -87,20 +97,7 @@ public static void Compress(string source, string archivePath, CompressionLevel
ZipFile.CreateFromDirectory(source, archivePath, compression, false);
}
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)
public static void Compress(string archivePath, List<string> files, string workingDirectory = "", CompressionLevel compression = CompressionLevel.Optimal)
{
if (File.Exists(archivePath))
{
@ -109,14 +106,13 @@ public static void Compress(string archivePath, Dictionary<string, string> files
using (ZipArchive archive = ZipFile.Open(archivePath, ZipArchiveMode.Update))
{
foreach (KeyValuePair<string, string> file in files)
foreach (string file in files)
{
string sourceFilePath = file.Key;
string filePath = Path.Combine(workingDirectory, file);
if (File.Exists(sourceFilePath))
if (File.Exists(filePath))
{
string entryName = file.Value;
archive.CreateEntryFromFile(sourceFilePath, entryName, compression);
archive.CreateEntryFromFile(filePath, file, compression);
}
}
}

View file

@ -27,7 +27,6 @@
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.IO;
namespace ShareX.ImageEffectsLib
@ -50,12 +49,6 @@ 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; }
@ -66,7 +59,7 @@ public DrawImage()
public override Bitmap Apply(Bitmap bmp)
{
string imageFilePath = Helpers.ExpandFolderVariables(ImageLocation, true);
string imageFilePath = Helpers.ExpandFolderVariables(ImageLocation);
if (!string.IsNullOrEmpty(imageFilePath) && File.Exists(imageFilePath))
{
@ -104,9 +97,7 @@ public override Bitmap Apply(Bitmap bmp)
using (Graphics g = Graphics.FromImage(bmp))
{
g.InterpolationMode = ImageHelpers.GetInterpolationMode(InterpolationMode);
g.PixelOffsetMode = PixelOffsetMode.Half;
g.CompositingMode = CompositingMode;
g.SetHighQuality();
g.DrawImage(bmp2, imageRectangle);
}
}

View file

@ -99,7 +99,7 @@ public DrawParticles()
public override Bitmap Apply(Bitmap bmp)
{
string imageFolder = Helpers.ExpandFolderVariables(ImageFolder, true);
string imageFolder = Helpers.ExpandFolderVariables(ImageFolder);
if (!string.IsNullOrEmpty(imageFolder) && Directory.Exists(imageFolder))
{

View file

@ -1,108 +0,0 @@
#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;
}
}
}

View file

@ -1,135 +0,0 @@
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;
}
}

View file

@ -1,113 +0,0 @@
#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();
}
}
}
}

View file

@ -1,120 +0,0 @@
<?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>

View file

@ -56,13 +56,7 @@ 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
@ -145,9 +139,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;
@ -265,36 +259,12 @@ 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);
@ -313,15 +283,13 @@ 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();
@ -355,8 +323,6 @@ 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;
}
}

View file

@ -35,10 +35,6 @@ 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; }
@ -52,8 +48,6 @@ public partial class ImageEffectsForm : Form
public ImageEffectsForm(Bitmap bmp, List<ImageEffectPreset> presets, int selectedPresetIndex)
{
pauseUpdate = true;
InitializeComponent();
ShareXResources.ApplyTheme(this);
@ -70,24 +64,9 @@ 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)
@ -106,11 +85,6 @@ 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);
@ -187,6 +161,8 @@ private void AddEffectToContextMenu(string groupName, params Type[] imageEffects
private void LoadSettings()
{
pauseUpdate = true;
foreach (ImageEffectPreset preset in Presets)
{
cbPresets.Items.Add(preset);
@ -198,6 +174,8 @@ private void LoadSettings()
}
UpdateControlStates();
pauseUpdate = false;
}
private ImageEffectPreset GetSelectedPreset()
@ -223,9 +201,7 @@ 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();
}
@ -443,6 +419,7 @@ private void LoadPreset(ImageEffectPreset preset)
private void ImageEffectsForm_Shown(object sender, EventArgs e)
{
LoadSettings();
this.ForceActivate();
}
@ -485,10 +462,10 @@ private void btnDuplicatePreset_Click(object sender, EventArgs e)
private void cbPresets_SelectedIndexChanged(object sender, EventArgs e)
{
SelectedPresetIndex = cbPresets.SelectedIndex;
if (!ignorePresetsSelectedIndexChanged)
{
SelectedPresetIndex = cbPresets.SelectedIndex;
ImageEffectPreset preset = GetSelectedPreset();
if (preset != null)
{
@ -588,7 +565,7 @@ private void lvEffects_SelectedIndexChanged(object sender, EventArgs e)
private void lvEffects_ItemChecked(object sender, ItemCheckedEventArgs e)
{
if (e.Item != null && e.Item.Focused && e.Item.Tag is ImageEffect)
if (e.Item != null && e.Item.Tag is ImageEffect)
{
ImageEffect imageEffect = (ImageEffect)e.Item.Tag;
imageEffect.Enabled = e.Item.Checked;
@ -631,33 +608,6 @@ 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();

View file

@ -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.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
<data name="pgSettings.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left</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>0, 0</value>
<value>184, 72</value>
</data>
<data name="pgSettings.Size" type="System.Drawing.Size, System.Drawing">
<value>330, 424</value>
<value>336, 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="&gt;&gt;pgSettings.Parent" xml:space="preserve">
<value>scMain.Panel1</value>
<value>$this</value>
</data>
<data name="&gt;&gt;pgSettings.ZOrder" xml:space="preserve">
<value>0</value>
<value>20</value>
</data>
<data name="btnAdd.Location" type="System.Drawing.Point, System.Drawing">
<value>408, 40</value>
@ -166,11 +166,14 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnAdd.ZOrder" xml:space="preserve">
<value>21</value>
<value>19</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>
@ -190,10 +193,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lvEffects.ZOrder" xml:space="preserve">
<value>22</value>
</data>
<data name="chEffect.Width" type="System.Int32, mscorlib">
<value>164</value>
<value>21</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="&gt;&gt;btnRemove.ZOrder" xml:space="preserve">
<value>20</value>
<value>18</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="&gt;&gt;btnClear.ZOrder" xml:space="preserve">
<value>19</value>
<value>17</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="&gt;&gt;btnDuplicate.ZOrder" xml:space="preserve">
<value>18</value>
<value>16</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>456, 504</value>
<value>328, 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>20</value>
<value>19</value>
</data>
<data name="btnSaveImage.Text" xml:space="preserve">
<value>Save image...</value>
@ -298,7 +298,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnSaveImage.ZOrder" xml:space="preserve">
<value>17</value>
<value>15</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="&gt;&gt;eiImageEffects.ZOrder" xml:space="preserve">
<value>16</value>
<value>14</value>
</data>
<data name="pbResult.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
<data name="pbResult.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="pbResult.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
<value>528, 72</value>
</data>
<data name="pbResult.Size" type="System.Drawing.Size, System.Drawing">
<value>440, 424</value>
<value>432, 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="&gt;&gt;pbResult.Parent" xml:space="preserve">
<value>scMain.Panel2</value>
<value>$this</value>
</data>
<data name="&gt;&gt;pbResult.ZOrder" xml:space="preserve">
<value>0</value>
<value>22</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,11 +364,23 @@
<value>Bottom, Left</value>
</data>
<data name="mbLoadImage.Location" type="System.Drawing.Point, System.Drawing">
<value>328, 504</value>
<value>200, 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>
@ -382,7 +394,7 @@
<value>120, 24</value>
</data>
<data name="mbLoadImage.TabIndex" type="System.Int32, mscorlib">
<value>19</value>
<value>18</value>
</data>
<data name="mbLoadImage.Text" xml:space="preserve">
<value>Load image</value>
@ -400,19 +412,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;mbLoadImage.ZOrder" xml:space="preserve">
<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>
<value>13</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="&gt;&gt;btnAddPreset.ZOrder" xml:space="preserve">
<value>14</value>
<value>12</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="&gt;&gt;btnRemovePreset.ZOrder" xml:space="preserve">
<value>13</value>
<value>11</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="&gt;&gt;cbPresets.ZOrder" xml:space="preserve">
<value>12</value>
<value>10</value>
</data>
<data name="lblPresetName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -508,7 +508,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblPresetName.ZOrder" xml:space="preserve">
<value>11</value>
<value>9</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="&gt;&gt;txtPresetName.ZOrder" xml:space="preserve">
<value>10</value>
<value>8</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="&gt;&gt;btnClose.ZOrder" xml:space="preserve">
<value>9</value>
<value>7</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="&gt;&gt;btnOK.ZOrder" xml:space="preserve">
<value>8</value>
<value>6</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>584, 504</value>
<value>456, 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>21</value>
<value>20</value>
</data>
<data name="btnUploadImage.Text" xml:space="preserve">
<value>Upload image</value>
@ -616,7 +616,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnUploadImage.ZOrder" xml:space="preserve">
<value>7</value>
<value>5</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="&gt;&gt;btnRefresh.ZOrder" xml:space="preserve">
<value>6</value>
<value>4</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="&gt;&gt;btnDuplicatePreset.ZOrder" xml:space="preserve">
<value>5</value>
<value>3</value>
</data>
<data name="lblPresets.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -691,88 +691,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblPresets.ZOrder" xml:space="preserve">
<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="&gt;&gt;btnPackager.Name" xml:space="preserve">
<value>btnPackager</value>
</data>
<data name="&gt;&gt;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="&gt;&gt;btnPackager.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;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="&gt;&gt;scMain.Panel1.Name" xml:space="preserve">
<value>scMain.Panel1</value>
</data>
<data name="&gt;&gt;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="&gt;&gt;scMain.Panel1.Parent" xml:space="preserve">
<value>scMain</value>
</data>
<data name="&gt;&gt;scMain.Panel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;scMain.Panel2.Name" xml:space="preserve">
<value>scMain.Panel2</value>
</data>
<data name="&gt;&gt;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="&gt;&gt;scMain.Panel2.Parent" xml:space="preserve">
<value>scMain</value>
</data>
<data name="&gt;&gt;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="&gt;&gt;scMain.Name" xml:space="preserve">
<value>scMain</value>
</data>
<data name="&gt;&gt;scMain.Type" xml:space="preserve">
<value>ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=13.1.1.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;scMain.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;scMain.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>

View file

@ -95,7 +95,6 @@
<Reference Include="System" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
@ -131,13 +130,6 @@
<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" />
@ -182,9 +174,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ImageEffectPackagerForm.resx">
<DependentUpon>ImageEffectPackagerForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ImageEffectsForm.de.resx">
<DependentUpon>ImageEffectsForm.cs</DependentUpon>
</EmbeddedResource>

View file

@ -35,7 +35,7 @@ namespace ShareX.ImageEffectsLib
public partial class WatermarkForm : Form
{
private WatermarkConfig config;
private bool isReady;
private bool IsGuiReady;
public WatermarkForm(WatermarkConfig watermarkConfig)
{
@ -85,7 +85,7 @@ private void WatermarkUI_Load(object sender, EventArgs e)
txtWatermarkImageLocation.Text = config.Image.ImageLocation;
isReady = true;
IsGuiReady = true;
UpdatePreview();
}
@ -96,7 +96,7 @@ private void WatermarkUI_Resize(object sender, EventArgs e)
private void UpdatePreview()
{
if (isReady)
if (IsGuiReady)
{
using (Bitmap bmp = new Bitmap(pbPreview.ClientSize.Width, pbPreview.ClientSize.Height))
{

View file

@ -25,6 +25,7 @@
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ShareX.MediaLib
@ -58,7 +59,7 @@ public static bool ExtractFFmpeg(string archivePath, string extractPath)
{
try
{
ZipManager.Extract(archivePath, extractPath, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
ZipManager.Extract(archivePath, extractPath, false, new List<string>() { "ffmpeg.exe" });
return true;
}
catch (Exception e)

View file

@ -70,7 +70,6 @@
<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" />

View file

@ -178,7 +178,7 @@ private string GetOutputDirectory()
break;
}
Helpers.CreateDirectory(directory);
Helpers.CreateDirectoryFromDirectoryPath(directory);
return directory;
}

View file

@ -318,6 +318,15 @@ public enum ImageEditorStartMode // Localized
Fullscreen
}
public enum ImageEditorInterpolationMode // Localized
{
HighQualityBicubic,
Bicubic,
HighQualityBilinear,
Bilinear,
NearestNeighbor
}
public enum ImageInsertMethod
{
Center,

View file

@ -33,12 +33,12 @@ namespace ShareX.ScreenCaptureLib
public partial class ImageSizeForm : Form
{
public Size ImageSize { get; private set; }
public ImageInterpolationMode InterpolationMode { get; private set; }
public ImageEditorInterpolationMode InterpolationMode { get; private set; }
private double widthRatio, heightRatio;
private bool ignoreValueChanged = true;
public ImageSizeForm(Size size, ImageInterpolationMode interpolationMode)
public ImageSizeForm(Size size, ImageEditorInterpolationMode interpolationMode)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
@ -56,7 +56,7 @@ public ImageSizeForm(Size size, ImageInterpolationMode interpolationMode)
nudWidth.TextChanged += NudWidth_TextChanged;
nudHeight.TextChanged += NudHeight_TextChanged;
cbResampling.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageInterpolationMode>());
cbResampling.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageEditorInterpolationMode>());
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 = (ImageInterpolationMode)cbResampling.SelectedIndex;
InterpolationMode = (ImageEditorInterpolationMode)cbResampling.SelectedIndex;
}
private void btnOK_Click(object sender, EventArgs e)

View file

@ -747,9 +747,6 @@
<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>

View file

@ -89,7 +89,7 @@ public class RegionCaptureOptions
public WindowState ImageEditorWindowState = new WindowState();
public bool AutoCloseEditorOnTask = false;
public bool ShowEditorPanTip = true;
public ImageInterpolationMode ImageEditorResizeInterpolationMode = ImageInterpolationMode.Bicubic;
public ImageEditorInterpolationMode ImageEditorResizeInterpolationMode = ImageEditorInterpolationMode.Bicubic;
public Size EditorNewImageSize = new Size(800, 600);
public bool EditorNewImageTransparent = false;
public Color EditorNewImageBackgroundColor = Color.White;

View file

@ -23,7 +23,6 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System.Collections.Generic;
using System.Drawing;
@ -75,7 +74,7 @@ public class AnnotationOptions
public Color TextFillColor { get; set; } = PrimaryColor;
// Image drawing
public ImageInterpolationMode ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;
public ImageEditorInterpolationMode ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor;
public string LastImageFilePath { get; set; }
// Step drawing

View file

@ -23,7 +23,6 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -34,7 +33,7 @@ public class ImageDrawingShape : BaseDrawingShape
public override ShapeType ShapeType { get; } = ShapeType.DrawingImage;
public Image Image { get; protected set; }
public ImageInterpolationMode ImageInterpolationMode { get; protected set; }
public ImageEditorInterpolationMode ImageInterpolationMode { get; protected set; }
public override void OnConfigLoad()
{
@ -80,7 +79,7 @@ protected void DrawImage(Graphics g)
if (Image != null)
{
g.PixelOffsetMode = PixelOffsetMode.Half;
g.InterpolationMode = ImageHelpers.GetInterpolationMode(ImageInterpolationMode);
g.InterpolationMode = Manager.GetInterpolationMode(ImageInterpolationMode);
g.DrawImage(Image, Rectangle);

View file

@ -23,7 +23,6 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -35,7 +34,7 @@ public class MagnifyDrawingShape : EllipseDrawingShape
public override ShapeType ShapeType { get; } = ShapeType.DrawingMagnify;
public int MagnifyStrength { get; set; } = 200;
public ImageInterpolationMode ImageInterpolationMode { get; set; }
public ImageEditorInterpolationMode ImageInterpolationMode { get; set; }
public MagnifyDrawingShape()
{
@ -59,7 +58,7 @@ public override void OnConfigSave()
public override void OnDraw(Graphics g)
{
g.PixelOffsetMode = PixelOffsetMode.Half;
g.InterpolationMode = ImageHelpers.GetInterpolationMode(ImageInterpolationMode);
g.InterpolationMode = Manager.GetInterpolationMode(ImageInterpolationMode);
using (GraphicsPath gp = new GraphicsPath())
{

View file

@ -35,7 +35,7 @@ public class StickerDrawingShape : ImageDrawingShape
public override void OnConfigLoad()
{
ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;
ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor;
}
public override void OnConfigSave()

View file

@ -1928,7 +1928,7 @@ private void ChangeImageSize()
if (size != oldSize)
{
InterpolationMode interpolationMode = ImageHelpers.GetInterpolationMode(Options.ImageEditorResizeInterpolationMode);
InterpolationMode interpolationMode = GetInterpolationMode(Options.ImageEditorResizeInterpolationMode);
Bitmap bmp = ImageHelpers.ResizeImage(Form.Canvas, size, interpolationMode);
if (bmp != null)
@ -1942,6 +1942,24 @@ 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();

View file

@ -506,10 +506,10 @@ internal void CreateToolbar()
tsddbShapeOptions.DropDownItems.Add(tslnudCornerRadius);
tscbImageInterpolationMode = new ToolStripLabeledComboBox(Resources.ShapeManager_CreateToolbar_InterpolationMode);
tscbImageInterpolationMode.Content.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageInterpolationMode>());
tscbImageInterpolationMode.Content.AddRange(Helpers.GetLocalizedEnumDescriptions<ImageEditorInterpolationMode>());
tscbImageInterpolationMode.Content.SelectedIndexChanged += (sender, e) =>
{
AnnotationOptions.ImageInterpolationMode = (ImageInterpolationMode)tscbImageInterpolationMode.Content.SelectedIndex;
AnnotationOptions.ImageInterpolationMode = (ImageEditorInterpolationMode)tscbImageInterpolationMode.Content.SelectedIndex;
tscbImageInterpolationMode.Invalidate();
UpdateCurrentShape();
};

View file

@ -25,6 +25,7 @@
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -342,7 +343,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, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
ZipManager.Extract(filename, ".", false, new List<string>() { "ffmpeg.exe" });
File.Move("ffmpeg.exe", FFmpeg32bit);
}
@ -354,7 +355,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, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase));
ZipManager.Extract(filename, ".", false, new List<string>() { "ffmpeg.exe" });
File.Move("ffmpeg.exe", FFmpeg64bit);
}

View file

@ -67,7 +67,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">

View file

@ -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?supportsAllDrives=true", fileID);
string url = string.Format("https://www.googleapis.com/drive/v3/files/{0}/permissions", fileID);
string json = JsonConvert.SerializeObject(new
{

View file

@ -61,8 +61,6 @@ public AboutForm()
#else
if (!Program.PortableApps)
{
uclUpdate.UpdateLoadingImage();
UpdateChecker updateChecker = Program.UpdateManager.CreateUpdateChecker();
uclUpdate.CheckUpdate(updateChecker);
}

View file

@ -315,6 +315,13 @@ public void UpdateControls()
InitHotkeys();
#if !WindowsStore
if (!Program.Portable && !IntegrationHelpers.CheckCustomUploaderExtension())
{
IntegrationHelpers.CreateCustomUploaderExtension(true);
}
#endif
IsReady = true;
}
@ -950,7 +957,6 @@ 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;
@ -1051,28 +1057,18 @@ public void UseCommandLineArgs(List<CLICommand> commands)
foreach (CLICommand command in commands)
{
DebugHelper.WriteLine("CommandLine: " + command);
DebugHelper.WriteLine("CommandLine: " + command.Command);
if (command.IsCommand)
if (command.IsCommand && command.Command.Equals("CustomUploader", StringComparison.InvariantCultureIgnoreCase))
{
if (command.Command.Equals("CustomUploader", StringComparison.InvariantCultureIgnoreCase))
{
TaskHelpers.ImportCustomUploader(command.Parameter);
TaskHelpers.AddCustomUploader(command.Parameter);
continue;
}
continue;
}
if (command.Command.Equals("ImageEffect", StringComparison.InvariantCultureIgnoreCase))
{
TaskHelpers.ImportImageEffect(command.Parameter);
continue;
}
if (CheckCLIHotkey(command) || CheckCLIWorkflow(command))
{
continue;
}
if (command.IsCommand && (CheckCLIHotkey(command) || CheckCLIWorkflow(command)))
{
continue;
}
if (URLHelpers.IsValidURL(command.Command))

View file

@ -813,7 +813,12 @@ private void chkShowImageEffectsWindowAfterCapture_CheckedChanged(object sender,
private void btnImageEffects_Click(object sender, EventArgs e)
{
TaskHelpers.OpenImageEffectsSingleton(TaskSettings);
using (ImageEffectsForm imageEffectsForm = new ImageEffectsForm(null, TaskSettings.ImageSettings.ImageEffectPresets,
TaskSettings.ImageSettings.SelectedImageEffectPreset))
{
imageEffectsForm.ShowDialog();
TaskSettings.ImageSettings.SelectedImageEffectPreset = imageEffectsForm.SelectedPresetIndex;
}
}
private void nudThumbnailWidth_ValueChanged(object sender, EventArgs e)

View file

@ -62,15 +62,6 @@ 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";
@ -223,57 +214,6 @@ 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
@ -461,7 +401,6 @@ public static void Uninstall()
CreateShellContextMenuButton(false);
CreateEditShellContextMenuButton(false);
CreateCustomUploaderExtension(false);
CreateImageEffectExtension(false);
CreateSendToMenuButton(false);
}
}

View file

@ -232,7 +232,6 @@ 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");
@ -316,8 +315,6 @@ private static void Run()
IgnoreHotkeyWarning = CLI.IsCommandExist("NoHotkeys");
CreateParentFolders();
RegisterExtensions();
CheckPuushMode();
DebugWriteFlags();
CleanTempFiles();
@ -326,9 +323,10 @@ private static void Run()
Uploader.UpdateServicePointManager();
UpdateManager = new GitHubUpdateManager("ShareX", "ShareX", Dev, Portable);
LanguageHelper.ChangeLanguage(Settings.Language);
Helpers.TryFixHandCursor();
LanguageHelper.ChangeLanguage(Settings.Language);
Helpers.TryFixHandCursor();
DebugHelper.WriteLine("MainForm init started.");
MainForm = new MainForm();
DebugHelper.WriteLine("MainForm init finished.");
@ -472,43 +470,6 @@ 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))

View file

@ -352,17 +352,17 @@ public static bool Export(string archivePath, bool settings, bool history)
if (settings)
{
files.Add(ApplicationConfigFilePath);
files.Add(HotkeysConfigFilePath);
files.Add(UploadersConfigFilePath);
files.Add(ApplicationConfigFilename);
files.Add(HotkeysConfigFilename);
files.Add(UploadersConfigFilename);
}
if (history)
{
files.Add(Program.HistoryFilePath);
files.Add(Program.HistoryFilename);
}
ZipManager.Compress(archivePath, files);
ZipManager.Compress(archivePath, files, Program.PersonalFolder);
return true;
}
catch (Exception e)

View file

@ -105,7 +105,6 @@
<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" />

View file

@ -578,7 +578,7 @@ public static void PrintImage(Image img)
}
}
public static Bitmap ApplyImageEffects(Bitmap bmp, TaskSettingsImage taskSettingsImage)
public static Bitmap AddImageEffects(Bitmap bmp, TaskSettingsImage taskSettingsImage)
{
if (bmp != null && !bmp.PixelFormat.HasFlag(PixelFormat.Indexed))
{
@ -1061,28 +1061,6 @@ 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())
@ -1588,7 +1566,7 @@ public static Screenshot GetScreenshot(TaskSettings taskSettings = null)
return screenshot;
}
public static void ImportCustomUploader(string filePath)
public static void AddCustomUploader(string filePath)
{
if (Program.UploadersConfig != null)
{
@ -1617,7 +1595,7 @@ public static void ImportCustomUploader(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);
@ -1688,30 +1666,6 @@ public static void ImportCustomUploader(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();

View file

@ -575,7 +575,7 @@ private bool DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
{
Image = TaskHelpers.ApplyImageEffects(Image, Info.TaskSettings.ImageSettingsReference);
Image = TaskHelpers.AddImageEffects(Image, Info.TaskSettings.ImageSettingsReference);
if (Image == null)
{