This commit is contained in:
Ray 2019-04-21 18:53:56 +01:00
parent 988857d91c
commit ad535144bd
16 changed files with 622 additions and 339 deletions

View File

@ -137,7 +137,9 @@ namespace bzit.bomg
this.textBox2.Name = "textBox2";
this.textBox2.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox2.Size = new System.Drawing.Size(259, 32);
this.textBox2.SubmitButton = this.button1;
this.textBox2.TabIndex = 0;
this.textBox2.UseSystemPasswordChar = false;
//
// textBox1
//
@ -149,7 +151,9 @@ namespace bzit.bomg
this.textBox1.Name = "textBox1";
this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox1.Size = new System.Drawing.Size(259, 32);
this.textBox1.SubmitButton = this.button2;
this.textBox1.TabIndex = 2;
this.textBox1.UseSystemPasswordChar = false;
//
// horizontalSeparator1
//

26
MainForm.Designer.cs generated
View File

@ -91,6 +91,7 @@ namespace bzit.bomg
this.openMenuBarItem = new System.Windows.Forms.ToolStripButton();
this.saveMenuBarItem = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.rootTreeNodeMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem17 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem18 = new System.Windows.Forms.ToolStripMenuItem();
@ -98,7 +99,6 @@ namespace bzit.bomg
this.toolStripMenuItem20 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem22 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView();
this.pageTreeNodeMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
@ -451,8 +451,8 @@ namespace bzit.bomg
//
// openFileDialog
//
this.openFileDialog.DefaultExt = "ryz";
this.openFileDialog.Filter = "Bookmarks files|*.ryz";
this.openFileDialog.DefaultExt = "jsnx";
this.openFileDialog.Filter = "Bookmarks files (*.jsnx)|*.jsnx|Bookmarks files (*.ryz)|*.ryz";
this.openFileDialog.Title = "Open bookmarks file";
//
// folderTreeNodeMenu
@ -604,6 +604,16 @@ namespace bzit.bomg
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(6, 25);
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "toolStripButton1";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// rootTreeNodeMenu
//
this.rootTreeNodeMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -654,16 +664,6 @@ namespace bzit.bomg
this.toolStripMenuItem22.Text = "&Sort";
this.toolStripMenuItem22.Click += new System.EventHandler(this.sortContextMenu_Click);
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "toolStripButton1";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// treeView1
//
this.treeView1.AllowDrop = true;

View File

