Changed: textbox button to respond to left-button only

This commit is contained in:
Ray 2021-09-28 21:19:34 +01:00
parent 2af53adcae
commit 3518084267
7 changed files with 78 additions and 78 deletions

View File

@ -1,15 +1,14 @@
using FizzyLauncher.Models; using BookmarkManager;
using System.Windows.Forms; using bzit.bomg.Models;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using RyzStudio.Windows.Forms;
using bzit.bomg.Models;
using System.Drawing;
using BookmarkManager;
using System.Threading.Tasks;
using System.ComponentModel; using System.ComponentModel;
using System.Net; using System.Drawing;
using System.IO; using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FizzyLauncher namespace FizzyLauncher
{ {
@ -32,10 +31,9 @@ namespace FizzyLauncher
private ToolTip toolTip1; private ToolTip toolTip1;
private System.ComponentModel.IContainer components; private System.ComponentModel.IContainer components;
protected bool isBusy = false;
protected WebParser webParser = null; protected WebParser webParser = null;
protected WebClient webClient = null; protected WebClient webClient = null;
protected bool isBusy = false;
public BookmarkForm(BookmarkItem model, Image icon) : base() public BookmarkForm(BookmarkItem model, Image icon) : base()

View File

@ -1,7 +1,6 @@
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
namespace BookmarkManager namespace BookmarkManager
@ -50,11 +49,8 @@ namespace BookmarkManager
{ {
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return false; return false;
} }
@ -84,11 +80,8 @@ namespace BookmarkManager
{ {
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return false; return false;
} }
@ -119,11 +112,8 @@ namespace BookmarkManager
command.Dispose(); command.Dispose();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return null; return null;
} }
@ -138,16 +128,12 @@ namespace BookmarkManager
{ {
img = Image.FromStream(new MemoryStream(iconBytes)); img = Image.FromStream(new MemoryStream(iconBytes));
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return null; return null;
} }
return img; return img;
//return new Bitmap(img, 16, 16);
} }
public bool HasIcon(string id) public bool HasIcon(string id)
@ -168,11 +154,8 @@ namespace BookmarkManager
command.Dispose(); command.Dispose();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return false; return false;
} }
@ -200,11 +183,8 @@ namespace BookmarkManager
{ {
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return false; return false;
} }
@ -222,11 +202,8 @@ namespace BookmarkManager
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.Dispose(); command.Dispose();
} }
catch (Exception exc) catch (Exception)
{ {
//#if DEBUG
// MessageBox.Show(exc.Message);
//#endif
return false; return false;
} }
@ -235,12 +212,6 @@ namespace BookmarkManager
protected byte[] ImageToBytes(Image image) protected byte[] ImageToBytes(Image image)
{ {
//MemoryStream stream = new MemoryStream();
//image.Save(stream, image.RawFormat);
//stream.Close();
//return stream.ToArray();
ImageConverter imageConverter = new ImageConverter(); ImageConverter imageConverter = new ImageConverter();
return (byte[])imageConverter.ConvertTo(image, typeof(byte[])); return (byte[])imageConverter.ConvertTo(image, typeof(byte[]));
} }

View File

@ -1,7 +1,6 @@
using BookmarkManager; using BookmarkManager;
using bzit.bomg.Models; using bzit.bomg.Models;
using FizzyLauncher.Models; using FizzyLauncher.Models;
using Microsoft.Data.Sqlite;
using Newtonsoft.Json; using Newtonsoft.Json;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using System; using System;
@ -521,7 +520,25 @@ namespace FizzyLauncher
return; return;
} }
//treeView1.AddItem(.AddFolder("New Folder"); if (treeView1.GetNodeType() == BookmarkTreeView.NodeType.Page)
{
return;
}
if (treeView1.SelectedNode == null)
{
return;
}
// add placeholder
TreeNode node = treeView1.AddItem(treeView1.SelectedNode, new BookmarkItem()
{
SiteName = "New Bookmark"
});
node.EnsureVisible();
treeView1.SelectedNode = node;
UpdateBookmarkNode(true);
} }
/// <summary> /// <summary>
@ -551,9 +568,7 @@ namespace FizzyLauncher
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void addPageToolStripMenuItem1_Click(object sender, EventArgs e) private void addPageToolStripMenuItem1_Click(object sender, EventArgs e) => addPageToolStripMenuItem_Click(sender, e);
{
}
/// <summary> /// <summary>
/// Add folder /// Add folder
@ -640,7 +655,16 @@ namespace FizzyLauncher
/// <param name="e"></param> /// <param name="e"></param>
private void editToolStripMenuItem2_Click(object sender, EventArgs e) private void editToolStripMenuItem2_Click(object sender, EventArgs e)
{ {
if (this.IsBusy)
{
return;
}
BookmarkTreeView.NodeType nodeType = treeView1.GetNodeType();
if (nodeType == BookmarkTreeView.NodeType.Page)
{
UpdateBookmarkNode(false);
}
} }
/// <summary> /// <summary>
@ -684,11 +708,7 @@ namespace FizzyLauncher
await OpenBookmark(tn); await OpenBookmark(tn);
break; break;
case Keys.F2: case Keys.F2:
if (nodeType == BookmarkTreeView.NodeType.Page) editToolStripMenuItem2_Click(sender, null);
{
UpdateBookmarkNode(false);
}
break; break;
case Keys.Insert: case Keys.Insert:
if (e.Modifiers != Keys.Shift) if (e.Modifiers != Keys.Shift)
@ -702,15 +722,7 @@ namespace FizzyLauncher
treeView1.SelectedNode = tn.Parent; treeView1.SelectedNode = tn.Parent;
} }
// add placeholder addPageToolStripMenuItem_Click(sender, null);
TreeNode node = treeView1.AddItem(treeView1.SelectedNode, new BookmarkItem()
{
SiteName = "New Bookmark"
});
node.EnsureVisible();
treeView1.SelectedNode = node;
UpdateBookmarkNode(true);
} }
break; break;
@ -1073,7 +1085,7 @@ namespace FizzyLauncher
string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName); string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
if (!string.IsNullOrWhiteSpace(iconID)) if (!string.IsNullOrWhiteSpace(iconID))
{ {
iconDatabase.AddIcon(iconID, icon); iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
} }
treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item); treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);

