CodeWalker/Explorer/OrganizeFavorites.cs
FiftyShadesOfBlue 4429a5e9ab Added Favorites To Rpf Explorer
I added favorites to the RPF Explorer. With this you can now click Favorites > Add to favorites and you will now have that path saved in a drop down list that you can easily access. You can also open the "OrganizeFavorites" form and that will allow you to be able to organize them. In here you can remove a certain favorite. You can clear ALL favorites. To save your favorites all you have to do is click the save button. Also if you click the X button then anything changed will not be saved. OrganizeFavorites form opens in whatever theme the RPF Explorer is in.
2018-03-16 01:22:45 -04:00

71 lines
2.0 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()
{
xDoc.Load(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\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();
}
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.Index == 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(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml");
ExploreForm.LoadFavorites();
Close();
}
}
}