@ -5,8 +5,12 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using static RyzStudio.Windows.Forms.BookmarkTreeView;
using TextBoxForm = RyzStudio.Windows.ThemedForms.TextBoxForm;
namespace bzit.bomg
{
@ -22,8 +26,6 @@ namespace bzit.bomg
protected AppMode appMode = AppMode.Clear;
protected string sessionFilename = null;
//protected SessionFileFormat sessionFileFormat = null;
public MainForm()
{
InitializeComponent();
@ -218,6 +220,7 @@ namespace bzit.bomg
set
{
appMode = value;
switch (value)
{
case AppMode.Clear:
@ -271,8 +274,24 @@ namespace bzit.bomg
/// <param name="e"></param>
private void newMenuItem_Click(object sender, EventArgs e)
{
NewSessionForm newSessionForm = new NewSessionForm(this);
newSessionForm.ShowDialog();
TextBoxForm newSessionForm = new TextBoxForm("New Session", "Name");
string rv = newSessionForm.ShowDialog();
if (string.IsNullOrWhiteSpace(rv))
{
return;
}
if (this.ApplicationMode == AppMode.Clear)
{
}
else
{
}
//treeView1.HasChanged.ToString()
}
/// <summary>
@ -284,9 +303,9 @@ namespace bzit.bomg
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
sessionFilename = openFileDialog.FileName;
//##sessionFilename = openFileDialog.FileName;
OpenBookmarkFile(sessionFilename);
loadBookmarkFile(openFileDialog.FileName, openFileDialog.FilterIndex);
}
}
@ -486,33 +505,9 @@ namespace bzit.bomg
#endregion
protected void OpenBookmarkFile(string filename)
{
//treeView1.HasChanged = false;
//if (RyzStudio.IO.SharpZipLib.IsZipEncrypted(filename))
//{
// PasswordForm oPassword = new PasswordForm(this);
// sessionFileFormat.passkey = oPassword.ShowDialog();
// if (sessionFileFormat.passkey.Equals(""))
// {
// return;
// }
//}
//else
//{
// sessionFileFormat.passkey = "";
//}
//bool rv = sessionFileFormat.loadFromRyz(filename);
//if (rv)
//{
// this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Properties.Resources.app_name;
// this.ApplicationMode = AppMode.Open;
// treeView1.HasChanged = false;
//}
}
protected bool SaveBookmarkFile()
{
@ -553,8 +548,250 @@ namespace bzit.bomg
return rv;
}
protected void loadBookmarkFile(string filename, int filterIndex)
{
switch (filterIndex)
{
case 1:
if (RyzStudio.IO.SharpZipLib.IsZipEncrypted(filename))
{
PasswordForm passwordForm = new PasswordForm(this);
string password = string.Empty;
protected void saveBookmarkFile(string filename)
while (true)
{
password = passwordForm.ShowDialog();
if (string.IsNullOrWhiteSpace(password))
{
break;
}
if (RyzStudio.IO.SharpZipLib.TestZipEncrypted(filename, password))
{
loadBookmarkFile_ForJSNX(filename, password);
break;
}
}
}
else
{
loadBookmarkFile_ForJSNX(filename);
}
break;
case 2:
if (RyzStudio.IO.SharpZipLib.IsZipEncrypted(filename))
{
PasswordForm passwordForm = new PasswordForm(this);
string password = string.Empty;
while (true)
{
password = passwordForm.ShowDialog();
if (string.IsNullOrWhiteSpace(password))
{
break;
}
if (RyzStudio.IO.SharpZipLib.TestZipEncrypted(filename, password))
{
loadBookmarkFile_ForRYZ(filename, password);
break;
}
}
}
else
{
loadBookmarkFile_ForRYZ(filename);
}
break;
default:
break;
}
}
protected void loadBookmarkFile_ForJSNX(string filename, string password = "")
{
int size = 2048;
byte[] buffer = new byte[size];
int bufferSize = 0;
List<BookmarkItemViewModel> rs = null;
ZipEntry readEntry = null;
ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
readStream.Password = password;
while (true)
{
readEntry = readStream.GetNextEntry();
if (readEntry == null)
{
break;
}
if (string.IsNullOrWhiteSpace(readEntry.Name))
{
continue;
}
if (!readEntry.IsFile)
{
continue;
}
if (!readEntry.Name.Equals("bookmarks.json"))
{
continue;
}
MemoryStream ms = new MemoryStream();
buffer = new byte[size];
bufferSize = 0;
do
{
bufferSize = readStream.Read(buffer, 0, buffer.Length);
ms.Write(buffer, 0, bufferSize);
}
while (bufferSize > 0);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
rs = JsonConvert.DeserializeObject<List<BookmarkItemViewModel>>(sr.ReadToEnd());
break;
}
treeView1.AddItem(rs);
}
protected void loadBookmarkFile_ForRYZ(string filename, string password = "")
{
int size = 2048;
byte[] buffer = new byte[size];
int bufferSize = 0;
List<BookmarkItemViewModel> rs = new List<BookmarkItemViewModel>();
ZipEntry readEntry = null;
ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
readStream.Password = password;
while (true)
{
readEntry = readStream.GetNextEntry();
if (readEntry == null)
{
break;
}
if (string.IsNullOrWhiteSpace(readEntry.Name))
{
continue;
}
if (!readEntry.IsFile)
{
continue;
}
if (!readEntry.Name.Equals("bookmarks.xml"))
{
continue;
}
MemoryStream ms = new MemoryStream();
buffer = new byte[size];
bufferSize = 0;
do
{
bufferSize = readStream.Read(buffer, 0, buffer.Length);
ms.Write(buffer, 0, bufferSize);
}
while (bufferSize > 0);
ms.Position = 0;
// read stream
StreamReader sr = new StreamReader(ms);
// load xml
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(sr.ReadToEnd());
// parse
XmlNode xnl = xmlDocument.SelectSingleNode("bomg/b/g");
if (xnl == null)
{
break;
}
string rootName = (xnl.Attributes["name"] == null) ? "Bookmarks" : (string.IsNullOrWhiteSpace(xnl.Attributes["name"].InnerText) ? "Bookmarks" : xnl.Attributes["name"].InnerText.Trim());
foreach (XmlNode xn in xnl.ChildNodes)
{
BookmarkItemViewModel viewModel = new BookmarkItemViewModel();
foreach (XmlNode xn2 in xn.ChildNodes)
{
switch (xn2.LocalName)
{
case "name":
viewModel.SiteName = xn2.InnerText?.Trim();
break;
case "address":
viewModel.SiteAddress = xn2.InnerText?.Trim();
break;
case "description":
viewModel.SiteDescription = xn2.InnerText?.Trim();
break;
//case "created":
// bi.Created = xn2.InnerText?.Trim();
// break;
default:
break;
}
}
// fix fullpath and name
if (viewModel.SiteName.Contains("|"))
{
StringBuilder sb = new StringBuilder();
sb.Append("\\");
sb.Append(System.Web.HttpUtility.UrlEncode(rootName));
sb.Append("\\");
string[] pathParts = viewModel.SiteName.Split('|');
for (int i = 0; i < (pathParts.Length - 1); i++)
{
sb.Append(pathParts[i]);
//sb.Append(System.Web.HttpUtility.UrlDecode(pathParts[i]));
sb.Append("\\");
}
viewModel.SiteName = System.Web.HttpUtility.UrlDecode(pathParts[(pathParts.Length - 1)] ?? string.Empty);
viewModel.TreeviewPath = sb.ToString();
}
else
{
viewModel.SiteName = System.Web.HttpUtility.UrlDecode(viewModel.SiteName);
viewModel.TreeviewPath = string.Format("\\{0}\\", System.Web.HttpUtility.UrlEncode(rootName));
}
rs.Add(viewModel);
}
break;
}
treeView1.AddItem(rs);
}
protected void saveBookmarkFile(string filename, string password = "")
{
List<BookmarkItemViewModel> rs = treeView1.GetBookmarkList();
@ -564,12 +801,13 @@ namespace bzit.bomg
ZipOutputStream zipStream = new ZipOutputStream(File.Create(filename));
zipStream.SetLevel(9);
zipStream.Password = password;
// make readable
// stream
MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(rs)));
ms.Position = 0;
// write new document xml
// write file entry
zipStream.PutNextEntry(new ZipEntry("bookmarks.json"));
buffer = new byte[size];
@ -815,9 +1053,10 @@ namespace bzit.bomg
{
List<BookmarkItemViewModel> rs = treeView1.GetBookmarkList();
string filename = @"N:\test.jsnx";
//string filename = @"N:\test.jsnx";
saveBookmarkFile(filename);
//saveBookmarkFile(filename, string.Empty);
//loadBookmarkFile(filename, string.Empty);
}
}

