Remember selected sticker pack

This commit is contained in:
Jaex 2018-02-07 15:03:45 +03:00
parent 30c339dc9e
commit 7b6b40d112
5 changed files with 14 additions and 6 deletions

View file

@ -39,14 +39,16 @@ namespace ShareX.ScreenCaptureLib
public partial class StickerForm : Form public partial class StickerForm : Form
{ {
public List<StickerPackInfo> StickerPacks { get; set; } public List<StickerPackInfo> StickerPacks { get; set; }
public string SelectedImageFile { get; set; } public int SelectedStickerPack { get; set; }
public int StickerSize { get; set; } public int StickerSize { get; set; }
public string SelectedImageFile { get; set; }
private string[] imageFiles; private string[] imageFiles;
public StickerForm(List<StickerPackInfo> stickerPacks, int stickerSize = 64) public StickerForm(List<StickerPackInfo> stickerPacks, int selectedStickerPack, int stickerSize = 64)
{ {
StickerPacks = stickerPacks; StickerPacks = stickerPacks;
SelectedStickerPack = selectedStickerPack;
StickerSize = stickerSize; StickerSize = stickerSize;
InitializeComponent(); InitializeComponent();
@ -72,9 +74,9 @@ private void UpdateStickerPacks()
tscbStickers.Items.Add(stickerPackInfo); tscbStickers.Items.Add(stickerPackInfo);
} }
if (tscbStickers.Items.Count > 0) if (tscbStickers.Items.Count > SelectedStickerPack)
{ {
tscbStickers.SelectedIndex = 0; tscbStickers.SelectedIndex = SelectedStickerPack;
} }
} }
@ -156,6 +158,8 @@ private void tstbSearch_KeyUp(object sender, KeyEventArgs e)
private void tscbStickers_SelectedIndexChanged(object sender, EventArgs e) private void tscbStickers_SelectedIndexChanged(object sender, EventArgs e)
{ {
LoadImageFiles(); LoadImageFiles();
SelectedStickerPack = tscbStickers.SelectedIndex;
} }
private void tsbEditStickers_Click(object sender, EventArgs e) private void tsbEditStickers_Click(object sender, EventArgs e)

View file

@ -125,7 +125,7 @@ private void InitializeComponent()
this.Controls.Add(this.lblName); this.Controls.Add(this.lblName);
this.Controls.Add(this.txtFolder); this.Controls.Add(this.txtFolder);
this.Controls.Add(this.lblFolder); this.Controls.Add(this.lblFolder);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.Name = "StickerPackForm"; this.Name = "StickerPackForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

View file

@ -116,6 +116,7 @@ private void txtFolder_TextChanged(object sender, EventArgs e)
if (stickerPackInfo != null) if (stickerPackInfo != null)
{ {
stickerPackInfo.FolderPath = txtFolder.Text; stickerPackInfo.FolderPath = txtFolder.Text;
cbStickers.RefreshItems();
} }
} }
@ -131,6 +132,7 @@ private void txtName_TextChanged(object sender, EventArgs e)
if (stickerPackInfo != null) if (stickerPackInfo != null)
{ {
stickerPackInfo.Name = txtName.Text; stickerPackInfo.Name = txtName.Text;
cbStickers.RefreshItems();
} }
} }
} }

View file

@ -85,6 +85,7 @@ public class AnnotationOptions
// Sticker drawing // Sticker drawing
public List<StickerPackInfo> StickerPacks = new List<StickerPackInfo>() { new StickerPackInfo("Stickers/Blob Emoji") }; public List<StickerPackInfo> StickerPacks = new List<StickerPackInfo>() { new StickerPackInfo("Stickers/Blob Emoji") };
public int SelectedStickerPack = 0;
public int StickerSize { get; set; } = 64; public int StickerSize { get; set; } = 64;
// Blur effect // Blur effect

View file

@ -56,10 +56,11 @@ private void OpenStickerForm(bool creating)
try try
{ {
using (StickerForm stickerForm = new StickerForm(AnnotationOptions.StickerPacks, AnnotationOptions.StickerSize)) using (StickerForm stickerForm = new StickerForm(AnnotationOptions.StickerPacks, AnnotationOptions.SelectedStickerPack, AnnotationOptions.StickerSize))
{ {
if (stickerForm.ShowDialog() == DialogResult.OK) if (stickerForm.ShowDialog() == DialogResult.OK)
{ {
AnnotationOptions.SelectedStickerPack = stickerForm.SelectedStickerPack;
AnnotationOptions.StickerSize = stickerForm.StickerSize; AnnotationOptions.StickerSize = stickerForm.StickerSize;
if (!string.IsNullOrEmpty(stickerForm.SelectedImageFile)) if (!string.IsNullOrEmpty(stickerForm.SelectedImageFile))