Changed: threading and icons db
This commit is contained in:
parent
17e4e867eb
commit
d232f7b5ec
82
MainForm.cs
82
MainForm.cs
@ -803,29 +803,31 @@ namespace bzit.bomg
|
||||
readStream.Dispose();
|
||||
readStream = null;
|
||||
|
||||
if (treeView1.InvokeRequired)
|
||||
{
|
||||
treeView1.Invoke(new MethodInvoker(() => {
|
||||
treeView1.AddItem(rs);
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.ApplicationMode = AppMode.Open;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
treeView1.AddItem(rs);
|
||||
this.ApplicationMode = AppMode.Open;
|
||||
}
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => {
|
||||
this.ApplicationMode = AppMode.Open;
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ApplicationMode = AppMode.Open;
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}
|
||||
|
||||
setAppTitle(Path.GetFileNameWithoutExtension(filename));
|
||||
}
|
||||
|
||||
protected void loadBookmarkFile_ForRYZ(string filename, string password = "")
|
||||
@ -953,23 +955,15 @@ namespace bzit.bomg
|
||||
readStream.Dispose();
|
||||
readStream = null;
|
||||
|
||||
if (treeView1.InvokeRequired)
|
||||
{
|
||||
treeView1.Invoke(new MethodInvoker(() => {
|
||||
treeView1.AddItem(rs);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
treeView1.AddItem(rs);
|
||||
}
|
||||
|
||||
sessionFilename = sessionPassword = null;
|
||||
usePassword = !string.IsNullOrWhiteSpace(password);
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => {
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.ApplicationMode = AppMode.New;
|
||||
}));
|
||||
}
|
||||
@ -978,7 +972,17 @@ namespace bzit.bomg
|
||||
this.ApplicationMode = AppMode.New;
|
||||
}
|
||||
|
||||
setAppTitle(Path.GetFileNameWithoutExtension(filename));
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}
|
||||
}
|
||||
|
||||
protected void openBookmark(TreeNode node)
|
||||
@ -1018,7 +1022,7 @@ namespace bzit.bomg
|
||||
case 1:
|
||||
saveBookmarkFile_ForJSNX(saveFileDialog.FileName);
|
||||
|
||||
setAppTitle(Path.GetFileNameWithoutExtension(saveFileDialog.FileName));
|
||||
this.Text = Path.GetFileNameWithoutExtension(saveFileDialog.FileName) + " - " + Properties.Resources.app_name;
|
||||
|
||||
sessionFilename = saveFileDialog.FileName;
|
||||
usePassword = false;
|
||||
@ -1031,7 +1035,7 @@ namespace bzit.bomg
|
||||
|
||||
saveBookmarkFile_ForJSNX(saveFileDialog.FileName, password ?? string.Empty);
|
||||
|
||||
setAppTitle(Path.GetFileNameWithoutExtension(saveFileDialog.FileName));
|
||||
this.Text = Path.GetFileNameWithoutExtension(saveFileDialog.FileName) + " - " + Properties.Resources.app_name;
|
||||
|
||||
sessionFilename = saveFileDialog.FileName;
|
||||
sessionPassword = password;
|
||||
@ -1093,20 +1097,6 @@ namespace bzit.bomg
|
||||
treeView1.HasChanged = false;
|
||||
}
|
||||
|
||||
protected void setAppTitle(string title)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => {
|
||||
this.Text = title + " - " + Properties.Resources.app_name;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text = title + " - " + Properties.Resources.app_name;
|
||||
}
|
||||
}
|
||||
|
||||
protected void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Right)
|
||||
@ -1243,27 +1233,11 @@ namespace bzit.bomg
|
||||
{
|
||||
if (loadFileType == LoadFileType.Jsnx)
|
||||
{
|
||||
if (usePassword)
|
||||
{
|
||||
loadBookmarkFile_ForJSNX(sessionFilename, sessionPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadBookmarkFile_ForJSNX(sessionFilename);
|
||||
}
|
||||
loadBookmarkFile_ForJSNX(sessionFilename, sessionPassword ?? string.Empty);
|
||||
}
|
||||
else if (loadFileType == LoadFileType.Ryz)
|
||||
{
|
||||
if (usePassword)
|
||||
{
|
||||
loadBookmarkFile_ForRYZ(sessionFilename, sessionPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadBookmarkFile_ForRYZ(sessionFilename);
|
||||
}
|
||||
|
||||
sessionFilename = sessionPassword = null;
|
||||
loadBookmarkFile_ForRYZ(sessionFilename, sessionPassword ?? string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,42 @@ namespace bzit.bomg
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap RetrieveFavicon(out byte[] rawData)
|
||||
{
|
||||
rawData = null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.FaviconAddress))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] iconData = null;
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
||||
|
||||
try
|
||||
{
|
||||
iconData = webClient.DownloadData(this.FaviconAddress);
|
||||
|
||||
if (!RyzStudio.IO.FileType.IsImage(iconData))
|
||||
{
|
||||
throw new Exception("Not a supported image");
|
||||
}
|
||||
|
||||
rawData = iconData;
|
||||
|
||||
Image img = Image.FromStream(new MemoryStream(iconData));
|
||||
return new Bitmap(img, 16, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
iconData = null;
|
||||
this.FaviconAddress = null;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected string retrieveSourceCode()
|
||||
{
|
||||
if (webClient == null)
|
||||
|
@ -169,7 +169,17 @@ namespace RyzStudio.Windows.Forms
|
||||
|
||||
TreeNode tn2 = addFolderPath(viewModel.TreeviewPath);
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
tn2.Nodes.Add(tn);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
tn2.Nodes.Add(tn);
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
@ -209,8 +219,18 @@ namespace RyzStudio.Windows.Forms
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Nodes.Clear();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Nodes.Clear();
|
||||
}
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
@ -646,20 +666,43 @@ namespace RyzStudio.Windows.Forms
|
||||
return (int)IconSet.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, rs);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, rs);
|
||||
}
|
||||
|
||||
return this.ImageList.Images.IndexOfKey(model.SiteAddress);
|
||||
}
|
||||
}
|
||||
|
||||
Bitmap bmp = model.RetrieveFavicon();
|
||||
byte[] rawData;
|
||||
Bitmap bmp = model.RetrieveFavicon(out rawData);
|
||||
if (bmp == null)
|
||||
{
|
||||
return (int)IconSet.Default;
|
||||
}
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, bmp);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, bmp);
|
||||
}
|
||||
|
||||
iconDatabase.AddIcon(model.SiteAddress, rawData);
|
||||
|
||||
return this.ImageList.Images.IndexOfKey(model.SiteAddress);
|
||||
}
|
||||
@ -696,8 +739,18 @@ namespace RyzStudio.Windows.Forms
|
||||
if (i <= 0)
|
||||
{
|
||||
if (!this.Nodes.ContainsKey(item))
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Nodes.Add(item, decodePath(item), (int)IconSet.Root, (int)IconSet.Root);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Nodes.Add(item, decodePath(item), (int)IconSet.Root, (int)IconSet.Root);
|
||||
}
|
||||
}
|
||||
|
||||
tn = this.Nodes[item];
|
||||
@ -705,8 +758,18 @@ namespace RyzStudio.Windows.Forms
|
||||
else
|
||||
{
|
||||
if (!tn.Nodes.ContainsKey(item))
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
tn.Nodes.Add(item, decodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
tn.Nodes.Add(item, decodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
|
||||
}
|
||||
}
|
||||
|
||||
tn = tn.Nodes[item];
|
||||
|
Reference in New Issue
Block a user