View File

@ -157,14 +157,14 @@
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHZSURBVDhPjZM7SxxRGIY1qfwPClaCICFkZUsRxELQQkmK
EAjEQsHOCxYpFSttZFmWNJJOsAik2yKwBAkJiu6i4g0iYrGbvbmzO5dzzszE1+87OOOOay4fPEyx5332
EAjEQsHOCxYpFSttZFmWNJJOsAik2C6wBAkJiu6i4g0iYrGbvbmzO5dzzszE1+87OOOOay4fPEyx5332
PWfmtDVNJxEj4v+gm3hCtEzMcRwjk8n89n0fjyGlRCKRWKe1j0riHLYsC7Zth9TrddRqNRSLRS0pFApI
JpMtknYizguEEFBK6SdjmiYMw0CpVNICagn+k1QqFUj0aIFXz0Fe72pBIOFAo9FAuVyObIfhjE7TaIE4
m4M4ng4XeJ6n9x1spVKp6Cb5fP5ecHM122Eevhnc/zS0IU+mIA9eQ16swq1+g+9aEQk34fOoVqv3Ank6
+UGdzkCez8O9XIX6uQSxPw5r+wXE4WKkCW+Hz4RFoQB49dQ5mPgszxdIsEaCZTi5l3Cy7+B7Si9kXNfV
58ISJhTwXO+NPRO5UaiLZaiz97C+9sE1jsIwwy2Cw+U2EYG1MzwismOwvz+Hud1L9WNQv77oUAA3YDjc
Kvgx8Da72fPRlxV4hDhZgbzaagk3ExHQhB/SQ5pbNMO/cUanabQgnU7fPBT8Cf7sOaPTd9NPr8f+22UK
uLszJmX49obTRfQTbP0fKNzWdQu5+pvuDaXQ3AAAAABJRU5ErkJggg==
uLszJmX49obTRfQTbP0fKNzWdQuznZvllfjFsQAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