View File

@ -2,8 +2,8 @@
{ {
using RyzStudio.Drawing; using RyzStudio.Drawing;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
public partial class TButtonTextBox : RyzStudio.Windows.ThemedForms.TUserControl public partial class TButtonTextBox : RyzStudio.Windows.ThemedForms.TUserControl
@ -22,11 +22,19 @@
textBox1.Left = this.Margin.Left; textBox1.Left = this.Margin.Left;
textBox1.PreviewKeyDown += textBox_PreviewKeyDown; textBox1.PreviewKeyDown += textBox_PreviewKeyDown;
imageBox1.Click += imageBox1_Click; imageBox1.MouseClick += imageBox1_MouseClick;
OnResize(null); OnResize(null);
} }
protected virtual void imageBox1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
OnButtonClick?.Invoke(sender, e);
}
}
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
base.OnResize(e); base.OnResize(e);
@ -69,8 +77,6 @@
} }
} }
protected virtual void imageBox1_Click(object sender, EventArgs e) => OnButtonClick?.Invoke(sender, e);
[Category("Action")] [Category("Action")]
[Browsable(true)] [Browsable(true)]
public event EventHandler OnButtonClick; public event EventHandler OnButtonClick;

View File

@ -1,5 +1,4 @@
using System; using System.IO;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using UIResources = BookmarkManager.UIResource; using UIResources = BookmarkManager.UIResource;
@ -16,8 +15,13 @@ namespace RyzStudio.Windows.ThemedForms
public FolderBrowserDialog FolderDialog { get; set; } = null; public FolderBrowserDialog FolderDialog { get; set; } = null;
protected override void imageBox1_Click(object sender, EventArgs e) protected override void imageBox1_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button != MouseButtons.Left)
{
return;
}
if (this.FolderDialog == null) if (this.FolderDialog == null)
{ {
this.FolderDialog = new FolderBrowserDialog(); this.FolderDialog = new FolderBrowserDialog();

View File

@ -1,5 +1,4 @@
using System; using System.Text;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using UIResources = BookmarkManager.UIResource; using UIResources = BookmarkManager.UIResource;
@ -71,8 +70,13 @@ namespace RyzStudio.Windows.ThemedForms
this.Text = this.KeyCodeResults.DisplayText; this.Text = this.KeyCodeResults.DisplayText;
} }
protected override void imageBox1_Click(object sender, EventArgs e) protected override void imageBox1_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button != MouseButtons.Left)
{
return;
}
this.KeyCodeResults.Clear(); this.KeyCodeResults.Clear();
this.Text = this.KeyCodeResults.DisplayText; this.Text = this.KeyCodeResults.DisplayText;

View File

@ -16,8 +16,13 @@ namespace RyzStudio.Windows.ThemedForms
public OpenFileDialog FileDialog { get; set; } = null; public OpenFileDialog FileDialog { get; set; } = null;
protected override void imageBox1_Click(object sender, EventArgs e) protected override void imageBox1_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button != MouseButtons.Left)
{
return;
}
if (this.FileDialog == null) if (this.FileDialog == null)
{ {
this.FileDialog = new OpenFileDialog(); this.FileDialog = new OpenFileDialog();