Changed: thread helper
This commit is contained in:
parent
f82dfbc308
commit
9e6992acd2
24
MainForm.cs
24
MainForm.cs
@ -822,17 +822,7 @@ namespace bzit.bomg
|
||||
this.ApplicationMode = AppMode.Open;
|
||||
}
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}
|
||||
RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
}
|
||||
|
||||
protected void loadBookmarkFile_ForRYZ(string filename, string password = "")
|
||||
@ -977,17 +967,7 @@ namespace bzit.bomg
|
||||
this.ApplicationMode = AppMode.New;
|
||||
}
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text = Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name;
|
||||
}
|
||||
RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
}
|
||||
|
||||
protected void openBookmark(TreeNode node)
|
||||
|
@ -71,6 +71,56 @@ namespace RyzStudio.Windows.Forms
|
||||
return n;
|
||||
}
|
||||
|
||||
public static TreeNode Add(TreeNode control, string key, string text, int imageIndex, int selectedImageIndex)
|
||||
{
|
||||
TreeNode rs = null;
|
||||
|
||||
if (control.TreeView.InvokeRequired)
|
||||
{
|
||||
control.TreeView.Invoke(new MethodInvoker(() => {
|
||||
rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
public static TreeNode Add(TreeView control, string key, string text, int imageIndex, int selectedImageIndex)
|
||||
{
|
||||
TreeNode rs = null;
|
||||
|
||||
if (control.InvokeRequired)
|
||||
{
|
||||
control.Invoke(new MethodInvoker(() => {
|
||||
rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = control.Nodes.Add(key, text, imageIndex, selectedImageIndex);
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
public static void Add(Control parentControl, ImageList control, string key, Image value)
|
||||
{
|
||||
if (parentControl.InvokeRequired)
|
||||
{
|
||||
parentControl.Invoke(new MethodInvoker(() => {
|
||||
control.Images.Add(key, value);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
control.Images.Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static int Add(TreeNode control, TreeNode value)
|
||||
{
|
||||
int n = -1;
|
||||
|
@ -166,17 +166,7 @@ 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);
|
||||
}
|
||||
ThreadControl.Add(tn2, tn);
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
@ -217,17 +207,7 @@ namespace RyzStudio.Windows.Forms
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.Nodes.Clear();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Nodes.Clear();
|
||||
}
|
||||
ThreadControl.Clear(this);
|
||||
|
||||
this.HasChanged = true;
|
||||
}
|
||||
@ -666,17 +646,7 @@ namespace RyzStudio.Windows.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, rs);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ImageList.Images.Add(model.SiteAddress, rs);
|
||||
}
|
||||
ThreadControl.Add(this, this.ImageList, model.SiteAddress, rs);
|
||||
|
||||
return this.ImageList.Images.IndexOfKey(model.SiteAddress);
|
||||
}
|
||||
@ -689,17 +659,7 @@ namespace RyzStudio.Windows.Forms
|
||||
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);
|
||||
}
|
||||
ThreadControl.Add(this, this.ImageList, model.SiteAddress, bmp);
|
||||
|
||||
iconDatabase.AddIcon(model.SiteAddress, rawData);
|
||||
|
||||
@ -739,17 +699,7 @@ namespace RyzStudio.Windows.Forms
|
||||
{
|
||||
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);
|
||||
}
|
||||
ThreadControl.Add(this, item, decodePath(item), (int)IconSet.Root, (int)IconSet.Root);
|
||||
}
|
||||
|
||||
tn = this.Nodes[item];
|
||||
@ -758,17 +708,7 @@ namespace RyzStudio.Windows.Forms
|
||||
{
|
||||
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);
|
||||
}
|
||||
ThreadControl.Add(tn, item, decodePath(item), (int)IconSet.Folder1, (int)IconSet.Folder2);
|
||||
}
|
||||
|
||||
tn = tn.Nodes[item];
|
||||
|
Reference in New Issue
Block a user