View File

@ -1,51 +0,0 @@
using System;
using System.Windows.Forms;
namespace bzit.bomg
{
public partial class NewSessionForm : Form
{
private MainForm parentForm = null;
public NewSessionForm(MainForm form)
{
InitializeComponent();
parentForm = form;
}
private void button2_Click(object sender, EventArgs e)
{
if (parentForm == null)
{
return;
}
if (string.IsNullOrEmpty(textBox2.Text))
{
return;
}
parentForm.treeView1.Clear();
parentForm.treeView1.Nodes.Add("", textBox2.Text.Trim(), 0, 0);
parentForm.ApplicationMode = MainForm.AppMode.New;
this.Close();
}
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
button2_Click(sender, null);
break;
case Keys.Escape:
this.Close();
break;
default: break;
}
}
}
}

View File

@ -28,62 +28,77 @@ namespace bzit.bomg
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PasswordForm));
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.btnSave = new RyzStudio.Windows.Forms.BigButton();
this.button2 = new RyzStudio.Windows.ThemedForms.Button();
this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
// button2
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 12);
this.label1.Margin = new System.Windows.Forms.Padding(3);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(91, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Enter a password";
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.BackColor = System.Drawing.Color.Transparent;
this.button2.DefaultImage = null;
this.button2.DownImage = null;
this.button2.LabelText = "&OK";
this.button2.Location = new System.Drawing.Point(264, 77);
this.button2.Name = "button2";
this.button2.OverImage = null;
this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button2.Size = new System.Drawing.Size(108, 32);
this.button2.TabIndex = 1;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// horizontalSeparator1
//
this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator1.Location = new System.Drawing.Point(12, 62);
this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10);
this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator1.Name = "horizontalSeparator1";
this.horizontalSeparator1.Size = new System.Drawing.Size(360, 2);
this.horizontalSeparator1.TabIndex = 73;
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(12, 31);
this.textBox1.BackColor = System.Drawing.Color.Transparent;
this.textBox1.Location = new System.Drawing.Point(96, 15);
this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
this.textBox1.Name = "textBox1";
this.textBox1.PasswordChar = '*';
this.textBox1.Size = new System.Drawing.Size(280, 21);
this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox1.Size = new System.Drawing.Size(276, 32);
this.textBox1.SubmitButton = this.button2;
this.textBox1.TabIndex = 0;
this.textBox1.UseSystemPasswordChar = true;
this.textBox1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox1_PreviewKeyDown);
this.textBox1.UseSystemPasswordChar = false;
//
// btnSave
// label2
//
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSave.BackColor = System.Drawing.Color.WhiteSmoke;
this.btnSave.Location = new System.Drawing.Point(196, 67);
this.btnSave.MaximumSize = new System.Drawing.Size(120, 32);
this.btnSave.MinimumSize = new System.Drawing.Size(32, 32);
this.btnSave.Name = "btnSave";
this.btnSave.Padding = new System.Windows.Forms.Padding(4);
this.btnSave.Size = new System.Drawing.Size(96, 32);
this.btnSave.TabIndex = 23;
this.btnSave.Value = "&OK";
this.btnSave.Click += new System.EventHandler(this.button2_Click);
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 25);
this.label2.Margin = new System.Windows.Forms.Padding(3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 71;
this.label2.Text = "Password";
//
// PasswordForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(304, 111);
this.Controls.Add(this.btnSave);
this.ClientSize = new System.Drawing.Size(384, 121);
this.Controls.Add(this.button2);
this.Controls.Add(this.horizontalSeparator1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Font = new System.Drawing.Font("Tahoma", 8.25F);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 160);
this.Name = "PasswordForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
@ -94,9 +109,9 @@ namespace bzit.bomg
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private RyzStudio.Windows.Forms.BigButton btnSave;
private RyzStudio.Windows.ThemedForms.Button button2;
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.ThemedForms.TextBox textBox1;
private System.Windows.Forms.Label label2;
}
}

