mirror of https://github.com/ShareX/ShareX.git
Compare commits
3 Commits
92b7747327
...
43bda2300e
Author | SHA1 | Date |
---|---|---|
jcommander | 43bda2300e | |
Jaex | 019c9a7dae | |
jcommander | 0704453dfc |
|
@ -260,24 +260,24 @@ namespace ShareX.HelpersLib
|
|||
return null;
|
||||
}
|
||||
|
||||
private static Bitmap ApplyCutOutEffect(Bitmap bmp, AnchorStyles effectEdge, CutOutEffectType effectType, int effectSize, Color cutOutBackgroundColor)
|
||||
private static Bitmap ApplyCutOutEffect(Bitmap bmp, AnchorStyles effectEdge, CutOutEffectType effectType, int effectSize, Color backgroundColor)
|
||||
{
|
||||
switch (effectType)
|
||||
{
|
||||
case CutOutEffectType.None:
|
||||
return bmp;
|
||||
case CutOutEffectType.ZigZag:
|
||||
return TornEdges(bmp, effectSize, effectSize, effectEdge, false, false, cutOutBackgroundColor);
|
||||
return TornEdges(bmp, effectSize, effectSize, effectEdge, false, false, backgroundColor);
|
||||
case CutOutEffectType.TornEdge:
|
||||
return TornEdges(bmp, effectSize, effectSize * 2, effectEdge, false, true, cutOutBackgroundColor);
|
||||
return TornEdges(bmp, effectSize, effectSize * 2, effectEdge, false, true, backgroundColor);
|
||||
case CutOutEffectType.Wave:
|
||||
return WavyEdges(bmp, effectSize, effectSize * 5, effectEdge, cutOutBackgroundColor);
|
||||
return WavyEdges(bmp, effectSize, effectSize * 5, effectEdge, backgroundColor);
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Bitmap CutOutBitmapMiddle(Bitmap bmp, Orientation orientation, int start, int size, CutOutEffectType effectType, int effectSize, Color cutOutBackgroundColor)
|
||||
public static Bitmap CutOutBitmapMiddle(Bitmap bmp, Orientation orientation, int start, int size, CutOutEffectType effectType, int effectSize, Color backgroundColor)
|
||||
{
|
||||
if (bmp != null && size > 0)
|
||||
{
|
||||
|
@ -290,7 +290,7 @@ namespace ShareX.HelpersLib
|
|||
: new Rectangle(0, 0, bmp.Width, Math.Min(start, bmp.Height));
|
||||
firstPart = CropBitmap(bmp, r);
|
||||
AnchorStyles effectEdge = orientation == Orientation.Horizontal ? AnchorStyles.Right : AnchorStyles.Bottom;
|
||||
firstPart = ApplyCutOutEffect(firstPart, effectEdge, effectType, effectSize, cutOutBackgroundColor);
|
||||
firstPart = ApplyCutOutEffect(firstPart, effectEdge, effectType, effectSize, backgroundColor);
|
||||
}
|
||||
|
||||
int cutDimension = orientation == Orientation.Horizontal ? bmp.Width : bmp.Height;
|
||||
|
@ -302,7 +302,7 @@ namespace ShareX.HelpersLib
|
|||
: new Rectangle(0, end, bmp.Width, bmp.Height - end);
|
||||
secondPart = CropBitmap(bmp, r);
|
||||
AnchorStyles effectEdge = orientation == Orientation.Horizontal ? AnchorStyles.Left : AnchorStyles.Top;
|
||||
secondPart = ApplyCutOutEffect(secondPart, effectEdge, effectType, effectSize, cutOutBackgroundColor);
|
||||
secondPart = ApplyCutOutEffect(secondPart, effectEdge, effectType, effectSize, backgroundColor);
|
||||
}
|
||||
|
||||
if (firstPart != null && secondPart != null)
|
||||
|
@ -1844,7 +1844,12 @@ namespace ShareX.HelpersLib
|
|||
}
|
||||
}
|
||||
|
||||
public static Bitmap WavyEdges(Bitmap bmp, int waveDepth, int waveRange, AnchorStyles sides, Color cutOutBackgroundColor)
|
||||
public static Bitmap WavyEdges(Bitmap bmp, int waveDepth, int waveRange, AnchorStyles sides)
|
||||
{
|
||||
return WavyEdges(bmp, waveDepth, waveRange, sides, Color.Transparent);
|
||||
}
|
||||
|
||||
public static Bitmap WavyEdges(Bitmap bmp, int waveDepth, int waveRange, AnchorStyles sides, Color backgroundColor)
|
||||
{
|
||||
if (waveDepth < 1 || waveRange < 1 || sides == AnchorStyles.None)
|
||||
{
|
||||
|
@ -1928,22 +1933,31 @@ namespace ShareX.HelpersLib
|
|||
}
|
||||
|
||||
Bitmap bmpResult = bmp.CreateEmptyBitmap();
|
||||
|
||||
using (bmp)
|
||||
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||
using (TextureBrush brush = new TextureBrush(bmp))
|
||||
{
|
||||
if (backgroundColor.A > 0)
|
||||
{
|
||||
g.Clear(backgroundColor);
|
||||
}
|
||||
|
||||
g.SetHighQuality();
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
if (cutOutBackgroundColor.A > 0)
|
||||
{
|
||||
g.Clear(cutOutBackgroundColor);
|
||||
}
|
||||
|
||||
g.FillPolygon(brush, points.ToArray());
|
||||
}
|
||||
|
||||
return bmpResult;
|
||||
}
|
||||
|
||||
public static Bitmap TornEdges(Bitmap bmp, int tornDepth, int tornRange, AnchorStyles sides, bool curvedEdges, bool random, Color cutOutBackgroundColor)
|
||||
public static Bitmap TornEdges(Bitmap bmp, int tornDepth, int tornRange, AnchorStyles sides, bool curvedEdges, bool random)
|
||||
{
|
||||
return TornEdges(bmp, tornDepth, tornRange, sides, curvedEdges, random, Color.Transparent);
|
||||
}
|
||||
|
||||
public static Bitmap TornEdges(Bitmap bmp, int tornDepth, int tornRange, AnchorStyles sides, bool curvedEdges, bool random, Color backgroundColor)
|
||||
{
|
||||
if (tornDepth < 1 || tornRange < 1 || sides == AnchorStyles.None)
|
||||
{
|
||||
|
@ -2030,12 +2044,13 @@ namespace ShareX.HelpersLib
|
|||
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||
using (TextureBrush brush = new TextureBrush(bmp))
|
||||
{
|
||||
if (backgroundColor.A > 0)
|
||||
{
|
||||
g.Clear(backgroundColor);
|
||||
}
|
||||
|
||||
g.SetHighQuality();
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
if (cutOutBackgroundColor.A > 0)
|
||||
{
|
||||
g.Clear(cutOutBackgroundColor);
|
||||
}
|
||||
|
||||
Point[] fillPoints = points.Distinct().ToArray();
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
using ShareX.HelpersLib;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ImageEffectsLib
|
||||
|
@ -46,9 +45,6 @@ namespace ShareX.ImageEffectsLib
|
|||
[DefaultValue(true)]
|
||||
public bool CurvedEdges { get; set; }
|
||||
|
||||
[DefaultValue(typeof(Color), "Transparent"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
||||
public Color CutOutBackgroundColor { get; set; }
|
||||
|
||||
public TornEdge()
|
||||
{
|
||||
this.ApplyDefaultPropertyValues();
|
||||
|
@ -56,7 +52,7 @@ namespace ShareX.ImageEffectsLib
|
|||
|
||||
public override Bitmap Apply(Bitmap bmp)
|
||||
{
|
||||
return ImageHelpers.TornEdges(bmp, Depth, Range, Sides, CurvedEdges, true, CutOutBackgroundColor);
|
||||
return ImageHelpers.TornEdges(bmp, Depth, Range, Sides, CurvedEdges, true);
|
||||
}
|
||||
|
||||
protected override string GetSummary()
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
using ShareX.HelpersLib;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ImageEffectsLib
|
||||
|
@ -48,12 +47,9 @@ namespace ShareX.ImageEffectsLib
|
|||
this.ApplyDefaultPropertyValues();
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "Transparent"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
||||
public Color CutOutBackgroundColor { get; set; }
|
||||
|
||||
public override Bitmap Apply(Bitmap bmp)
|
||||
{
|
||||
return ImageHelpers.WavyEdges(bmp, Depth, Range, Sides, CutOutBackgroundColor);
|
||||
return ImageHelpers.WavyEdges(bmp, Depth, Range, Sides);
|
||||
}
|
||||
|
||||
protected override string GetSummary()
|
||||
|
|
|
@ -324,7 +324,7 @@ namespace ShareX.ScreenCaptureLib.Properties {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cut out background color.
|
||||
/// Looks up a localized string similar to Cut out background color....
|
||||
/// </summary>
|
||||
internal static string CutOutBackgroundColor {
|
||||
get {
|
||||
|
|
|
@ -831,6 +831,6 @@ Would you like to save the changes before closing the image editor?</value>
|
|||
<value>..\Resources\control-record-green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="CutOutBackgroundColor" xml:space="preserve">
|
||||
<value>Cut out background color</value>
|
||||
<value>Cut out background color...</value>
|
||||
</data>
|
||||
</root>
|
|
@ -47,7 +47,7 @@ namespace ShareX
|
|||
switch (info.DataType)
|
||||
{
|
||||
case EDataType.Image:
|
||||
InitCapture(info.TaskSettings);
|
||||
InitCapture(info.TaskSettings, info.DataType);
|
||||
break;
|
||||
case EDataType.Text:
|
||||
Helpers.GetEnums<TextDestination>().ForEach(x =>
|
||||
|
@ -61,7 +61,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomTextUploaderSelected, info.TaskSettings);
|
||||
}
|
||||
|
||||
AddDestination<TextDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText);
|
||||
AddDestination<TextDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText, info.DataType);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomFileUploaderSelected, info.TaskSettings);
|
||||
}
|
||||
|
||||
AddDestination<FileDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText);
|
||||
AddDestination<FileDestination>((int)x, EDataType.Text, info.TaskSettings, overrideText, info.DataType);
|
||||
});
|
||||
|
||||
flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||
|
@ -99,7 +99,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomFileUploaderSelected, info.TaskSettings);
|
||||
}
|
||||
|
||||
AddDestination<FileDestination>((int)x, EDataType.File, info.TaskSettings, overrideText);
|
||||
AddDestination<FileDestination>((int)x, EDataType.File, info.TaskSettings, overrideText, info.DataType);
|
||||
});
|
||||
|
||||
flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||
|
@ -117,7 +117,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomURLShortenerSelected, info.TaskSettings);
|
||||
}
|
||||
|
||||
AddDestination<UrlShortenerType>((int)x, EDataType.URL, info.TaskSettings, overrideText);
|
||||
AddDestination<UrlShortenerType>((int)x, EDataType.URL, info.TaskSettings, overrideText, info.DataType);
|
||||
});
|
||||
|
||||
flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||
|
@ -131,7 +131,7 @@ namespace ShareX
|
|||
OnInitCompleted();
|
||||
}
|
||||
|
||||
public void InitCapture(TaskSettings taskSettings)
|
||||
public void InitCapture(TaskSettings taskSettings, EDataType trueDateType = EDataType.Default)
|
||||
{
|
||||
Helpers.GetEnums<ImageDestination>().ForEach(x =>
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomImageUploaderSelected, taskSettings);
|
||||
}
|
||||
|
||||
AddDestination<ImageDestination>((int)x, EDataType.Image, taskSettings, overrideText);
|
||||
AddDestination<ImageDestination>((int)x, EDataType.Image, taskSettings, overrideText, trueDateType);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace ShareX
|
|||
overrideText = GetCustomUploaderName(Program.UploadersConfig.CustomFileUploaderSelected, taskSettings);
|
||||
}
|
||||
|
||||
AddDestination<FileDestination>((int)x, EDataType.File, taskSettings, overrideText);
|
||||
AddDestination<FileDestination>((int)x, EDataType.File, taskSettings, overrideText, trueDateType);
|
||||
});
|
||||
|
||||
flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||
|
@ -187,23 +187,67 @@ namespace ShareX
|
|||
}
|
||||
}
|
||||
|
||||
private void AddDestination<T>(int index, EDataType dataType, TaskSettings taskSettings, string overrideText = null)
|
||||
private void AddDestination<T>(int index, EDataType dataType, TaskSettings taskSettings, string overrideText = null, EDataType trueDataType = EDataType.Default)
|
||||
{
|
||||
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
||||
|
||||
if (UploadersConfigValidator.Validate<T>(index, Program.UploadersConfig))
|
||||
if (destination.Equals(FileDestination.FTP))
|
||||
{
|
||||
RadioButton rb = new RadioButton() { AutoSize = true };
|
||||
|
||||
rb.Text = string.IsNullOrEmpty(overrideText) ? destination.GetLocalizedDescription() :
|
||||
string.Format("{0} [{1}]", Resources.BeforeUploadControl_AddDestination_Custom, overrideText);
|
||||
rb.Text = string.Format("FTP");
|
||||
rb.Tag = destination;
|
||||
rb.CheckedChanged += (sender, e) => SetDestinations(rb.Checked, dataType, rb.Tag, taskSettings);
|
||||
|
||||
ComboBox ftpComboBox = new ComboBox() { Size = new System.Drawing.Size(250, 100) };
|
||||
Program.UploadersConfig.FTPAccountList.ForEach(ftpAcc => { ftpComboBox.Items.Add(ftpAcc.Name); });
|
||||
ftpComboBox.SelectedIndexChanged += (sender, e) => SetFTPOverrideIndex(ftpComboBox.SelectedIndex, taskSettings);
|
||||
switch (trueDataType)
|
||||
{
|
||||
case EDataType.Image:
|
||||
ftpComboBox.SelectedIndex = Program.UploadersConfig.FTPSelectedImage;
|
||||
break;
|
||||
case EDataType.Text:
|
||||
ftpComboBox.SelectedIndex = Program.UploadersConfig.FTPSelectedText;
|
||||
break;
|
||||
default:
|
||||
case EDataType.File:
|
||||
ftpComboBox.SelectedIndex = Program.UploadersConfig.FTPSelectedFile;
|
||||
break;
|
||||
}
|
||||
rb.CheckedChanged += (sender, e) => SetFTPOverride(rb.Checked, ftpComboBox.SelectedIndex, taskSettings);
|
||||
flp.Controls.Add(rb);
|
||||
flp.Controls.Add(ftpComboBox);
|
||||
} else {
|
||||
if (UploadersConfigValidator.Validate<T>(index, Program.UploadersConfig))
|
||||
{
|
||||
RadioButton rb = new RadioButton() { AutoSize = true };
|
||||
|
||||
rb.Text = string.IsNullOrEmpty(overrideText) ? destination.GetLocalizedDescription() :
|
||||
string.Format("{0} [{1}]", Resources.BeforeUploadControl_AddDestination_Custom, overrideText);
|
||||
rb.Tag = destination;
|
||||
rb.CheckedChanged += (sender, e) => SetDestinations(rb.Checked, dataType, rb.Tag, taskSettings);
|
||||
|
||||
flp.Controls.Add(rb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFTPOverrideIndex(int ftpAccIndex, TaskSettings taskSettings)
|
||||
{
|
||||
DebugHelper.WriteLine(ftpAccIndex.ToString());
|
||||
taskSettings.FTPIndex = ftpAccIndex;
|
||||
}
|
||||
|
||||
private void SetFTPOverride(bool isActive, int ftpAccIndex, TaskSettings taskSettings)
|
||||
{
|
||||
if (!isActive) return;
|
||||
DebugHelper.WriteLine(ftpAccIndex.ToString());
|
||||
taskSettings.OverrideFTP = true;
|
||||
taskSettings.FTPIndex = ftpAccIndex;
|
||||
taskSettings.ImageDestination = ImageDestination.FileUploader;
|
||||
taskSettings.TextDestination = TextDestination.FileUploader;
|
||||
taskSettings.ImageFileDestination = taskSettings.TextFileDestination = taskSettings.FileDestination = FileDestination.FTP;
|
||||
}
|
||||
|
||||
private void SetDestinations(bool isActive, EDataType dataType, object destination, TaskSettings taskSettings)
|
||||
{
|
||||
if (!isActive) return;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace ShareX
|
|||
lvAfterCaptureTasks.SmallImageList = imageList;
|
||||
lvAfterUploadTasks.SmallImageList = imageList;
|
||||
|
||||
ucBeforeUpload.InitCapture(TaskSettings);
|
||||
ucBeforeUpload.InitCapture(TaskSettings, EDataType.Image);
|
||||
|
||||
AddAfterCaptureItems(TaskSettings.AfterCaptureJob);
|
||||
AddAfterUploadItems(TaskSettings.AfterUploadJob);
|
||||
|
|
|
@ -431,6 +431,12 @@ namespace ShareX
|
|||
|
||||
if (!cancelUpload)
|
||||
{
|
||||
if (Info.TaskSettings.OverrideFTP)
|
||||
{
|
||||
taskReferenceHelper.OverrideFTP = true;
|
||||
taskReferenceHelper.FTPIndex = Info.TaskSettings.FTPIndex;
|
||||
}
|
||||
|
||||
OnUploadStarted();
|
||||
|
||||
bool isError = DoUpload(Data, Info.FileName);
|
||||
|
|
Loading…
Reference in New Issue