mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Using DrawText & DrawImage in WatermarkManager
Removed GradientMaker because it was not good enough
This commit is contained in:
parent
6f4ba22ba0
commit
15ee7a2338
12 changed files with 119 additions and 983 deletions
|
@ -25,12 +25,15 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
using HelpersLib;
|
using HelpersLib;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Design;
|
using System.Drawing.Design;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Text;
|
using System.Drawing.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ImageEffectsLib
|
namespace ImageEffectsLib
|
||||||
|
@ -93,6 +96,12 @@ public Font TextFont
|
||||||
[DefaultValue(typeof(Color), "Black"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
[DefaultValue(typeof(Color), "Black"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
||||||
public Color BackgroundColor2 { get; set; }
|
public Color BackgroundColor2 { get; set; }
|
||||||
|
|
||||||
|
[Browsable(false), DefaultValue(false)]
|
||||||
|
public bool UseCustomGradient { get; set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public List<GradientStop> CustomGradientList { get; set; }
|
||||||
|
|
||||||
[DefaultValue(LinearGradientMode.Vertical)]
|
[DefaultValue(LinearGradientMode.Vertical)]
|
||||||
public LinearGradientMode GradientType { get; set; }
|
public LinearGradientMode GradientType { get; set; }
|
||||||
|
|
||||||
|
@ -145,6 +154,15 @@ public override Image Apply(Image img)
|
||||||
if (UseGradient)
|
if (UseGradient)
|
||||||
{
|
{
|
||||||
backgroundBrush = new LinearGradientBrush(backgroundRect, BackgroundColor, BackgroundColor2, GradientType);
|
backgroundBrush = new LinearGradientBrush(backgroundRect, BackgroundColor, BackgroundColor2, GradientType);
|
||||||
|
|
||||||
|
if (UseCustomGradient && CustomGradientList != null && CustomGradientList.Count > 1)
|
||||||
|
{
|
||||||
|
ColorBlend colorBlend = new ColorBlend();
|
||||||
|
IEnumerable<GradientStop> gradient = CustomGradientList.OrderBy(x => x.Offset);
|
||||||
|
colorBlend.Colors = gradient.Select(x => x.Color).ToArray();
|
||||||
|
colorBlend.Positions = gradient.Select(x => x.Offset).ToArray();
|
||||||
|
((LinearGradientBrush)backgroundBrush).InterpolationColors = colorBlend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,13 +122,6 @@
|
||||||
<Compile Include="Manipulations\Resize.cs" />
|
<Compile Include="Manipulations\Resize.cs" />
|
||||||
<Compile Include="Manipulations\Rotate.cs" />
|
<Compile Include="Manipulations\Rotate.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Watermark\GradientData.cs" />
|
|
||||||
<Compile Include="Watermark\GradientMaker.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Watermark\GradientMaker.Designer.cs">
|
|
||||||
<DependentUpon>GradientMaker.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Watermark\GradientStop.cs" />
|
<Compile Include="Watermark\GradientStop.cs" />
|
||||||
<Compile Include="Watermark\WatermarkConfig.cs" />
|
<Compile Include="Watermark\WatermarkConfig.cs" />
|
||||||
<Compile Include="Watermark\WatermarkManager.cs" />
|
<Compile Include="Watermark\WatermarkManager.cs" />
|
||||||
|
@ -166,9 +159,6 @@
|
||||||
<EmbeddedResource Include="ImageEffectsForm.resx">
|
<EmbeddedResource Include="ImageEffectsForm.resx">
|
||||||
<DependentUpon>ImageEffectsForm.cs</DependentUpon>
|
<DependentUpon>ImageEffectsForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Watermark\GradientMaker.resx">
|
|
||||||
<DependentUpon>GradientMaker.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Watermark\WatermarkForm.resx">
|
<EmbeddedResource Include="Watermark\WatermarkForm.resx">
|
||||||
<DependentUpon>WatermarkForm.cs</DependentUpon>
|
<DependentUpon>WatermarkForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright (C) 2008-2013 ShareX Developers
|
|
||||||
|
|
||||||
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 System.Drawing.Drawing2D;
|
|
||||||
|
|
||||||
namespace ImageEffectsLib
|
|
||||||
{
|
|
||||||
public class GradientData
|
|
||||||
{
|
|
||||||
public string Data { get; set; }
|
|
||||||
public LinearGradientMode Type { get; set; }
|
|
||||||
|
|
||||||
public GradientData()
|
|
||||||
{
|
|
||||||
Data = "255,68,120,194\t0\n255,13,58,122\t0.5\n255,6,36,78\t0.5\n255,12,76,159\t1";
|
|
||||||
Type = LinearGradientMode.Vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GradientData(string data, LinearGradientMode type)
|
|
||||||
{
|
|
||||||
Data = data;
|
|
||||||
Type = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
201
ImageEffectsLib/Watermark/GradientMaker.Designer.cs
generated
201
ImageEffectsLib/Watermark/GradientMaker.Designer.cs
generated
|
@ -1,201 +0,0 @@
|
||||||
namespace ImageEffectsLib
|
|
||||||
{
|
|
||||||
partial class GradientMaker
|
|
||||||
{
|
|
||||||
/// <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.pbPreview = new System.Windows.Forms.PictureBox();
|
|
||||||
this.btnAddColor = new System.Windows.Forms.Button();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
|
||||||
this.txtColor = new System.Windows.Forms.TextBox();
|
|
||||||
this.txtOffset = new System.Windows.Forms.TextBox();
|
|
||||||
this.btnBrowseColor = new System.Windows.Forms.Button();
|
|
||||||
this.rtbCodes = new System.Windows.Forms.RichTextBox();
|
|
||||||
this.btnOK = new System.Windows.Forms.Button();
|
|
||||||
this.btnCancel = new System.Windows.Forms.Button();
|
|
||||||
this.cboGradientDirection = new System.Windows.Forms.ComboBox();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbPreview)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// pbPreview
|
|
||||||
//
|
|
||||||
this.pbPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.pbPreview.Location = new System.Drawing.Point(8, 6);
|
|
||||||
this.pbPreview.Name = "pbPreview";
|
|
||||||
this.pbPreview.Size = new System.Drawing.Size(384, 50);
|
|
||||||
this.pbPreview.TabIndex = 2;
|
|
||||||
this.pbPreview.TabStop = false;
|
|
||||||
//
|
|
||||||
// btnAddColor
|
|
||||||
//
|
|
||||||
this.btnAddColor.Location = new System.Drawing.Point(296, 300);
|
|
||||||
this.btnAddColor.Name = "btnAddColor";
|
|
||||||
this.btnAddColor.Size = new System.Drawing.Size(96, 23);
|
|
||||||
this.btnAddColor.TabIndex = 12;
|
|
||||||
this.btnAddColor.Text = "Add / Update";
|
|
||||||
this.btnAddColor.UseVisualStyleBackColor = true;
|
|
||||||
this.btnAddColor.Click += new System.EventHandler(this.btnAddColor_Click);
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
this.label3.AutoSize = true;
|
|
||||||
this.label3.Location = new System.Drawing.Point(8, 303);
|
|
||||||
this.label3.Name = "label3";
|
|
||||||
this.label3.Size = new System.Drawing.Size(34, 13);
|
|
||||||
this.label3.TabIndex = 7;
|
|
||||||
this.label3.Text = "Color:";
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
this.label4.AutoSize = true;
|
|
||||||
this.label4.Location = new System.Drawing.Point(200, 303);
|
|
||||||
this.label4.Name = "label4";
|
|
||||||
this.label4.Size = new System.Drawing.Size(38, 13);
|
|
||||||
this.label4.TabIndex = 10;
|
|
||||||
this.label4.Text = "Offset:";
|
|
||||||
//
|
|
||||||
// txtColor
|
|
||||||
//
|
|
||||||
this.txtColor.Location = new System.Drawing.Point(48, 300);
|
|
||||||
this.txtColor.Name = "txtColor";
|
|
||||||
this.txtColor.Size = new System.Drawing.Size(112, 20);
|
|
||||||
this.txtColor.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// txtOffset
|
|
||||||
//
|
|
||||||
this.txtOffset.Location = new System.Drawing.Point(248, 300);
|
|
||||||
this.txtOffset.Name = "txtOffset";
|
|
||||||
this.txtOffset.Size = new System.Drawing.Size(40, 20);
|
|
||||||
this.txtOffset.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// btnBrowseColor
|
|
||||||
//
|
|
||||||
this.btnBrowseColor.Location = new System.Drawing.Point(168, 300);
|
|
||||||
this.btnBrowseColor.Name = "btnBrowseColor";
|
|
||||||
this.btnBrowseColor.Size = new System.Drawing.Size(24, 23);
|
|
||||||
this.btnBrowseColor.TabIndex = 9;
|
|
||||||
this.btnBrowseColor.Text = "...";
|
|
||||||
this.btnBrowseColor.UseVisualStyleBackColor = true;
|
|
||||||
this.btnBrowseColor.Click += new System.EventHandler(this.btnBrowseColor_Click);
|
|
||||||
//
|
|
||||||
// rtbCodes
|
|
||||||
//
|
|
||||||
this.rtbCodes.AcceptsTab = true;
|
|
||||||
this.rtbCodes.Font = new System.Drawing.Font("Lucida Console", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.rtbCodes.Location = new System.Drawing.Point(8, 64);
|
|
||||||
this.rtbCodes.Name = "rtbCodes";
|
|
||||||
this.rtbCodes.Size = new System.Drawing.Size(384, 232);
|
|
||||||
this.rtbCodes.TabIndex = 5;
|
|
||||||
this.rtbCodes.Text = "";
|
|
||||||
this.rtbCodes.SelectionChanged += new System.EventHandler(this.rtbCodes_SelectionChanged);
|
|
||||||
this.rtbCodes.TextChanged += new System.EventHandler(this.rtbCodes_TextChanged);
|
|
||||||
//
|
|
||||||
// btnOK
|
|
||||||
//
|
|
||||||
this.btnOK.Location = new System.Drawing.Point(240, 332);
|
|
||||||
this.btnOK.Name = "btnOK";
|
|
||||||
this.btnOK.Size = new System.Drawing.Size(72, 23);
|
|
||||||
this.btnOK.TabIndex = 14;
|
|
||||||
this.btnOK.Text = "OK";
|
|
||||||
this.btnOK.UseVisualStyleBackColor = true;
|
|
||||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
|
||||||
//
|
|
||||||
// btnCancel
|
|
||||||
//
|
|
||||||
this.btnCancel.Location = new System.Drawing.Point(320, 332);
|
|
||||||
this.btnCancel.Name = "btnCancel";
|
|
||||||
this.btnCancel.Size = new System.Drawing.Size(72, 23);
|
|
||||||
this.btnCancel.TabIndex = 15;
|
|
||||||
this.btnCancel.Text = "Cancel";
|
|
||||||
this.btnCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
|
||||||
//
|
|
||||||
// cboGradientDirection
|
|
||||||
//
|
|
||||||
this.cboGradientDirection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.cboGradientDirection.FormattingEnabled = true;
|
|
||||||
this.cboGradientDirection.Location = new System.Drawing.Point(104, 332);
|
|
||||||
this.cboGradientDirection.Name = "cboGradientDirection";
|
|
||||||
this.cboGradientDirection.Size = new System.Drawing.Size(128, 21);
|
|
||||||
this.cboGradientDirection.TabIndex = 3;
|
|
||||||
this.cboGradientDirection.SelectedIndexChanged += new System.EventHandler(this.cboGradientDirection_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(8, 336);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(93, 13);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Gradient direction:";
|
|
||||||
//
|
|
||||||
// GradientMaker
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(401, 361);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.cboGradientDirection);
|
|
||||||
this.Controls.Add(this.btnCancel);
|
|
||||||
this.Controls.Add(this.btnOK);
|
|
||||||
this.Controls.Add(this.rtbCodes);
|
|
||||||
this.Controls.Add(this.btnBrowseColor);
|
|
||||||
this.Controls.Add(this.txtOffset);
|
|
||||||
this.Controls.Add(this.txtColor);
|
|
||||||
this.Controls.Add(this.label4);
|
|
||||||
this.Controls.Add(this.label3);
|
|
||||||
this.Controls.Add(this.btnAddColor);
|
|
||||||
this.Controls.Add(this.pbPreview);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.Name = "GradientMaker";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "ShareX - Gradient maker";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbPreview)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Windows Form Designer generated code
|
|
||||||
|
|
||||||
private System.Windows.Forms.PictureBox pbPreview;
|
|
||||||
private System.Windows.Forms.Button btnAddColor;
|
|
||||||
private System.Windows.Forms.Label label3;
|
|
||||||
private System.Windows.Forms.Label label4;
|
|
||||||
private System.Windows.Forms.TextBox txtColor;
|
|
||||||
private System.Windows.Forms.TextBox txtOffset;
|
|
||||||
private System.Windows.Forms.Button btnBrowseColor;
|
|
||||||
private System.Windows.Forms.RichTextBox rtbCodes;
|
|
||||||
private System.Windows.Forms.Button btnOK;
|
|
||||||
private System.Windows.Forms.Button btnCancel;
|
|
||||||
private System.Windows.Forms.ComboBox cboGradientDirection;
|
|
||||||
private System.Windows.Forms.Label label1;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,218 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright (C) 2008-2013 ShareX Developers
|
|
||||||
|
|
||||||
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 HelpersLib;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ImageEffectsLib
|
|
||||||
{
|
|
||||||
public partial class GradientMaker : Form
|
|
||||||
{
|
|
||||||
public GradientData GradientData { get; private set; }
|
|
||||||
|
|
||||||
private bool isEditable;
|
|
||||||
private bool isEditing;
|
|
||||||
private string lastData;
|
|
||||||
|
|
||||||
public GradientMaker()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
cboGradientDirection.Items.AddRange(Enum.GetNames(typeof(LinearGradientMode)));
|
|
||||||
cboGradientDirection.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GradientMaker(GradientData gradientData)
|
|
||||||
: this()
|
|
||||||
{
|
|
||||||
GradientData = gradientData;
|
|
||||||
|
|
||||||
if (GradientData != null)
|
|
||||||
{
|
|
||||||
rtbCodes.Text = GradientData.Data;
|
|
||||||
cboGradientDirection.SelectedIndex = (int)GradientData.Type;
|
|
||||||
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdatePreview()
|
|
||||||
{
|
|
||||||
GradientData = GetNewBrushData();
|
|
||||||
|
|
||||||
if (GradientData != null && !string.IsNullOrEmpty(GradientData.Data))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (LinearGradientBrush brush = CreateGradientBrush(pbPreview.ClientSize, GradientData))
|
|
||||||
{
|
|
||||||
Bitmap bmp = new Bitmap(pbPreview.ClientSize.Width, pbPreview.ClientSize.Height);
|
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(bmp))
|
|
||||||
{
|
|
||||||
g.FillRectangle(brush, 0, 0, pbPreview.ClientSize.Width, pbPreview.ClientSize.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
pbPreview.Image = bmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.WriteLine(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GradientStop[] ParseGradientData(string gradientData)
|
|
||||||
{
|
|
||||||
List<GradientStop> gradient = new List<GradientStop>();
|
|
||||||
string[] lines = gradientData.Split('\n').Select(x => x.Trim()).ToArray();
|
|
||||||
foreach (string line in lines)
|
|
||||||
{
|
|
||||||
if (line.Contains('\t'))
|
|
||||||
{
|
|
||||||
gradient.Add(ParseLine(line));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return gradient.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GradientStop ParseLine(string line)
|
|
||||||
{
|
|
||||||
return new GradientStop(line.Substring(0, line.IndexOf('\t')), line.Remove(0, line.IndexOf('\t') + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinearGradientBrush CreateGradientBrush(Size size, GradientData gradientData)
|
|
||||||
{
|
|
||||||
IEnumerable<GradientStop> gradient = ParseGradientData(gradientData.Data);
|
|
||||||
gradient = gradient.OrderBy(x => x.Offset);
|
|
||||||
|
|
||||||
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, size.Width, size.Height), Color.Black, Color.Black, gradientData.Type);
|
|
||||||
ColorBlend blend = new ColorBlend();
|
|
||||||
blend.Colors = gradient.Select(x => x.Color).ToArray();
|
|
||||||
blend.Positions = gradient.Select(x => x.Offset).ToArray();
|
|
||||||
brush.InterpolationColors = blend;
|
|
||||||
return brush;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GradientData GetNewBrushData()
|
|
||||||
{
|
|
||||||
return new GradientData(rtbCodes.Text, (LinearGradientMode)cboGradientDirection.SelectedIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Form events
|
|
||||||
|
|
||||||
private void rtbCodes_SelectionChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!isEditing)
|
|
||||||
{
|
|
||||||
isEditable = false;
|
|
||||||
int firstcharindex = rtbCodes.GetFirstCharIndexOfCurrentLine();
|
|
||||||
int currentline = rtbCodes.GetLineFromCharIndex(firstcharindex);
|
|
||||||
if (rtbCodes.Lines.Length > currentline)
|
|
||||||
{
|
|
||||||
string line = rtbCodes.Lines[currentline];
|
|
||||||
if (line.Contains('\t'))
|
|
||||||
{
|
|
||||||
txtColor.Text = line.Substring(0, line.IndexOf('\t'));
|
|
||||||
txtOffset.Text = line.Remove(0, line.IndexOf('\t') + 1);
|
|
||||||
isEditable = true;
|
|
||||||
if (rtbCodes.Text != lastData)
|
|
||||||
{
|
|
||||||
UpdatePreview();
|
|
||||||
lastData = rtbCodes.Text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rtbCodes_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnBrowseColor_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using (DialogColor colorPicker = new DialogColor())
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(txtColor.Text))
|
|
||||||
{
|
|
||||||
colorPicker.SetCurrentColor(ColorHelpers.ParseColor(txtColor.Text));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorPicker.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
Color color = colorPicker.NewColor;
|
|
||||||
txtColor.Text = string.Format("{0},{1},{2},{3}", color.A, color.R, color.G, color.B);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnAddColor_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
isEditing = true;
|
|
||||||
if (isEditable)
|
|
||||||
{
|
|
||||||
int firstcharindex = rtbCodes.GetFirstCharIndexOfCurrentLine();
|
|
||||||
int currentline = rtbCodes.GetLineFromCharIndex(firstcharindex);
|
|
||||||
if (rtbCodes.Lines.Length > currentline)
|
|
||||||
{
|
|
||||||
rtbCodes.SelectionStart = firstcharindex;
|
|
||||||
rtbCodes.SelectionLength = rtbCodes.Lines[currentline].Length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rtbCodes.SelectedText = string.Format("{0}\t{1}", txtColor.Text, txtOffset.Text);
|
|
||||||
isEditing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cboGradientDirection_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnOK_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
GradientData = GetNewBrushData();
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Form events
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
|
@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
using HelpersLib;
|
using HelpersLib;
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
|
@ -32,33 +33,36 @@ namespace ImageEffectsLib
|
||||||
{
|
{
|
||||||
public class GradientStop
|
public class GradientStop
|
||||||
{
|
{
|
||||||
|
[DefaultValue(typeof(Color), "Black")]
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
public float Offset { get; set; }
|
|
||||||
|
private float offset;
|
||||||
|
|
||||||
|
[DefaultValue(0f)]
|
||||||
|
public float Offset
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value >= 0 || value <= 1)
|
||||||
|
{
|
||||||
|
offset = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradientStop()
|
||||||
|
{
|
||||||
|
this.ApplyDefaultPropertyValues();
|
||||||
|
}
|
||||||
|
|
||||||
public GradientStop(Color color, float offset)
|
public GradientStop(Color color, float offset)
|
||||||
{
|
{
|
||||||
Color = color;
|
Color = color;
|
||||||
Offset = offset;
|
Offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradientStop(string color, string offset)
|
|
||||||
{
|
|
||||||
Color = ColorHelpers.ParseColor(color);
|
|
||||||
|
|
||||||
if (Color == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Color is unknown.");
|
|
||||||
}
|
|
||||||
|
|
||||||
float offset2;
|
|
||||||
if (float.TryParse(offset, NumberStyles.Any, CultureInfo.InvariantCulture, out offset2))
|
|
||||||
{
|
|
||||||
Offset = offset2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Offset = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,34 +24,13 @@ You should have received a copy of the GNU General Public License
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using HelpersLib;
|
using HelpersLib;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
namespace ImageEffectsLib
|
namespace ImageEffectsLib
|
||||||
{
|
{
|
||||||
public enum WatermarkPositionType
|
|
||||||
{
|
|
||||||
[Description("Top - Left")]
|
|
||||||
TOP_LEFT,
|
|
||||||
[Description("Top - Center")]
|
|
||||||
TOP,
|
|
||||||
[Description("Top - Right")]
|
|
||||||
TOP_RIGHT,
|
|
||||||
[Description("Center - Left")]
|
|
||||||
LEFT,
|
|
||||||
[Description("Center")]
|
|
||||||
CENTER,
|
|
||||||
[Description("Center - Right")]
|
|
||||||
RIGHT,
|
|
||||||
[Description("Bottom - Left")]
|
|
||||||
BOTTOM_LEFT,
|
|
||||||
[Description("Bottom - Center")]
|
|
||||||
BOTTOM,
|
|
||||||
[Description("Bottom - Right")]
|
|
||||||
BOTTOM_RIGHT
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum WatermarkType
|
public enum WatermarkType
|
||||||
{
|
{
|
||||||
[Description("Text")]
|
[Description("Text")]
|
||||||
|
@ -63,9 +42,8 @@ public enum WatermarkType
|
||||||
public class WatermarkConfig
|
public class WatermarkConfig
|
||||||
{
|
{
|
||||||
public WatermarkType WatermarkMode = WatermarkType.TEXT;
|
public WatermarkType WatermarkMode = WatermarkType.TEXT;
|
||||||
public WatermarkPositionType WatermarkPositionMode = WatermarkPositionType.BOTTOM_RIGHT;
|
public PositionType WatermarkPositionMode = PositionType.Bottom_Right;
|
||||||
public int WatermarkOffset = 5;
|
public int WatermarkOffset = 5;
|
||||||
public bool WatermarkAddReflection = false;
|
|
||||||
public bool WatermarkAutoHide = true;
|
public bool WatermarkAutoHide = true;
|
||||||
|
|
||||||
public string WatermarkText = "%h:%mi";
|
public string WatermarkText = "%h:%mi";
|
||||||
|
@ -78,10 +56,8 @@ public class WatermarkConfig
|
||||||
public XmlColor WatermarkBorderArgb = Color.Black;
|
public XmlColor WatermarkBorderArgb = Color.Black;
|
||||||
public LinearGradientMode WatermarkGradientType = LinearGradientMode.Vertical;
|
public LinearGradientMode WatermarkGradientType = LinearGradientMode.Vertical;
|
||||||
public bool WatermarkUseCustomGradient = false;
|
public bool WatermarkUseCustomGradient = false;
|
||||||
public GradientData WatermarkGradient = new GradientData();
|
public List<GradientStop> WatermarkGradientList = new List<GradientStop>();
|
||||||
|
|
||||||
public string WatermarkImageLocation = "";
|
public string WatermarkImageLocation = "";
|
||||||
public bool WatermarkUseBorder = false;
|
|
||||||
public int WatermarkImageScale = 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
108
ImageEffectsLib/Watermark/WatermarkForm.Designer.cs
generated
108
ImageEffectsLib/Watermark/WatermarkForm.Designer.cs
generated
|
@ -31,7 +31,6 @@ private void InitializeComponent()
|
||||||
this.lblWatermarkOffsetPixel = new System.Windows.Forms.Label();
|
this.lblWatermarkOffsetPixel = new System.Windows.Forms.Label();
|
||||||
this.cboWatermarkType = new System.Windows.Forms.ComboBox();
|
this.cboWatermarkType = new System.Windows.Forms.ComboBox();
|
||||||
this.cbWatermarkAutoHide = new System.Windows.Forms.CheckBox();
|
this.cbWatermarkAutoHide = new System.Windows.Forms.CheckBox();
|
||||||
this.cbWatermarkAddReflection = new System.Windows.Forms.CheckBox();
|
|
||||||
this.lblWatermarkType = new System.Windows.Forms.Label();
|
this.lblWatermarkType = new System.Windows.Forms.Label();
|
||||||
this.chkWatermarkPosition = new System.Windows.Forms.ComboBox();
|
this.chkWatermarkPosition = new System.Windows.Forms.ComboBox();
|
||||||
this.lblWatermarkPosition = new System.Windows.Forms.Label();
|
this.lblWatermarkPosition = new System.Windows.Forms.Label();
|
||||||
|
@ -40,9 +39,7 @@ private void InitializeComponent()
|
||||||
this.gbWatermarkBackground = new System.Windows.Forms.GroupBox();
|
this.gbWatermarkBackground = new System.Windows.Forms.GroupBox();
|
||||||
this.lblWatermarkBorderColor = new System.Windows.Forms.Label();
|
this.lblWatermarkBorderColor = new System.Windows.Forms.Label();
|
||||||
this.lblRectangleCornerRadius = new System.Windows.Forms.Label();
|
this.lblRectangleCornerRadius = new System.Windows.Forms.Label();
|
||||||
this.btnSelectGradient = new System.Windows.Forms.Button();
|
|
||||||
this.lblWatermarkBackColors2 = new System.Windows.Forms.Label();
|
this.lblWatermarkBackColors2 = new System.Windows.Forms.Label();
|
||||||
this.cboUseCustomGradient = new System.Windows.Forms.CheckBox();
|
|
||||||
this.nudWatermarkCornerRadius = new System.Windows.Forms.NumericUpDown();
|
this.nudWatermarkCornerRadius = new System.Windows.Forms.NumericUpDown();
|
||||||
this.lblWatermarkBackColors = new System.Windows.Forms.Label();
|
this.lblWatermarkBackColors = new System.Windows.Forms.Label();
|
||||||
this.pbWatermarkGradient2 = new System.Windows.Forms.PictureBox();
|
this.pbWatermarkGradient2 = new System.Windows.Forms.PictureBox();
|
||||||
|
@ -57,9 +54,6 @@ private void InitializeComponent()
|
||||||
this.btnWatermarkFont = new System.Windows.Forms.Button();
|
this.btnWatermarkFont = new System.Windows.Forms.Button();
|
||||||
this.txtWatermarkText = new System.Windows.Forms.TextBox();
|
this.txtWatermarkText = new System.Windows.Forms.TextBox();
|
||||||
this.pbWatermarkFontColor = new System.Windows.Forms.PictureBox();
|
this.pbWatermarkFontColor = new System.Windows.Forms.PictureBox();
|
||||||
this.lblWatermarkImageScale = new System.Windows.Forms.Label();
|
|
||||||
this.nudWatermarkImageScale = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.cbWatermarkUseBorder = new System.Windows.Forms.CheckBox();
|
|
||||||
this.btwWatermarkBrowseImage = new System.Windows.Forms.Button();
|
this.btwWatermarkBrowseImage = new System.Windows.Forms.Button();
|
||||||
this.txtWatermarkImageLocation = new System.Windows.Forms.TextBox();
|
this.txtWatermarkImageLocation = new System.Windows.Forms.TextBox();
|
||||||
this.pbPreview = new HelpersLib.MyPictureBox();
|
this.pbPreview = new HelpersLib.MyPictureBox();
|
||||||
|
@ -72,7 +66,6 @@ private void InitializeComponent()
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkBorderColor)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkBorderColor)).BeginInit();
|
||||||
this.gbWatermarkText.SuspendLayout();
|
this.gbWatermarkText.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkFontColor)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkFontColor)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudWatermarkImageScale)).BeginInit();
|
|
||||||
this.gbImageWatermark.SuspendLayout();
|
this.gbImageWatermark.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -98,7 +91,7 @@ private void InitializeComponent()
|
||||||
// cbWatermarkAutoHide
|
// cbWatermarkAutoHide
|
||||||
//
|
//
|
||||||
this.cbWatermarkAutoHide.AutoSize = true;
|
this.cbWatermarkAutoHide.AutoSize = true;
|
||||||
this.cbWatermarkAutoHide.Location = new System.Drawing.Point(16, 128);
|
this.cbWatermarkAutoHide.Location = new System.Drawing.Point(19, 107);
|
||||||
this.cbWatermarkAutoHide.Name = "cbWatermarkAutoHide";
|
this.cbWatermarkAutoHide.Name = "cbWatermarkAutoHide";
|
||||||
this.cbWatermarkAutoHide.Size = new System.Drawing.Size(260, 17);
|
this.cbWatermarkAutoHide.Size = new System.Drawing.Size(260, 17);
|
||||||
this.cbWatermarkAutoHide.TabIndex = 8;
|
this.cbWatermarkAutoHide.TabIndex = 8;
|
||||||
|
@ -106,17 +99,6 @@ private void InitializeComponent()
|
||||||
this.cbWatermarkAutoHide.UseVisualStyleBackColor = true;
|
this.cbWatermarkAutoHide.UseVisualStyleBackColor = true;
|
||||||
this.cbWatermarkAutoHide.CheckedChanged += new System.EventHandler(this.cbWatermarkAutoHide_CheckedChanged);
|
this.cbWatermarkAutoHide.CheckedChanged += new System.EventHandler(this.cbWatermarkAutoHide_CheckedChanged);
|
||||||
//
|
//
|
||||||
// cbWatermarkAddReflection
|
|
||||||
//
|
|
||||||
this.cbWatermarkAddReflection.AutoSize = true;
|
|
||||||
this.cbWatermarkAddReflection.Location = new System.Drawing.Point(16, 104);
|
|
||||||
this.cbWatermarkAddReflection.Name = "cbWatermarkAddReflection";
|
|
||||||
this.cbWatermarkAddReflection.Size = new System.Drawing.Size(121, 17);
|
|
||||||
this.cbWatermarkAddReflection.TabIndex = 7;
|
|
||||||
this.cbWatermarkAddReflection.Text = "Add reflection effect";
|
|
||||||
this.cbWatermarkAddReflection.UseVisualStyleBackColor = true;
|
|
||||||
this.cbWatermarkAddReflection.CheckedChanged += new System.EventHandler(this.cbWatermarkAddReflection_CheckedChanged);
|
|
||||||
//
|
|
||||||
// lblWatermarkType
|
// lblWatermarkType
|
||||||
//
|
//
|
||||||
this.lblWatermarkType.AutoSize = true;
|
this.lblWatermarkType.AutoSize = true;
|
||||||
|
@ -172,9 +154,7 @@ private void InitializeComponent()
|
||||||
//
|
//
|
||||||
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBorderColor);
|
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBorderColor);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.lblRectangleCornerRadius);
|
this.gbWatermarkBackground.Controls.Add(this.lblRectangleCornerRadius);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.btnSelectGradient);
|
|
||||||
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBackColors2);
|
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBackColors2);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.cboUseCustomGradient);
|
|
||||||
this.gbWatermarkBackground.Controls.Add(this.nudWatermarkCornerRadius);
|
this.gbWatermarkBackground.Controls.Add(this.nudWatermarkCornerRadius);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBackColors);
|
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkBackColors);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.pbWatermarkGradient2);
|
this.gbWatermarkBackground.Controls.Add(this.pbWatermarkGradient2);
|
||||||
|
@ -183,9 +163,9 @@ private void InitializeComponent()
|
||||||
this.gbWatermarkBackground.Controls.Add(this.pbWatermarkBorderColor);
|
this.gbWatermarkBackground.Controls.Add(this.pbWatermarkBorderColor);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.cbWatermarkGradientType);
|
this.gbWatermarkBackground.Controls.Add(this.cbWatermarkGradientType);
|
||||||
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkGradientType);
|
this.gbWatermarkBackground.Controls.Add(this.lblWatermarkGradientType);
|
||||||
this.gbWatermarkBackground.Location = new System.Drawing.Point(304, 96);
|
this.gbWatermarkBackground.Location = new System.Drawing.Point(304, 94);
|
||||||
this.gbWatermarkBackground.Name = "gbWatermarkBackground";
|
this.gbWatermarkBackground.Name = "gbWatermarkBackground";
|
||||||
this.gbWatermarkBackground.Size = new System.Drawing.Size(448, 176);
|
this.gbWatermarkBackground.Size = new System.Drawing.Size(448, 153);
|
||||||
this.gbWatermarkBackground.TabIndex = 1;
|
this.gbWatermarkBackground.TabIndex = 1;
|
||||||
this.gbWatermarkBackground.TabStop = false;
|
this.gbWatermarkBackground.TabStop = false;
|
||||||
this.gbWatermarkBackground.Text = "Background settings";
|
this.gbWatermarkBackground.Text = "Background settings";
|
||||||
|
@ -208,16 +188,6 @@ private void InitializeComponent()
|
||||||
this.lblRectangleCornerRadius.TabIndex = 0;
|
this.lblRectangleCornerRadius.TabIndex = 0;
|
||||||
this.lblRectangleCornerRadius.Text = "Rectangle corner radius:";
|
this.lblRectangleCornerRadius.Text = "Rectangle corner radius:";
|
||||||
//
|
//
|
||||||
// btnSelectGradient
|
|
||||||
//
|
|
||||||
this.btnSelectGradient.Location = new System.Drawing.Point(144, 141);
|
|
||||||
this.btnSelectGradient.Name = "btnSelectGradient";
|
|
||||||
this.btnSelectGradient.Size = new System.Drawing.Size(112, 23);
|
|
||||||
this.btnSelectGradient.TabIndex = 5;
|
|
||||||
this.btnSelectGradient.Text = "Gradient maker...";
|
|
||||||
this.btnSelectGradient.UseVisualStyleBackColor = true;
|
|
||||||
this.btnSelectGradient.Click += new System.EventHandler(this.btnSelectGradient_Click);
|
|
||||||
//
|
|
||||||
// lblWatermarkBackColors2
|
// lblWatermarkBackColors2
|
||||||
//
|
//
|
||||||
this.lblWatermarkBackColors2.AutoSize = true;
|
this.lblWatermarkBackColors2.AutoSize = true;
|
||||||
|
@ -227,17 +197,6 @@ private void InitializeComponent()
|
||||||
this.lblWatermarkBackColors2.TabIndex = 15;
|
this.lblWatermarkBackColors2.TabIndex = 15;
|
||||||
this.lblWatermarkBackColors2.Text = "Background color 2:";
|
this.lblWatermarkBackColors2.Text = "Background color 2:";
|
||||||
//
|
//
|
||||||
// cboUseCustomGradient
|
|
||||||
//
|
|
||||||
this.cboUseCustomGradient.AutoSize = true;
|
|
||||||
this.cboUseCustomGradient.Location = new System.Drawing.Point(18, 144);
|
|
||||||
this.cboUseCustomGradient.Name = "cboUseCustomGradient";
|
|
||||||
this.cboUseCustomGradient.Size = new System.Drawing.Size(121, 17);
|
|
||||||
this.cboUseCustomGradient.TabIndex = 4;
|
|
||||||
this.cboUseCustomGradient.Text = "Use gradient maker:";
|
|
||||||
this.cboUseCustomGradient.UseVisualStyleBackColor = true;
|
|
||||||
this.cboUseCustomGradient.CheckedChanged += new System.EventHandler(this.cbUseCustomGradient_CheckedChanged);
|
|
||||||
//
|
|
||||||
// nudWatermarkCornerRadius
|
// nudWatermarkCornerRadius
|
||||||
//
|
//
|
||||||
this.nudWatermarkCornerRadius.Location = new System.Drawing.Point(148, 20);
|
this.nudWatermarkCornerRadius.Location = new System.Drawing.Point(148, 20);
|
||||||
|
@ -388,45 +347,6 @@ private void InitializeComponent()
|
||||||
this.pbWatermarkFontColor.TabStop = false;
|
this.pbWatermarkFontColor.TabStop = false;
|
||||||
this.pbWatermarkFontColor.Click += new System.EventHandler(this.pbWatermarkFontColor_Click);
|
this.pbWatermarkFontColor.Click += new System.EventHandler(this.pbWatermarkFontColor_Click);
|
||||||
//
|
//
|
||||||
// lblWatermarkImageScale
|
|
||||||
//
|
|
||||||
this.lblWatermarkImageScale.AutoSize = true;
|
|
||||||
this.lblWatermarkImageScale.Location = new System.Drawing.Point(16, 56);
|
|
||||||
this.lblWatermarkImageScale.Name = "lblWatermarkImageScale";
|
|
||||||
this.lblWatermarkImageScale.Size = new System.Drawing.Size(117, 13);
|
|
||||||
this.lblWatermarkImageScale.TabIndex = 3;
|
|
||||||
this.lblWatermarkImageScale.Text = "Image size percentage:";
|
|
||||||
//
|
|
||||||
// nudWatermarkImageScale
|
|
||||||
//
|
|
||||||
this.nudWatermarkImageScale.Increment = new decimal(new int[] {
|
|
||||||
10,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.nudWatermarkImageScale.Location = new System.Drawing.Point(136, 52);
|
|
||||||
this.nudWatermarkImageScale.Maximum = new decimal(new int[] {
|
|
||||||
2000,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
this.nudWatermarkImageScale.Name = "nudWatermarkImageScale";
|
|
||||||
this.nudWatermarkImageScale.Size = new System.Drawing.Size(56, 20);
|
|
||||||
this.nudWatermarkImageScale.TabIndex = 4;
|
|
||||||
this.nudWatermarkImageScale.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
|
||||||
this.nudWatermarkImageScale.ValueChanged += new System.EventHandler(this.nudWatermarkImageScale_ValueChanged);
|
|
||||||
//
|
|
||||||
// cbWatermarkUseBorder
|
|
||||||
//
|
|
||||||
this.cbWatermarkUseBorder.AutoSize = true;
|
|
||||||
this.cbWatermarkUseBorder.Location = new System.Drawing.Point(18, 80);
|
|
||||||
this.cbWatermarkUseBorder.Name = "cbWatermarkUseBorder";
|
|
||||||
this.cbWatermarkUseBorder.Size = new System.Drawing.Size(78, 17);
|
|
||||||
this.cbWatermarkUseBorder.TabIndex = 2;
|
|
||||||
this.cbWatermarkUseBorder.Text = "Add border";
|
|
||||||
this.cbWatermarkUseBorder.UseVisualStyleBackColor = true;
|
|
||||||
this.cbWatermarkUseBorder.CheckedChanged += new System.EventHandler(this.cbWatermarkUseBorder_CheckedChanged);
|
|
||||||
//
|
|
||||||
// btwWatermarkBrowseImage
|
// btwWatermarkBrowseImage
|
||||||
//
|
//
|
||||||
this.btwWatermarkBrowseImage.Location = new System.Drawing.Point(376, 22);
|
this.btwWatermarkBrowseImage.Location = new System.Drawing.Point(376, 22);
|
||||||
|
@ -451,21 +371,18 @@ private void InitializeComponent()
|
||||||
this.pbPreview.BackColor = System.Drawing.Color.White;
|
this.pbPreview.BackColor = System.Drawing.Color.White;
|
||||||
this.pbPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.pbPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.pbPreview.DrawCheckeredBackground = true;
|
this.pbPreview.DrawCheckeredBackground = true;
|
||||||
this.pbPreview.Location = new System.Drawing.Point(8, 176);
|
this.pbPreview.Location = new System.Drawing.Point(8, 132);
|
||||||
this.pbPreview.Name = "pbPreview";
|
this.pbPreview.Name = "pbPreview";
|
||||||
this.pbPreview.Size = new System.Drawing.Size(288, 216);
|
this.pbPreview.Size = new System.Drawing.Size(288, 176);
|
||||||
this.pbPreview.TabIndex = 2;
|
this.pbPreview.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// gbImageWatermark
|
// gbImageWatermark
|
||||||
//
|
//
|
||||||
this.gbImageWatermark.Controls.Add(this.txtWatermarkImageLocation);
|
this.gbImageWatermark.Controls.Add(this.txtWatermarkImageLocation);
|
||||||
this.gbImageWatermark.Controls.Add(this.lblWatermarkImageScale);
|
|
||||||
this.gbImageWatermark.Controls.Add(this.btwWatermarkBrowseImage);
|
this.gbImageWatermark.Controls.Add(this.btwWatermarkBrowseImage);
|
||||||
this.gbImageWatermark.Controls.Add(this.nudWatermarkImageScale);
|
this.gbImageWatermark.Location = new System.Drawing.Point(304, 253);
|
||||||
this.gbImageWatermark.Controls.Add(this.cbWatermarkUseBorder);
|
|
||||||
this.gbImageWatermark.Location = new System.Drawing.Point(304, 280);
|
|
||||||
this.gbImageWatermark.Name = "gbImageWatermark";
|
this.gbImageWatermark.Name = "gbImageWatermark";
|
||||||
this.gbImageWatermark.Size = new System.Drawing.Size(448, 112);
|
this.gbImageWatermark.Size = new System.Drawing.Size(448, 55);
|
||||||
this.gbImageWatermark.TabIndex = 5;
|
this.gbImageWatermark.TabIndex = 5;
|
||||||
this.gbImageWatermark.TabStop = false;
|
this.gbImageWatermark.TabStop = false;
|
||||||
this.gbImageWatermark.Text = "Image watermark settings";
|
this.gbImageWatermark.Text = "Image watermark settings";
|
||||||
|
@ -475,14 +392,13 @@ private void InitializeComponent()
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.Color.White;
|
this.BackColor = System.Drawing.Color.White;
|
||||||
this.ClientSize = new System.Drawing.Size(761, 401);
|
this.ClientSize = new System.Drawing.Size(761, 316);
|
||||||
this.Controls.Add(this.lblWatermarkOffsetPixel);
|
this.Controls.Add(this.lblWatermarkOffsetPixel);
|
||||||
this.Controls.Add(this.gbImageWatermark);
|
this.Controls.Add(this.gbImageWatermark);
|
||||||
this.Controls.Add(this.cboWatermarkType);
|
this.Controls.Add(this.cboWatermarkType);
|
||||||
this.Controls.Add(this.pbPreview);
|
this.Controls.Add(this.pbPreview);
|
||||||
this.Controls.Add(this.cbWatermarkAutoHide);
|
this.Controls.Add(this.cbWatermarkAutoHide);
|
||||||
this.Controls.Add(this.gbWatermarkBackground);
|
this.Controls.Add(this.gbWatermarkBackground);
|
||||||
this.Controls.Add(this.cbWatermarkAddReflection);
|
|
||||||
this.Controls.Add(this.lblWatermarkType);
|
this.Controls.Add(this.lblWatermarkType);
|
||||||
this.Controls.Add(this.chkWatermarkPosition);
|
this.Controls.Add(this.chkWatermarkPosition);
|
||||||
this.Controls.Add(this.gbWatermarkText);
|
this.Controls.Add(this.gbWatermarkText);
|
||||||
|
@ -490,6 +406,7 @@ private void InitializeComponent()
|
||||||
this.Controls.Add(this.lblWatermarkOffset);
|
this.Controls.Add(this.lblWatermarkOffset);
|
||||||
this.Controls.Add(this.nudWatermarkOffset);
|
this.Controls.Add(this.nudWatermarkOffset);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.MaximizeBox = false;
|
||||||
this.Name = "WatermarkForm";
|
this.Name = "WatermarkForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "ShareX - Watermark settings";
|
this.Text = "ShareX - Watermark settings";
|
||||||
|
@ -505,7 +422,6 @@ private void InitializeComponent()
|
||||||
this.gbWatermarkText.ResumeLayout(false);
|
this.gbWatermarkText.ResumeLayout(false);
|
||||||
this.gbWatermarkText.PerformLayout();
|
this.gbWatermarkText.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkFontColor)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbWatermarkFontColor)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudWatermarkImageScale)).EndInit();
|
|
||||||
this.gbImageWatermark.ResumeLayout(false);
|
this.gbImageWatermark.ResumeLayout(false);
|
||||||
this.gbImageWatermark.PerformLayout();
|
this.gbImageWatermark.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
@ -518,7 +434,6 @@ private void InitializeComponent()
|
||||||
private System.Windows.Forms.Label lblWatermarkOffsetPixel;
|
private System.Windows.Forms.Label lblWatermarkOffsetPixel;
|
||||||
internal System.Windows.Forms.ComboBox cboWatermarkType;
|
internal System.Windows.Forms.ComboBox cboWatermarkType;
|
||||||
internal System.Windows.Forms.CheckBox cbWatermarkAutoHide;
|
internal System.Windows.Forms.CheckBox cbWatermarkAutoHide;
|
||||||
internal System.Windows.Forms.CheckBox cbWatermarkAddReflection;
|
|
||||||
internal System.Windows.Forms.Label lblWatermarkType;
|
internal System.Windows.Forms.Label lblWatermarkType;
|
||||||
internal System.Windows.Forms.ComboBox chkWatermarkPosition;
|
internal System.Windows.Forms.ComboBox chkWatermarkPosition;
|
||||||
internal System.Windows.Forms.Label lblWatermarkPosition;
|
internal System.Windows.Forms.Label lblWatermarkPosition;
|
||||||
|
@ -532,8 +447,6 @@ private void InitializeComponent()
|
||||||
internal System.Windows.Forms.PictureBox pbWatermarkBorderColor;
|
internal System.Windows.Forms.PictureBox pbWatermarkBorderColor;
|
||||||
internal System.Windows.Forms.Label lblWatermarkGradientType;
|
internal System.Windows.Forms.Label lblWatermarkGradientType;
|
||||||
internal System.Windows.Forms.PictureBox pbWatermarkGradient1;
|
internal System.Windows.Forms.PictureBox pbWatermarkGradient1;
|
||||||
private System.Windows.Forms.Button btnSelectGradient;
|
|
||||||
private System.Windows.Forms.CheckBox cboUseCustomGradient;
|
|
||||||
internal System.Windows.Forms.NumericUpDown nudWatermarkCornerRadius;
|
internal System.Windows.Forms.NumericUpDown nudWatermarkCornerRadius;
|
||||||
internal System.Windows.Forms.Label lblWatermarkCornerRadiusTip;
|
internal System.Windows.Forms.Label lblWatermarkCornerRadiusTip;
|
||||||
internal System.Windows.Forms.GroupBox gbWatermarkText;
|
internal System.Windows.Forms.GroupBox gbWatermarkText;
|
||||||
|
@ -542,9 +455,6 @@ private void InitializeComponent()
|
||||||
internal System.Windows.Forms.Button btnWatermarkFont;
|
internal System.Windows.Forms.Button btnWatermarkFont;
|
||||||
internal System.Windows.Forms.TextBox txtWatermarkText;
|
internal System.Windows.Forms.TextBox txtWatermarkText;
|
||||||
internal System.Windows.Forms.PictureBox pbWatermarkFontColor;
|
internal System.Windows.Forms.PictureBox pbWatermarkFontColor;
|
||||||
internal System.Windows.Forms.Label lblWatermarkImageScale;
|
|
||||||
internal System.Windows.Forms.NumericUpDown nudWatermarkImageScale;
|
|
||||||
internal System.Windows.Forms.CheckBox cbWatermarkUseBorder;
|
|
||||||
internal System.Windows.Forms.Button btwWatermarkBrowseImage;
|
internal System.Windows.Forms.Button btwWatermarkBrowseImage;
|
||||||
internal System.Windows.Forms.TextBox txtWatermarkImageLocation;
|
internal System.Windows.Forms.TextBox txtWatermarkImageLocation;
|
||||||
internal System.Windows.Forms.Label lblWatermarkBorderColor;
|
internal System.Windows.Forms.Label lblWatermarkBorderColor;
|
||||||
|
|
|
@ -62,12 +62,11 @@ private void WatermarkUI_Load(object sender, EventArgs e)
|
||||||
cboWatermarkType.SelectedIndex = (int)Config.WatermarkMode;
|
cboWatermarkType.SelectedIndex = (int)Config.WatermarkMode;
|
||||||
if (chkWatermarkPosition.Items.Count == 0)
|
if (chkWatermarkPosition.Items.Count == 0)
|
||||||
{
|
{
|
||||||
chkWatermarkPosition.Items.AddRange(Helpers.GetEnumDescriptions<WatermarkPositionType>());
|
chkWatermarkPosition.Items.AddRange(Helpers.GetEnumDescriptions<PositionType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
chkWatermarkPosition.SelectedIndex = (int)Config.WatermarkPositionMode;
|
chkWatermarkPosition.SelectedIndex = (int)Config.WatermarkPositionMode;
|
||||||
nudWatermarkOffset.Value = Config.WatermarkOffset;
|
nudWatermarkOffset.Value = Config.WatermarkOffset;
|
||||||
cbWatermarkAddReflection.Checked = Config.WatermarkAddReflection;
|
|
||||||
cbWatermarkAutoHide.Checked = Config.WatermarkAutoHide;
|
cbWatermarkAutoHide.Checked = Config.WatermarkAutoHide;
|
||||||
|
|
||||||
txtWatermarkText.Text = Config.WatermarkText;
|
txtWatermarkText.Text = Config.WatermarkText;
|
||||||
|
@ -83,11 +82,8 @@ private void WatermarkUI_Load(object sender, EventArgs e)
|
||||||
}
|
}
|
||||||
|
|
||||||
cbWatermarkGradientType.SelectedIndex = (int)Config.WatermarkGradientType;
|
cbWatermarkGradientType.SelectedIndex = (int)Config.WatermarkGradientType;
|
||||||
cboUseCustomGradient.Checked = Config.WatermarkUseCustomGradient;
|
|
||||||
|
|
||||||
txtWatermarkImageLocation.Text = Config.WatermarkImageLocation;
|
txtWatermarkImageLocation.Text = Config.WatermarkImageLocation;
|
||||||
cbWatermarkUseBorder.Checked = Config.WatermarkUseBorder;
|
|
||||||
nudWatermarkImageScale.Value = Config.WatermarkImageScale;
|
|
||||||
|
|
||||||
IsGuiReady = true;
|
IsGuiReady = true;
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
|
@ -126,33 +122,44 @@ private void UpdatePreview()
|
||||||
{
|
{
|
||||||
using (Bitmap bmp = new Bitmap(pbPreview.ClientSize.Width, pbPreview.ClientSize.Height))
|
using (Bitmap bmp = new Bitmap(pbPreview.ClientSize.Width, pbPreview.ClientSize.Height))
|
||||||
{
|
{
|
||||||
new WatermarkManager(Config).ApplyWatermark(bmp);
|
WatermarkManager.ApplyWatermark(bmp, Config);
|
||||||
pbPreview.LoadImage(bmp);
|
pbPreview.LoadImage(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSelectGradient_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using (GradientMaker gradientForm = new GradientMaker(Config.WatermarkGradient) { Icon = Icon })
|
|
||||||
{
|
|
||||||
if (gradientForm.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
Config.WatermarkGradient = gradientForm.GradientData;
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnWatermarkFont_Click(object sender, EventArgs e)
|
private void btnWatermarkFont_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult result = WatermarkManager.ShowFontDialog(Config);
|
try
|
||||||
|
|
||||||
if (result == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
pbWatermarkFontColor.BackColor = Config.WatermarkFontArgb;
|
using (FontDialog fontDialog = new FontDialog())
|
||||||
lblWatermarkFont.Text = FontToString();
|
{
|
||||||
UpdatePreview();
|
fontDialog.ShowColor = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fontDialog.Color = Config.WatermarkFontArgb;
|
||||||
|
fontDialog.Font = Config.WatermarkFont;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
DebugHelper.WriteException(ex, "Error while initializing font.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fontDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
Config.WatermarkFont = fontDialog.Font;
|
||||||
|
Config.WatermarkFontArgb = fontDialog.Color;
|
||||||
|
|
||||||
|
pbWatermarkFontColor.BackColor = Config.WatermarkFontArgb;
|
||||||
|
lblWatermarkFont.Text = FontToString();
|
||||||
|
UpdatePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
DebugHelper.WriteException(ex, "Error while setting watermark font.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,18 +179,6 @@ private void cboWatermarkType_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cbUseCustomGradient_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Config.WatermarkUseCustomGradient = cboUseCustomGradient.Checked;
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cbWatermarkAddReflection_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Config.WatermarkAddReflection = cbWatermarkAddReflection.Checked;
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cbWatermarkAutoHide_CheckedChanged(object sender, EventArgs e)
|
private void cbWatermarkAutoHide_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Config.WatermarkAutoHide = cbWatermarkAutoHide.Checked;
|
Config.WatermarkAutoHide = cbWatermarkAutoHide.Checked;
|
||||||
|
@ -198,13 +193,7 @@ private void cbWatermarkGradientType_SelectedIndexChanged(object sender, EventAr
|
||||||
|
|
||||||
private void cbWatermarkPosition_SelectedIndexChanged(object sender, EventArgs e)
|
private void cbWatermarkPosition_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Config.WatermarkPositionMode = (WatermarkPositionType)chkWatermarkPosition.SelectedIndex;
|
Config.WatermarkPositionMode = (PositionType)chkWatermarkPosition.SelectedIndex;
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cbWatermarkUseBorder_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Config.WatermarkUseBorder = cbWatermarkUseBorder.Checked;
|
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,12 +203,6 @@ private void nudWatermarkCornerRadius_ValueChanged(object sender, EventArgs e)
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nudWatermarkImageScale_ValueChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Config.WatermarkImageScale = (int)nudWatermarkImageScale.Value;
|
|
||||||
UpdatePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void nudWatermarkOffset_ValueChanged(object sender, EventArgs e)
|
private void nudWatermarkOffset_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Config.WatermarkOffset = (int)nudWatermarkOffset.Value;
|
Config.WatermarkOffset = (int)nudWatermarkOffset.Value;
|
||||||
|
|
|
@ -33,202 +33,44 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
namespace ImageEffectsLib
|
namespace ImageEffectsLib
|
||||||
{
|
{
|
||||||
public class WatermarkManager
|
public static class WatermarkManager
|
||||||
{
|
{
|
||||||
public WatermarkConfig Config { get; private set; }
|
public static Image ApplyWatermark(Image img, WatermarkConfig config)
|
||||||
|
|
||||||
public WatermarkManager(WatermarkConfig config)
|
|
||||||
{
|
{
|
||||||
Config = config;
|
switch (config.WatermarkMode)
|
||||||
}
|
|
||||||
|
|
||||||
public static DialogResult ShowFontDialog(WatermarkConfig config)
|
|
||||||
{
|
|
||||||
DialogResult result = DialogResult.Cancel;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FontDialog fDialog = new FontDialog
|
|
||||||
{
|
|
||||||
ShowColor = true
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fDialog.Color = config.WatermarkFontArgb;
|
|
||||||
fDialog.Font = config.WatermarkFont;
|
|
||||||
}
|
|
||||||
catch (Exception err)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(err, "Error while initializing font.");
|
|
||||||
}
|
|
||||||
|
|
||||||
result = fDialog.ShowDialog();
|
|
||||||
|
|
||||||
if (result == DialogResult.OK)
|
|
||||||
{
|
|
||||||
config.WatermarkFont = fDialog.Font;
|
|
||||||
config.WatermarkFontArgb = fDialog.Color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(ex, "Error while setting Watermark Font");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image ApplyWatermark(Image img)
|
|
||||||
{
|
|
||||||
switch (Config.WatermarkMode)
|
|
||||||
{
|
{
|
||||||
case WatermarkType.TEXT:
|
case WatermarkType.TEXT:
|
||||||
NameParser parser = new NameParser(NameParserType.Text) { Picture = img };
|
DrawText drawText = new DrawText
|
||||||
return DrawWatermarkText(img, parser.Parse(Config.WatermarkText));
|
{
|
||||||
|
Position = (PositionType)config.WatermarkPositionMode,
|
||||||
|
Offset = config.WatermarkOffset,
|
||||||
|
AutoHide = config.WatermarkAutoHide,
|
||||||
|
Text = config.WatermarkText,
|
||||||
|
TextFont = config.WatermarkFont,
|
||||||
|
TextColor = config.WatermarkFontArgb,
|
||||||
|
DrawBackground = true,
|
||||||
|
BackgroundPadding = 5,
|
||||||
|
CornerRadius = config.WatermarkCornerRadius,
|
||||||
|
BorderColor = config.WatermarkBorderArgb,
|
||||||
|
BackgroundColor = config.WatermarkGradient1Argb,
|
||||||
|
UseGradient = true,
|
||||||
|
BackgroundColor2 = config.WatermarkGradient2Argb,
|
||||||
|
UseCustomGradient = false,
|
||||||
|
CustomGradientList = null,
|
||||||
|
GradientType = config.WatermarkGradientType
|
||||||
|
};
|
||||||
|
|
||||||
|
return drawText.Apply(img);
|
||||||
case WatermarkType.IMAGE:
|
case WatermarkType.IMAGE:
|
||||||
return DrawWatermarkImage(img, Config.WatermarkImageLocation);
|
DrawImage drawImage = new DrawImage
|
||||||
}
|
|
||||||
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Image DrawWatermarkImage(Image img, string imgPath)
|
|
||||||
{
|
|
||||||
Image img2 = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (img != null && !string.IsNullOrEmpty(imgPath) && File.Exists(imgPath) && Config.WatermarkImageScale > 0)
|
|
||||||
{
|
|
||||||
img2 = Helpers.GetImageFromFile(imgPath);
|
|
||||||
|
|
||||||
int offset = Config.WatermarkOffset;
|
|
||||||
int width = (int)(Config.WatermarkImageScale / 100f * img2.Width);
|
|
||||||
int height = (int)(Config.WatermarkImageScale / 100f * img2.Height);
|
|
||||||
|
|
||||||
if (Config.WatermarkAutoHide && ((img.Width < width + offset) || (img.Height < height + offset)))
|
|
||||||
{
|
{
|
||||||
return img;
|
Position = (PositionType)config.WatermarkPositionMode,
|
||||||
}
|
Offset = config.WatermarkOffset,
|
||||||
|
AutoHide = config.WatermarkAutoHide,
|
||||||
|
ImageLocation = config.WatermarkImageLocation
|
||||||
|
};
|
||||||
|
|
||||||
if (Config.WatermarkImageScale != 100)
|
return drawImage.Apply(img);
|
||||||
{
|
|
||||||
img2 = ImageHelpers.ResizeImage(img2, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point imgPos = Helpers.GetPosition((PositionType)Config.WatermarkPositionMode, offset, img.Size, img2.Size);
|
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(img))
|
|
||||||
{
|
|
||||||
g.SetHighQuality();
|
|
||||||
g.DrawImage(img2, imgPos.X, imgPos.Y, img2.Width, img2.Height);
|
|
||||||
|
|
||||||
if (Config.WatermarkAddReflection)
|
|
||||||
{
|
|
||||||
using (Bitmap bmp = ImageHelpers.AddReflection(img2, 50, 150, 10))
|
|
||||||
{
|
|
||||||
g.DrawImage(bmp, new Rectangle(imgPos.X, imgPos.Y + img2.Height - 1, bmp.Width, bmp.Height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.WatermarkUseBorder)
|
|
||||||
{
|
|
||||||
g.DrawRectangleProper(Pens.Black, imgPos.X, imgPos.Y, img2.Width, img2.Height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(ex, "Error while drawing image watermark");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (img2 != null) img2.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Image DrawWatermarkText(Image img, string drawText)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(drawText) || Config.WatermarkFont == null || Config.WatermarkFont.Size < 1)
|
|
||||||
{
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
Font font = null;
|
|
||||||
Brush backgroundBrush = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
font = Config.WatermarkFont;
|
|
||||||
Size textSize = TextRenderer.MeasureText(drawText, font);
|
|
||||||
Size labelSize = new Size(textSize.Width + 10, textSize.Height + 10);
|
|
||||||
|
|
||||||
if (Config.WatermarkAutoHide && ((img.Width < labelSize.Width + Config.WatermarkOffset) || (img.Height < labelSize.Height + Config.WatermarkOffset)))
|
|
||||||
{
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle labelRectangle = new Rectangle(Point.Empty, labelSize);
|
|
||||||
Color fontColor = Config.WatermarkFontArgb;
|
|
||||||
|
|
||||||
using (Bitmap bmp = new Bitmap(labelRectangle.Width, labelRectangle.Height))
|
|
||||||
using (Graphics g = Graphics.FromImage(bmp))
|
|
||||||
{
|
|
||||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
|
||||||
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
|
|
||||||
|
|
||||||
if (Config.WatermarkUseCustomGradient)
|
|
||||||
{
|
|
||||||
backgroundBrush = GradientMaker.CreateGradientBrush(labelRectangle.Size, Config.WatermarkGradient);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
backgroundBrush = new LinearGradientBrush(labelRectangle, Config.WatermarkGradient1Argb, Config.WatermarkGradient2Argb, Config.WatermarkGradientType);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (GraphicsPath gPath = new GraphicsPath())
|
|
||||||
using (Pen borderPen = new Pen(Config.WatermarkBorderArgb))
|
|
||||||
{
|
|
||||||
gPath.AddRoundedRectangle(labelRectangle, Config.WatermarkCornerRadius);
|
|
||||||
g.FillPath(backgroundBrush, gPath);
|
|
||||||
g.DrawPath(borderPen, gPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (Brush textBrush = new SolidBrush(fontColor))
|
|
||||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
|
||||||
{
|
|
||||||
g.DrawString(drawText, font, textBrush, bmp.Width / 2f, bmp.Height / 2f, sf);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (Graphics gImg = Graphics.FromImage(img))
|
|
||||||
{
|
|
||||||
gImg.SmoothingMode = SmoothingMode.HighQuality;
|
|
||||||
|
|
||||||
Point labelPosition = Helpers.GetPosition((PositionType)Config.WatermarkPositionMode, Config.WatermarkOffset, img.Size, labelSize);
|
|
||||||
gImg.DrawImage(bmp, labelPosition.X, labelPosition.Y, bmp.Width, bmp.Height);
|
|
||||||
|
|
||||||
if (Config.WatermarkAddReflection)
|
|
||||||
{
|
|
||||||
using (Bitmap bmp2 = ImageHelpers.AddReflection(bmp, 50, 150, 10))
|
|
||||||
{
|
|
||||||
gImg.DrawImage(bmp2, new Rectangle(labelPosition.X, labelPosition.Y + bmp.Height - 1, bmp2.Width, bmp2.Height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(ex, "Error while drawing watermark");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (font != null) font.Dispose();
|
|
||||||
if (backgroundBrush != null) backgroundBrush.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
|
|
|
@ -360,8 +360,7 @@ private void DoAfterCaptureJobs()
|
||||||
|
|
||||||
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddWatermark) && Info.TaskSettings.ImageSettings.WatermarkConfig != null)
|
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddWatermark) && Info.TaskSettings.ImageSettings.WatermarkConfig != null)
|
||||||
{
|
{
|
||||||
WatermarkManager watermarkManager = new WatermarkManager(Info.TaskSettings.ImageSettings.WatermarkConfig);
|
WatermarkManager.ApplyWatermark(tempImage, Info.TaskSettings.ImageSettings.WatermarkConfig);
|
||||||
watermarkManager.ApplyWatermark(tempImage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
|
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
|
||||||
|
|
Loading…
Reference in a new issue