View File

@ -21,11 +21,6 @@ namespace bzit.bomg
return;
}
if (string.IsNullOrEmpty(textBox1.Text))
{
return;
}
this.Close();
}
@ -33,9 +28,6 @@ namespace bzit.bomg
{
switch (e.KeyCode)
{
case Keys.Enter:
button2_Click(sender, null);
break;
case Keys.Escape:
this.Close();
break;

View File

@ -117,29 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzjMmFRJ7V6TmMy+AkZqRWAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAR63jyYXp+f9M2fX/OZHM8yNgnF0AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEeq4c+g5vj/N9Ly/0bW9v86k831IlqYYhlS
tw0cXb8NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvl9pcOZ3dzpji9v9S3PX/Rdn2/zaP
zPQ0gs/oNYPS6B9dplMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACyU2TRFqeHKT7fl3l3Z
8v9N2/b/Wt33/1TY9f8tf833H1ehWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADOY
2oaI3fT/aeD2/3Li9/9e3/b/VNr2/zd+zfMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAA6oN2vqO75/33m+P+Z6Pj/fdHw/3/i9v8+l9nwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAALZXZZlzA6v2i8Pv/f9Tw/33H7P9Pot31IG21WQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAokNhwbsns/8nz+/9WueftJITNSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAALJXaAjCY2olFquHLKpXaYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA//+sQf//rEH//6xB4f+sQeD/rEHgH6xB4A+sQfAHrEH8B6xB/AesQfwHrEH+D6xB/h+sQf//
rEH//6xB//+sQQ==
</value>
</data>
</root>

View File

@ -1,75 +1,123 @@
using System;
namespace RyzStudio.IO
{
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
namespace RyzStudio.IO
{
public class SharpZipLib
{
/// <summary>
/// Is zip file encrypted
/// </summary>
/// <param name="fn">Filename</param>
/// <returns>Is encrypted</returns>
public static bool IsZipEncrypted(string fn)
public static bool IsZipEncrypted(string filename)
{
bool ret_val = false;
bool rv = false;
try
{
ZipInputStream zipIn = new ZipInputStream(System.IO.File.OpenRead(fn));
ZipEntry theEntry = null;
while ((theEntry = zipIn.GetNextEntry()) != null)
ZipInputStream zipStream = new ZipInputStream(File.OpenRead(filename));
ZipEntry zipEntry = null;
while ((zipEntry = zipStream.GetNextEntry()) != null)
{
if (theEntry.IsCrypted)
if (zipEntry.IsCrypted)
{
ret_val = true;
rv = true;
}
break;
}
zipIn.Close();
zipStream.Close();
}
catch
{
// do nothing
}
return ret_val;
return rv;
}
public static void AddFile(ZipOutputStream zipstream, string filename, string prefixpath = null)
public static bool TestZipEncrypted(string filename, string password)
{
bool rv = false;
int size = 2;
byte[] buffer = new byte[size];
int bufferSize = 0;
ZipEntry readEntry = null;
ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
readStream.Password = password;
while (true)
{
readEntry = readStream.GetNextEntry();
if (readEntry == null)
{
break;
}
if (string.IsNullOrWhiteSpace(readEntry.Name))
{
continue;
}
if (!readEntry.IsFile)
{
continue;
}
if (readEntry.Size <= 0)
{
continue;
}
try
{
bufferSize = readStream.Read(buffer, 0, buffer.Length);
rv = true;
}
catch
{
break;
}
break;
}
return rv;
}
public static void AddFile(ZipOutputStream zipStream, string filename, string prefixPath = null)
{
byte[] buffer = new byte[4096];
string f1 = "";
if (prefixpath != null)
if (prefixPath != null)
{
f1 = Path.GetDirectoryName(filename).TrimEnd('\\') + "\\";
f1 = f1.Replace(prefixpath, "").TrimEnd('\\') + "\\";
f1 = f1.Replace(prefixPath, "").TrimEnd('\\') + "\\";
f1 = f1 + Path.GetFileName(filename);
f1 = f1.TrimStart('\\');
}
ZipEntry entry = new ZipEntry(f1);
entry.DateTime = DateTime.Now;
zipstream.PutNextEntry(entry);
ZipEntry zipEntry = new ZipEntry(f1);
zipEntry.DateTime = DateTime.Now;
zipStream.PutNextEntry(zipEntry);
FileStream fs = File.OpenRead(filename);
FileStream fileStream = File.OpenRead(filename);
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
zipstream.Write(buffer, 0, sourceBytes);
sourceBytes = fileStream.Read(buffer, 0, buffer.Length);
zipStream.Write(buffer, 0, sourceBytes);
}
while (sourceBytes > 0);
}
public static void AddFolder(ZipOutputStream zipstream, string folderpath, string prefixpath = null)
public static void AddFolder(ZipOutputStream zipStream, string folderPath, string prefixPath = null)
{
foreach (string fn in Directory.GetFiles(folderpath, "*.*", System.IO.SearchOption.AllDirectories))
foreach (string fn in Directory.GetFiles(folderPath, "*.*", System.IO.SearchOption.AllDirectories))
{
AddFile(zipstream, fn, prefixpath);
AddFile(zipStream, fn, prefixPath);
}
}
}

View File

@ -100,5 +100,7 @@
[Browsable(false)]
public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.White, Color.Black);
public void PerformClick() => this.OnClick(null);
}
}

