diff --git a/ShareX.HelpersLib/Properties/Resources.Designer.cs b/ShareX.HelpersLib/Properties/Resources.Designer.cs index c918d40e4..0b5f5c35a 100644 --- a/ShareX.HelpersLib/Properties/Resources.Designer.cs +++ b/ShareX.HelpersLib/Properties/Resources.Designer.cs @@ -2645,7 +2645,7 @@ internal class Resources { } /// - /// Looks up a localized string similar to Random line from a file. Use {path} to determine the file. + /// Looks up a localized string similar to Random line from a file. Use {filepath} to determine the file. /// internal static string ReplCodeMenuEntry_rf_Random_line_from_file { get { diff --git a/ShareX.HelpersLib/Properties/Resources.resx b/ShareX.HelpersLib/Properties/Resources.resx index 8e6d80ae4..2c6464f34 100644 --- a/ShareX.HelpersLib/Properties/Resources.resx +++ b/ShareX.HelpersLib/Properties/Resources.resx @@ -1146,6 +1146,6 @@ Would you like to download it? ..\Resources\animals.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - Random line from a file. Use {path} to determine the file + Random line from a file. Use {filepath} to determine the file \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerForm.Designer.cs b/ShareX.ScreenCaptureLib/Forms/StickerForm.Designer.cs new file mode 100644 index 000000000..23e236158 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerForm.Designer.cs @@ -0,0 +1,170 @@ +namespace ShareX.ScreenCaptureLib +{ + partial class StickerForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.ilvStickers = new Manina.Windows.Forms.ImageListView(); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.toolStrip2 = new System.Windows.Forms.ToolStrip(); + this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox(); + this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripTextBox3 = new System.Windows.Forms.ToolStripTextBox(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); + this.toolStrip2.SuspendLayout(); + this.SuspendLayout(); + // + // ilvStickers + // + this.ilvStickers.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.ilvStickers.ColumnHeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.ilvStickers.Dock = System.Windows.Forms.DockStyle.Fill; + this.ilvStickers.GroupHeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold); + this.ilvStickers.Location = new System.Drawing.Point(0, 0); + this.ilvStickers.Name = "ilvStickers"; + this.ilvStickers.PersistentCacheDirectory = ""; + this.ilvStickers.PersistentCacheSize = ((long)(100)); + this.ilvStickers.Size = new System.Drawing.Size(784, 484); + this.ilvStickers.TabIndex = 0; + // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.ilvStickers); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(784, 484); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(784, 511); + this.toolStripContainer1.TabIndex = 2; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip2); + // + // toolStrip2 + // + this.toolStrip2.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripLabel1, + this.toolStripTextBox1, + this.toolStripLabel2, + this.toolStripComboBox1, + this.toolStripLabel3, + this.toolStripTextBox3}); + this.toolStrip2.Location = new System.Drawing.Point(0, 0); + this.toolStrip2.Name = "toolStrip2"; + this.toolStrip2.Padding = new System.Windows.Forms.Padding(2); + this.toolStrip2.Size = new System.Drawing.Size(784, 27); + this.toolStrip2.Stretch = true; + this.toolStrip2.TabIndex = 0; + // + // toolStripLabel1 + // + this.toolStripLabel1.Name = "toolStripLabel1"; + this.toolStripLabel1.Size = new System.Drawing.Size(45, 20); + this.toolStripLabel1.Text = "Search:"; + // + // toolStripTextBox1 + // + this.toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.toolStripTextBox1.Name = "toolStripTextBox1"; + this.toolStripTextBox1.Size = new System.Drawing.Size(100, 23); + // + // toolStripLabel2 + // + this.toolStripLabel2.Margin = new System.Windows.Forms.Padding(2, 1, 0, 2); + this.toolStripLabel2.Name = "toolStripLabel2"; + this.toolStripLabel2.Size = new System.Drawing.Size(50, 20); + this.toolStripLabel2.Text = "Stickers:"; + // + // toolStripComboBox1 + // + this.toolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.toolStripComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.toolStripComboBox1.Items.AddRange(new object[] { + "Blob Emoji"}); + this.toolStripComboBox1.Name = "toolStripComboBox1"; + this.toolStripComboBox1.Size = new System.Drawing.Size(121, 23); + // + // toolStripLabel3 + // + this.toolStripLabel3.Margin = new System.Windows.Forms.Padding(2, 1, 0, 2); + this.toolStripLabel3.Name = "toolStripLabel3"; + this.toolStripLabel3.Size = new System.Drawing.Size(30, 20); + this.toolStripLabel3.Text = "Size:"; + // + // toolStripTextBox3 + // + this.toolStripTextBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.toolStripTextBox3.Name = "toolStripTextBox3"; + this.toolStripTextBox3.Size = new System.Drawing.Size(30, 23); + this.toolStripTextBox3.Text = "64"; + this.toolStripTextBox3.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // StickerForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(784, 511); + this.Controls.Add(this.toolStripContainer1); + this.Name = "StickerForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ShareX - Sticker picker"; + this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); + this.toolStrip2.ResumeLayout(false); + this.toolStrip2.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Manina.Windows.Forms.ImageListView ilvStickers; + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + private System.Windows.Forms.ToolStrip toolStrip2; + private System.Windows.Forms.ToolStripLabel toolStripLabel1; + private System.Windows.Forms.ToolStripTextBox toolStripTextBox1; + private System.Windows.Forms.ToolStripLabel toolStripLabel2; + private System.Windows.Forms.ToolStripLabel toolStripLabel3; + private System.Windows.Forms.ToolStripTextBox toolStripTextBox3; + private System.Windows.Forms.ToolStripComboBox toolStripComboBox1; + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerForm.cs b/ShareX.ScreenCaptureLib/Forms/StickerForm.cs new file mode 100644 index 000000000..f0efabf79 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerForm.cs @@ -0,0 +1,56 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2018 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 . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ShareX.ScreenCaptureLib +{ + public partial class StickerForm : Form + { + public StickerForm() + { + InitializeComponent(); + Icon = ShareXResources.Icon; + toolStrip2.Renderer = new CustomToolStripProfessionalRenderer(); + ilvStickers.SetRenderer(new StickerImageListViewRenderer()); + ilvStickers.ThumbnailSize = new Size(64, 64); + ilvStickers.Colors.SelectedColor1 = Color.Transparent; + ilvStickers.Colors.SelectedColor2 = Color.FromArgb(252, 221, 132); + ilvStickers.Colors.HoverColor1 = Color.Transparent; + ilvStickers.Colors.HoverColor2 = Color.FromArgb(252, 221, 132); + ilvStickers.Items.AddRange(Directory.GetFiles("blobs", "*.png")); + toolStripComboBox1.SelectedIndex = 0; + } + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerForm.resx b/ShareX.ScreenCaptureLib/Forms/StickerForm.resx new file mode 100644 index 000000000..c30babd2e --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 59 + + \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerImageListViewRenderer.cs b/ShareX.ScreenCaptureLib/Forms/StickerImageListViewRenderer.cs new file mode 100644 index 000000000..b16199734 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerImageListViewRenderer.cs @@ -0,0 +1,150 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2018 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 . +*/ + +#endregion License Information (GPL v3) + +using Manina.Windows.Forms; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Windows.Forms; +using ShareX.HelpersLib; +using static Manina.Windows.Forms.ImageListView; + +namespace ShareX.ScreenCaptureLib +{ + public class StickerImageListViewRenderer : ImageListViewRenderer + { + public override void InitializeGraphics(Graphics g) + { + base.InitializeGraphics(g); + + ItemDrawOrder = ItemDrawOrder.NormalSelectedHovered; + } + + public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds) + { + Clip = false; + + Size itemPadding = new Size(4, 4); + Rectangle imageBounds = bounds; + + string text = Path.GetFileNameWithoutExtension(item.Text); + Size szt = TextRenderer.MeasureText(text, ImageListView.Font); + int textWidth = szt.Width + itemPadding.Width * 2; + + if ((state & ItemState.Hovered) != ItemState.None && textWidth > bounds.Width) + { + bounds = new Rectangle(bounds.X + bounds.Width / 2 - textWidth / 2, bounds.Y, textWidth, bounds.Height); + } + + // Paint background + if (ImageListView.Enabled) + { + using (Brush bItemBack = new SolidBrush(ImageListView.Colors.BackColor)) + { + g.FillRectangle(bItemBack, bounds); + } + } + else + { + using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor)) + { + g.FillRectangle(bItemBack, bounds); + } + } + + if ((state & ItemState.Disabled) != ItemState.None) // Paint background Disabled + { + using (Brush bDisabled = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.DisabledColor1, ImageListView.Colors.DisabledColor2, LinearGradientMode.Vertical)) + { + Utility.FillRoundedRectangle(g, bDisabled, bounds, 4); + } + } + else if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) || + (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None))) // Paint background Selected + { + using (Brush bSelected = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical)) + { + Utility.FillRoundedRectangle(g, bSelected, bounds, 4); + } + } + else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) // Paint background unfocused + { + using (Brush bGray64 = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.UnFocusedColor1, ImageListView.Colors.UnFocusedColor2, LinearGradientMode.Vertical)) + { + Utility.FillRoundedRectangle(g, bGray64, bounds, 4); + } + } + + // Paint background Hovered + if ((state & ItemState.Hovered) != ItemState.None) + { + using (Brush bHovered = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.HoverColor1, ImageListView.Colors.HoverColor2, LinearGradientMode.Vertical)) + { + Utility.FillRoundedRectangle(g, bHovered, bounds, 4); + } + } + + // Draw the image + Image img = item.GetCachedImage(CachedImageType.Thumbnail); + if (img != null) + { + Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(imageBounds.Location + itemPadding, ImageListView.ThumbnailSize)); + g.DrawImage(img, pos); + } + + // Draw item text + Color foreColor = ImageListView.Colors.ForeColor; + if ((state & ItemState.Disabled) != ItemState.None) + { + foreColor = ImageListView.Colors.DisabledForeColor; + } + else if ((state & ItemState.Selected) != ItemState.None) + { + if (ImageListView.Focused) + { + foreColor = ImageListView.Colors.SelectedForeColor; + } + else + { + foreColor = ImageListView.Colors.UnFocusedForeColor; + } + } + + Rectangle rt = new Rectangle(bounds.Left, bounds.Top + 2 * itemPadding.Height + ImageListView.ThumbnailSize.Height, bounds.Width, szt.Height); + TextFormatFlags flags; + + if ((state & ItemState.Hovered) != ItemState.None) + { + flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.NoClipping; + } + else + { + flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis; + } + + TextRenderer.DrawText(g, text, ImageListView.Font, rt, foreColor, flags); + } + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs index 9f542b777..5968a4fe4 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs @@ -565,7 +565,7 @@ internal void CreateToolbar() }; tsddbShapeOptions.DropDownItems.Add(tsmiShadow); - tsmiShadowColor = new ToolStripMenuItem("Shadow color..."); + tsmiShadowColor = new ToolStripMenuItem("Drop shadow color..."); tsmiShadowColor.Click += (sender, e) => { Form.Pause(); @@ -1006,6 +1006,13 @@ private void MenuForm_Shown(object sender, EventArgs e) { Form.ToolbarHeight = menuForm.Height; Form.CenterCanvas(); + + if (Form.IsEditorMode) + { + Form.Pause(); + StickerForm stickerForm = new StickerForm(); + stickerForm.Show(); + } } private void MenuForm_KeyDown(object sender, KeyEventArgs e) diff --git a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj index 0b2ec4450..3f687e723 100644 --- a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj +++ b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj @@ -68,6 +68,9 @@ MinimumRecommendedRules.ruleset + + ..\packages\ImageListView.11.0.4.0\lib\net35\ImageListView.dll + @@ -106,6 +109,13 @@ ImageSizeForm.cs + + Form + + + StickerForm.cs + + @@ -223,6 +233,7 @@ + @@ -367,6 +378,9 @@ ScrollingCaptureForm.cs + + StickerForm.cs + TextDrawingInputBox.cs diff --git a/ShareX.ScreenCaptureLib/packages.config b/ShareX.ScreenCaptureLib/packages.config new file mode 100644 index 000000000..2a089e8c5 --- /dev/null +++ b/ShareX.ScreenCaptureLib/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ShareX.sln b/ShareX.sln index 590436ec2..95834cf0a 100644 --- a/ShareX.sln +++ b/ShareX.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX", "ShareX\ShareX.csproj", "{C5AE4585-E9EC-4FA3-B75A-E1210635ACB6}" ProjectSection(ProjectDependencies) = postProject