From 025d0ccbe7213de2c73a0d8d7b1df2c0fe688c3b Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 7 Feb 2018 14:09:28 +0300 Subject: [PATCH] Adding sticker pack form --- ShareX.ScreenCaptureLib/Forms/StickerForm.cs | 10 +- .../Forms/StickerPackForm.Designer.cs | 149 ++++++++++++++++++ .../Forms/StickerPackForm.cs | 118 ++++++++++++++ .../Forms/StickerPackForm.resx | 120 ++++++++++++++ .../Shapes/StickerPackInfo.cs | 2 +- .../ShareX.ScreenCaptureLib.csproj | 9 ++ 6 files changed, 405 insertions(+), 3 deletions(-) create mode 100644 ShareX.ScreenCaptureLib/Forms/StickerPackForm.Designer.cs create mode 100644 ShareX.ScreenCaptureLib/Forms/StickerPackForm.cs create mode 100644 ShareX.ScreenCaptureLib/Forms/StickerPackForm.resx diff --git a/ShareX.ScreenCaptureLib/Forms/StickerForm.cs b/ShareX.ScreenCaptureLib/Forms/StickerForm.cs index 34ea8e34e..b97c9d911 100644 --- a/ShareX.ScreenCaptureLib/Forms/StickerForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/StickerForm.cs @@ -63,7 +63,10 @@ public StickerForm(List stickerPacks, int stickerSize = 64) { tscbStickers.Items.Add(stickerPackInfo); } - tscbStickers.SelectedIndex = 0; + if (tscbStickers.Items.Count > 0) + { + tscbStickers.SelectedIndex = 0; + } tstbSearch.Focus(); } @@ -149,7 +152,10 @@ private void tscbStickers_SelectedIndexChanged(object sender, EventArgs e) private void tsbEditStickers_Click(object sender, EventArgs e) { - + using (StickerPackForm stickerPackForm = new StickerPackForm(StickerPacks)) + { + stickerPackForm.ShowDialog(); + } } private void tsnudSize_ValueChanged(object sender, EventArgs e) diff --git a/ShareX.ScreenCaptureLib/Forms/StickerPackForm.Designer.cs b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.Designer.cs new file mode 100644 index 000000000..b4f388718 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.Designer.cs @@ -0,0 +1,149 @@ +namespace ShareX.ScreenCaptureLib +{ + partial class StickerPackForm + { + /// + /// 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.lblFolder = new System.Windows.Forms.Label(); + this.txtFolder = new System.Windows.Forms.TextBox(); + this.lblName = new System.Windows.Forms.Label(); + this.txtName = new System.Windows.Forms.TextBox(); + this.cbStickers = new System.Windows.Forms.ComboBox(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnRemove = new System.Windows.Forms.Button(); + this.btnFolderBrowse = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // lblFolder + // + this.lblFolder.AutoSize = true; + this.lblFolder.Location = new System.Drawing.Point(8, 64); + this.lblFolder.Name = "lblFolder"; + this.lblFolder.Size = new System.Drawing.Size(39, 13); + this.lblFolder.TabIndex = 0; + this.lblFolder.Text = "Folder:"; + // + // txtFolder + // + this.txtFolder.Location = new System.Drawing.Point(56, 60); + this.txtFolder.Name = "txtFolder"; + this.txtFolder.Size = new System.Drawing.Size(160, 20); + this.txtFolder.TabIndex = 1; + this.txtFolder.TextChanged += new System.EventHandler(this.txtFolder_TextChanged); + // + // lblName + // + this.lblName.AutoSize = true; + this.lblName.Location = new System.Drawing.Point(8, 88); + this.lblName.Name = "lblName"; + this.lblName.Size = new System.Drawing.Size(38, 13); + this.lblName.TabIndex = 2; + this.lblName.Text = "Name:"; + // + // txtName + // + this.txtName.Location = new System.Drawing.Point(56, 84); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(160, 20); + this.txtName.TabIndex = 3; + this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); + // + // cbStickers + // + this.cbStickers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbStickers.FormattingEnabled = true; + this.cbStickers.Location = new System.Drawing.Point(8, 8); + this.cbStickers.Name = "cbStickers"; + this.cbStickers.Size = new System.Drawing.Size(208, 21); + this.cbStickers.TabIndex = 4; + this.cbStickers.SelectedIndexChanged += new System.EventHandler(this.cbStickers_SelectedIndexChanged); + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(8, 32); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(104, 23); + this.btnAdd.TabIndex = 5; + this.btnAdd.Text = "Add"; + this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnRemove + // + this.btnRemove.Location = new System.Drawing.Point(112, 32); + this.btnRemove.Name = "btnRemove"; + this.btnRemove.Size = new System.Drawing.Size(104, 23); + this.btnRemove.TabIndex = 6; + this.btnRemove.Text = "Remove"; + this.btnRemove.UseVisualStyleBackColor = true; + this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click); + // + // btnFolderBrowse + // + this.btnFolderBrowse.Location = new System.Drawing.Point(218, 59); + this.btnFolderBrowse.Name = "btnFolderBrowse"; + this.btnFolderBrowse.Size = new System.Drawing.Size(24, 23); + this.btnFolderBrowse.TabIndex = 7; + this.btnFolderBrowse.Text = "..."; + this.btnFolderBrowse.UseVisualStyleBackColor = true; + this.btnFolderBrowse.Click += new System.EventHandler(this.btnFolderBrowse_Click); + // + // StickerPackForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(248, 113); + this.Controls.Add(this.btnFolderBrowse); + this.Controls.Add(this.btnRemove); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.cbStickers); + this.Controls.Add(this.txtName); + this.Controls.Add(this.lblName); + this.Controls.Add(this.txtFolder); + this.Controls.Add(this.lblFolder); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.Name = "StickerPackForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ShareX - Sticker packs"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblFolder; + private System.Windows.Forms.TextBox txtFolder; + private System.Windows.Forms.Label lblName; + private System.Windows.Forms.TextBox txtName; + private System.Windows.Forms.ComboBox cbStickers; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnRemove; + private System.Windows.Forms.Button btnFolderBrowse; + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerPackForm.cs b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.cs new file mode 100644 index 000000000..25064fb8f --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.cs @@ -0,0 +1,118 @@ +#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.Linq; +using System.Text; +using System.Windows.Forms; + +namespace ShareX.ScreenCaptureLib +{ + public partial class StickerPackForm : Form + { + public List Stickers { get; private set; } + + public StickerPackForm(List stickers) + { + Stickers = stickers; + + InitializeComponent(); + Icon = ShareXResources.Icon; + + foreach (StickerPackInfo stickerPackInfo in Stickers) + { + cbStickers.Items.Add(stickerPackInfo); + } + + if (cbStickers.Items.Count > 0) + { + cbStickers.SelectedIndex = 0; + } + } + + private StickerPackInfo GetCurrentStickerPack() + { + if (cbStickers.SelectedIndex > -1) + { + return cbStickers.SelectedItem as StickerPackInfo; + } + + return null; + } + + private void cbStickers_SelectedIndexChanged(object sender, EventArgs e) + { + StickerPackInfo stickerPackInfo = GetCurrentStickerPack(); + + if (stickerPackInfo != null) + { + txtFolder.Text = stickerPackInfo.FolderPath; + txtName.Text = stickerPackInfo.Name; + } + } + + private void btnAdd_Click(object sender, EventArgs e) + { + Stickers.Add(new StickerPackInfo()); + cbStickers.Items.Add(Stickers[Stickers.Count - 1]); + cbStickers.SelectedIndex = cbStickers.Items.Count - 1; + } + + private void btnRemove_Click(object sender, EventArgs e) + { + + } + + private void txtFolder_TextChanged(object sender, EventArgs e) + { + StickerPackInfo stickerPackInfo = GetCurrentStickerPack(); + + if (stickerPackInfo != null) + { + stickerPackInfo.FolderPath = txtFolder.Text; + } + } + + private void btnFolderBrowse_Click(object sender, EventArgs e) + { + + } + + private void txtName_TextChanged(object sender, EventArgs e) + { + StickerPackInfo stickerPackInfo = GetCurrentStickerPack(); + + if (stickerPackInfo != null) + { + stickerPackInfo.Name = txtName.Text; + } + } + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/StickerPackForm.resx b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Forms/StickerPackForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/StickerPackInfo.cs b/ShareX.ScreenCaptureLib/Shapes/StickerPackInfo.cs index bb3602226..69a88aee4 100644 --- a/ShareX.ScreenCaptureLib/Shapes/StickerPackInfo.cs +++ b/ShareX.ScreenCaptureLib/Shapes/StickerPackInfo.cs @@ -35,7 +35,7 @@ public class StickerPackInfo public string FolderPath { get; set; } public string Name { get; set; } - public StickerPackInfo(string folderPath, string name) + public StickerPackInfo(string folderPath = "", string name = "") { FolderPath = folderPath; Name = name; diff --git a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj index 95494b004..050711a85 100644 --- a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj +++ b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj @@ -116,6 +116,12 @@ StickerForm.cs + + Form + + + StickerPackForm.cs + @@ -384,6 +390,9 @@ StickerForm.cs + + StickerPackForm.cs + TextDrawingInputBox.cs