View File

@ -15,6 +15,7 @@
InitializeComponent();
this.Margin = new Padding(10, 6, 10, 6);
textBox1.PreviewKeyDown += textBox_PreviewKeyDown;
}
protected override void OnResize(EventArgs e)
@ -33,6 +34,24 @@
textBox1.Focus();
}
protected void textBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
if (this.SubmitButton != null)
{
this.SubmitButton.PerformClick();
}
break;
//case Keys.Escape:
// this.Close();
// break;
default: break;
}
}
[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
[Category("Appearance")]
public System.Windows.Forms.TextBox InnerTextBox { get => textBox1; set => textBox1 = value; }
@ -41,6 +60,14 @@
[Category("Appearance")]
public new string Text { get => textBox1.Text; set => textBox1.Text = value; }
[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
[Category("Appearance")]
public bool UseSystemPasswordChar { get => textBox1.UseSystemPasswordChar; set => textBox1.UseSystemPasswordChar = value; }
[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
[Category("Appearance")]
public Button SubmitButton { get; set; } = null;
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Padding Margin { get { return base.Margin; } set { base.Margin = value; } }

View File

@ -1,6 +1,6 @@
namespace bzit.bomg
namespace RyzStudio.Windows.ThemedForms
{
partial class NewSessionForm
partial class TextBoxForm
{
/// <summary>
/// Required designer variable.
@ -28,23 +28,40 @@ namespace bzit.bomg
/// </summary>
private void InitializeComponent()
{
this.textBox2 = new RyzStudio.Windows.ThemedForms.TextBox();
this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox();
this.button2 = new RyzStudio.Windows.ThemedForms.Button();
this.label2 = new System.Windows.Forms.Label();
this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.button2 = new RyzStudio.Windows.ThemedForms.Button();
this.SuspendLayout();
//
// textBox2
// textBox1
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.BackColor = System.Drawing.Color.Transparent;
this.textBox2.Location = new System.Drawing.Point(96, 15);
this.textBox2.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
this.textBox2.Name = "textBox2";
this.textBox2.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox2.Size = new System.Drawing.Size(276, 32);
this.textBox2.TabIndex = 68;
this.textBox1.BackColor = System.Drawing.Color.Transparent;
this.textBox1.Location = new System.Drawing.Point(96, 15);
this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
this.textBox1.Name = "textBox1";
this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox1.Size = new System.Drawing.Size(276, 32);
this.textBox1.SubmitButton = this.button2;
this.textBox1.TabIndex = 0;
this.textBox1.UseSystemPasswordChar = false;
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.BackColor = System.Drawing.Color.Transparent;
this.button2.DefaultImage = null;
this.button2.DownImage = null;
this.button2.LabelText = "&OK";
this.button2.Location = new System.Drawing.Point(264, 77);
this.button2.Name = "button2";
this.button2.OverImage = null;
this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button2.Size = new System.Drawing.Size(108, 32);
this.button2.TabIndex = 1;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label2
//
@ -60,40 +77,26 @@ namespace bzit.bomg
//
this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator1.Location = new System.Drawing.Point(12, 63);
this.horizontalSeparator1.Location = new System.Drawing.Point(12, 62);
this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(3, 10, 3, 10);
this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator1.Name = "horizontalSeparator1";
this.horizontalSeparator1.Size = new System.Drawing.Size(360, 2);
this.horizontalSeparator1.TabIndex = 69;
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.BackColor = System.Drawing.Color.Transparent;
this.button2.DefaultImage = null;
this.button2.DownImage = null;
this.button2.LabelText = "&OK";
this.button2.Location = new System.Drawing.Point(264, 78);
this.button2.Name = "button2";
this.button2.OverImage = null;
this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button2.Size = new System.Drawing.Size(108, 32);
this.button2.TabIndex = 70;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// NewSessionForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(384, 122);
this.ClientSize = new System.Drawing.Size(384, 121);
this.Controls.Add(this.button2);
this.Controls.Add(this.horizontalSeparator1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Font = new System.Drawing.Font("Tahoma", 8.25F);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 160);
this.Name = "NewSessionForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
@ -105,7 +108,7 @@ namespace bzit.bomg
}
#endregion
private RyzStudio.Windows.ThemedForms.TextBox textBox2;
private RyzStudio.Windows.ThemedForms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.ThemedForms.Button button2;

View File

@ -0,0 +1,67 @@
using System;
using System.Windows.Forms;
namespace RyzStudio.Windows.ThemedForms
{
public partial class TextBoxForm : Form
{
public TextBoxForm(string title, string labelText, string defaultValue)
{
InitializeComponent();
this.Text = title;
label2.Text = labelText;
textBox1.Text = defaultValue;
}
public TextBoxForm(string title, string labelText, string defaultValue, bool password)
{
InitializeComponent();
this.Text = title;
label2.Text = labelText;
textBox1.Text = defaultValue;
textBox1.UseSystemPasswordChar = password;
}
public TextBoxForm(string title, string labelText)
{
InitializeComponent();
this.Text = title;
label2.Text = labelText;
}
public TextBoxForm(string title, string labelText, bool password)
{
InitializeComponent();
this.Text = title;
label2.Text = labelText;
textBox1.UseSystemPasswordChar = password;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Escape:
this.Close();
break;
default: break;
}
}
public new string ShowDialog()
{
base.ShowDialog();
return textBox1.Text;
}
}
}

View File

@ -198,6 +198,21 @@ namespace RyzStudio.Windows.Forms
return node.Nodes.Add(encodePath(name), name, (int)IconSet.Folder1, (int)IconSet.Folder2);
}
public void AddItem(List<BookmarkItemViewModel> viewModelList)
{
this.Clear();
if (viewModelList == null)
{
return;
}
foreach (BookmarkItemViewModel item in viewModelList)
{
AddItem(item);
}
}
public void AddItem(BookmarkItemViewModel viewModel)
{
int iconIndex = addIcon(viewModel);
@ -296,7 +311,10 @@ namespace RyzStudio.Windows.Forms
return rs;
}
traverseBookmarkList(rs, this.Nodes[0]);
foreach (TreeNode item in this.Nodes)
{
traverseBookmarkList(rs, item);
}
return rs;
}
@ -403,13 +421,19 @@ namespace RyzStudio.Windows.Forms
public void Clear()
{
//nodeCount = 0;
//NodeCountUpdate(nodeCount);
this.Nodes.Clear();
this.HasChanged = true;
}
public void Clear(string name)
{
this.Nodes.Clear();
this.Nodes.Add("", name?.Trim(), (int)IconSet.Root, (int)IconSet.Root);
this.HasChanged = true;
}
#endregion
#region integrated behaviour
@ -491,22 +515,6 @@ namespace RyzStudio.Windows.Forms
this.HasChanged = true;
base.OnBeforeLabelEdit(e);
//if (e.Node == null)
//{
// e.CancelEdit = true;
//}
//else
//{
// if (e.Node.Tag == null)
// {
// // do it
// }
// else
// {
// e.CancelEdit = true;
// }
//}
}
protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
@ -627,14 +635,8 @@ namespace RyzStudio.Windows.Forms
base.OnPreviewKeyDown(e);
}
//protected virtual void NodeCountUpdate(ulong v)
//{
// this.OnNodeCountUpdate?.Invoke(v);
//}
#endregion
protected int addIcon(BookmarkItemViewModel viewModel) => addIcon(viewModel.ToModel());
protected int addIcon(BookmarkItemModel model)
@ -672,11 +674,12 @@ namespace RyzStudio.Windows.Forms
protected TreeNode addFolderPath(string path)
{
TreeNode tn = this.Nodes[0];
if (tn == null)
{
return tn;
}
TreeNode tn = null;
//TreeNode tn = this.Nodes[0];
//if (tn == null)
//{
// return tn;
//}
if (string.IsNullOrWhiteSpace(path))
{
@ -694,19 +697,29 @@ namespace RyzStudio.Windows.Forms
return tn;
}
foreach (string item in folderList)
for (int i=0; i<folderList.Length; i++)
{
if (tn.Nodes.ContainsKey(item))
string item = folderList[i];
if (i <= 0)
{
// do nothing
if (!this.Nodes.ContainsKey(item))
{
this.Nodes.Add(item, decodePath(item), (int)IconSet.Root, (int)IconSet.Root);
}
tn = this.Nodes[item];
}
else
{
tn.Nodes.Add(item, item, (int)IconSet.Folder1, (int)IconSet.Folder2);
if (!tn.Nodes.ContainsKey(item))
{
tn.Nodes.Add(item, decodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
}
tn = tn.Nodes[item];
}
}
return tn;
}
@ -792,55 +805,5 @@ namespace RyzStudio.Windows.Forms
return false;
}
//protected void traverseNodeList(ref TreeNode[] results, TreeNode node)
//{
// foreach (TreeNode tn in node.Nodes)
// {
// if (tn.Tag == null)
// {
// traverseNodeList(ref results, tn);
// }
// else
// {
// Array.Resize(ref results, (results.Length + 1));
// results[(results.Length - 1)] = tn;
// }
// }
//}
//protected void traverseNodeCount(ref ulong results, TreeNode node)
//{
// foreach (TreeNode tn in node.Nodes)
// {
// if (tn.Tag == null)
// {
// traverseNodeCount(ref results, tn);
// }
// else
// {
// results++;
// }
// }
//}
//protected virtual void OnAddFolderNode(TreeNode node) { }
//protected virtual void OnAddItemNode(TreeNode node) { }
////protected string PathEncode(string text) { return RyzStudio.String.EncodeTo64(text); }
//protected string PathDecode(string text) { return RyzStudio.String.DecodeFrom64(text); }
}
}

