mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-17 04:22:54 +08:00
83 lines
2.4 KiB
C#
83 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
|
|
namespace CodeWalker.Explorer
|
|
{
|
|
public partial class OrganizeFavorites : Form
|
|
{
|
|
public ExploreForm ExploreForm { get; set; }
|
|
|
|
private XmlDocument xDoc = new XmlDocument();
|
|
private XmlNodeList FavoriteNodes;
|
|
private XmlNode Root;
|
|
|
|
public OrganizeFavorites(ExploreForm exploreform)
|
|
{
|
|
ExploreForm = exploreform;
|
|
InitializeComponent();
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
try
|
|
{
|
|
xDoc.Load(Application.StartupPath + @"\Resources\Favorites.xml");
|
|
FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite");
|
|
Root = xDoc.DocumentElement;
|
|
foreach (XmlNode FavNode in FavoriteNodes)
|
|
{
|
|
FavoritesTreeView.Nodes[0].Nodes.Add(FavNode.InnerText);
|
|
}
|
|
|
|
FavoritesTreeView.ExpandAll();
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("Favorites.xml is missing from " + Application.StartupPath + @"\Resources", "Error");
|
|
}
|
|
}
|
|
|
|
private void ClearAllFavoritesButton_Click(object sender, EventArgs e)
|
|
{
|
|
FavoritesTreeView.Nodes[0].Nodes.Clear();
|
|
Root.RemoveAll();
|
|
}
|
|
|
|
private void RemoveFavoriteButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (FavoritesTreeView.SelectedNode == FavoritesTreeView.Nodes[0]) return;
|
|
string FavoriteToDelete = FavoritesTreeView.SelectedNode.Text;
|
|
FavoritesTreeView.SelectedNode.Remove();
|
|
|
|
foreach (XmlNode FavNode in FavoriteNodes)
|
|
{
|
|
if(FavNode.InnerText == FavoriteToDelete)
|
|
{
|
|
Root.RemoveChild(FavNode);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SaveButton_Click(object sender, EventArgs e)
|
|
{
|
|
xDoc.Save(Application.StartupPath + @"\Resources\Favorites.xml");
|
|
ExploreForm.LoadFavorites();
|
|
Close();
|
|
}
|
|
|
|
private void CancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}
|