WIP: web parser + ui

This commit is contained in:
Ray committed 2021-09-17 16:37:01 +01:00
1 parent c00d42a7d8
commit 682af23f55
11 files changed
+540 -147

No files matched your search

+50 -51
View File
@@ -39,14 +39,14 @@ namespace RyzStudio.Windows.Forms
return System.Web.HttpUtility.UrlEncode(value);
}
public static BookmarkItemViewModel GetNodeModel(TreeNode node)
public static BookmarkItem GetNodeModel(TreeNode node)
{
if (node == null)
{
return null;
}
return (BookmarkItemViewModel)node.Tag;
return (BookmarkItem)node.Tag;
}
public static string GetNodePath(TreeNode node)
@@ -90,7 +90,7 @@ namespace RyzStudio.Windows.Forms
}
else
{
if (node.Tag is BookmarkItemViewModel)
if (node.Tag is BookmarkItem)
{
return NodeType.Page;
}
@@ -259,27 +259,27 @@ namespace RyzStudio.Windows.Forms
return;
}
TreeNode en = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
if (en == null)
TreeNode node = this.GetNodeAt(this.PointToClient(new Point(e.X, e.Y)));
if (node == null)
{
return;
}
if (IsNodeChild(draggingNode, en))
if (ThreadControl.IsChild(draggingNode, node))
{
return;
}
TreeNode dn = draggingNode;
if (en.Tag == null)
if (node.Tag == null)
{
dn.Parent.Nodes.Remove(dn);
en.Nodes.Insert(0, dn);
node.Nodes.Insert(0, dn);
}
else
{
en.Parent.Nodes.Remove(dn);
en.Parent.Nodes.Insert(en.Index + 1, dn);
node.Parent.Nodes.Remove(dn);
node.Parent.Nodes.Insert(node.Index + 1, dn);
}
this.HasChanged = true;
@@ -428,7 +428,7 @@ namespace RyzStudio.Windows.Forms
break;
case NodeType.Page:
BookmarkItemViewModel viewModel = this.GetNodeModel();
BookmarkItem viewModel = this.GetNodeModel();
if (viewModel != null)
{
try
@@ -612,33 +612,33 @@ namespace RyzStudio.Windows.Forms
// this.HasChanged = false;
//}
public void AddItem(BookmarkItemViewModel viewModel)
public void AddItem(BookmarkItem item)
{
int iconIndex = addIcon(viewModel);
int iconIndex = addIcon(item);
TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex);
tn.Tag = viewModel;
tn.ToolTipText = viewModel.ToString();
TreeNode tn = new TreeNode(item.SiteName, iconIndex, iconIndex);
tn.Tag = item;
tn.ToolTipText = item.ToString();
TreeNode tn2 = AddFolderPath(viewModel.TreeviewPath);
TreeNode tn2 = AddFolderPath(item.TreeviewPath);
ThreadControl.Add(tn2, tn);
this.HasChanged = true;
}
public TreeNode AddItem(TreeNode treeNode, BookmarkItemViewModel viewModel)
public TreeNode AddItem(TreeNode treeNode, BookmarkItem item)
{
if (treeNode == null)
{
return null;
}
int iconIndex = addIcon(viewModel);
int iconIndex = addIcon(item);
TreeNode tn = new TreeNode(viewModel.SiteName, iconIndex, iconIndex);
tn.Tag = viewModel;
tn.ToolTipText = viewModel.ToString();
TreeNode tn = new TreeNode(item.SiteName, iconIndex, iconIndex);
tn.Tag = item;
tn.ToolTipText = item.ToString();
treeNode.Nodes.Add(tn);
@@ -734,16 +734,15 @@ namespace RyzStudio.Windows.Forms
}
}
public NodeType GetNodeType() => GetNodeType(this.SelectedNode);
public string GetNodePath() => GetNodePath(this.SelectedNode);
public BookmarkItemViewModel GetNodeModel() => GetNodeModel(this.SelectedNode);
public BookmarkItem GetNodeModel() => GetNodeModel(this.SelectedNode);
public List<BookmarkItemViewModel> GetBookmarkList()
public List<BookmarkItem> GetBookmarkList()
{
List<BookmarkItemViewModel> rs = new List<BookmarkItemViewModel>();
List<BookmarkItem> rs = new List<BookmarkItem>();
if (this.Nodes.Count <= 0)
{
@@ -856,26 +855,26 @@ namespace RyzStudio.Windows.Forms
public new void Sort() => Sort(this.SelectedNode);
public void UpdateItem(TreeNode treeNode, BookmarkItemViewModel model, Image image)
public void UpdateItem(TreeNode treeNode, BookmarkItem item, Image image)
{
if (treeNode == null)
{
return;
}
int iconIndex = addIcon(model);
int iconIndex = addIcon(item);
treeNode.Text = model.SiteName;
treeNode.Text = item.SiteName;
treeNode.ImageIndex = iconIndex;
treeNode.SelectedImageIndex = iconIndex;
treeNode.Tag = model;
treeNode.ToolTipText = model.ToString();
treeNode.Tag = item;
treeNode.ToolTipText = item.ToString();
this.HasChanged = true;
}
protected int addIcon(BookmarkItemViewModel viewModel)
protected int addIcon(BookmarkItem viewModel)
{
return (int)IconSet.Default;
}
@@ -973,28 +972,28 @@ namespace RyzStudio.Windows.Forms
return tn;
}
protected bool IsNodeChild(TreeNode dragNode, TreeNode dropNode)
{
TreeNode tn = dropNode;
while (true)
{
if (tn.Parent == null)
{
break;
}
//protected bool IsNodeChild(TreeNode dragNode, TreeNode dropNode)
//{
// TreeNode tn = dropNode;
// while (true)
// {
// if (tn.Parent == null)
// {
// break;
// }
if (tn.Equals(dragNode))
{
return true;
}
// if (tn.Equals(dragNode))
// {
// return true;
// }
tn = tn.Parent;
}
// tn = tn.Parent;
// }
return false;
}
// return false;
//}
protected void TraverseBookmarkList(List<BookmarkItemViewModel> rs, TreeNode node)
protected void TraverseBookmarkList(List<BookmarkItem> rs, TreeNode node)
{
foreach (TreeNode tn in node.Nodes)
{
@@ -1005,7 +1004,7 @@ namespace RyzStudio.Windows.Forms
}
else if (nodeType == NodeType.Page)
{
BookmarkItemViewModel nodeTag = GetNodeModel(tn);
BookmarkItem nodeTag = GetNodeModel(tn);
nodeTag.TreeviewPath = GetNodePath(tn);
if (nodeTag != null)