View File

@ -161,7 +161,6 @@
<Compile Include="UpdateIconForm.Designer.cs">
<DependentUpon>UpdateIconForm.cs</DependentUpon>
</Compile>
<Compile Include="SessionFileFormat.cs" />
<Compile Include="Data\IconDatabase.cs" />
<Compile Include="BookmarkEditForm.cs">
<SubType>Form</SubType>
@ -175,11 +174,11 @@
<Compile Include="FindForm.Designer.cs">
<DependentUpon>FindForm.cs</DependentUpon>
</Compile>
<Compile Include="NewSessionForm.cs">
<Compile Include="RyzStudio\Windows\ThemedForms\TextBoxForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NewSessionForm.Designer.cs">
<DependentUpon>NewSessionForm.cs</DependentUpon>
<Compile Include="RyzStudio\Windows\ThemedForms\TextBoxForm.Designer.cs">
<DependentUpon>TextBoxForm.cs</DependentUpon>
</Compile>
<Compile Include="PasswordForm.cs">
<SubType>Form</SubType>
@ -242,8 +241,8 @@
<EmbeddedResource Include="FindForm.resx">
<DependentUpon>FindForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NewSessionForm.resx">
<DependentUpon>NewSessionForm.cs</DependentUpon>
<EmbeddedResource Include="RyzStudio\Windows\ThemedForms\TextBoxForm.resx">
<DependentUpon>TextBoxForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PasswordForm.resx">
<DependentUpon>PasswordForm.cs</DependentUpon>