aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/FileSkimmer.cs
diff options
context:
space:
mode:
authorMichael VanOverbeek <[email protected]>2017-05-21 12:21:41 +0000
committerMichael VanOverbeek <[email protected]>2017-05-21 12:21:41 +0000
commit31cc9148dd23737df16d8456a42d003cd31dd488 (patch)
treef699644cd0384e80a673099374649b7350d6e02d /ShiftOS.WinForms/Applications/FileSkimmer.cs
parent3b1c71e6710c06a9e390f449589bd30cb2f4b7dd (diff)
downloadshiftos_thereturn-31cc9148dd23737df16d8456a42d003cd31dd488.tar.gz
shiftos_thereturn-31cc9148dd23737df16d8456a42d003cd31dd488.tar.bz2
shiftos_thereturn-31cc9148dd23737df16d8456a42d003cd31dd488.zip
holy ashit
Diffstat (limited to 'ShiftOS.WinForms/Applications/FileSkimmer.cs')
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.cs69
1 files changed, 64 insertions, 5 deletions
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs
index 6309775..218e9e2 100644
--- a/ShiftOS.WinForms/Applications/FileSkimmer.cs
+++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs
@@ -34,8 +34,8 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using static ShiftOS.Objects.ShiftFS.Utils;
-using Newtonsoft.Json;
using ShiftOS.Engine;
+using Newtonsoft.Json;
namespace ShiftOS.WinForms.Applications
{
@@ -129,8 +129,14 @@ namespace ShiftOS.WinForms.Applications
{
int amountsCalled = -1;
amountsCalled = amountsCalled + 1;
- pinnedItems.Nodes.Add(path);
- pinnedItems.Nodes[amountsCalled].Nodes.Add("test");
+ List<string> Pinned = new List<string>();
+ if(FileExists(Paths.GetPath("data") + "/pinned_items.dat"))
+ {
+ Pinned = JsonConvert.DeserializeObject<List<string>>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat"));
+ }
+ Pinned.Add(path);
+ WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned));
+ ResetList();
}
public void ChangeDirectory(string path)
@@ -153,8 +159,40 @@ namespace ShiftOS.WinForms.Applications
}
}
+ public void PopulatePinned(TreeNode node, string[] items)
+ {
+ foreach(var dir in items)
+ {
+ var treenode = new TreeNode();
+ if (DirectoryExists(dir))
+ {
+ var dinf = GetDirectoryInfo(dir);
+ treenode.Text = dinf.Name;
+ }
+ else if (FileExists(dir))
+ {
+ var finf = GetFileInfo(dir);
+ treenode.Text = finf.Name;
+ }
+ treenode.Tag = dir;
+ node.Nodes.Add(treenode);
+ }
+ }
+
public void ResetList()
{
+ pinnedItems.Nodes.Clear();
+ List<string> Pinned = new List<string>();
+ if(FileExists(Paths.GetPath("data") + "/pinned_items.dat"))
+ {
+ Pinned = JsonConvert.DeserializeObject<List<string>>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat"));
+ }
+ var node = new TreeNode();
+ node.Text = "Pinned";
+ PopulatePinned(node, Pinned.ToArray());
+ pinnedItems.Nodes.Add(node);
+ node.ExpandAll();
+
if(lvitems.LargeImageList == null)
{
lvitems.LargeImageList = new ImageList();
@@ -423,14 +461,14 @@ namespace ShiftOS.WinForms.Applications
{
if (result == true)
{
- if (currentdir != "__system")
+ if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one")
{
pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text);
ResetList();
}
else
{
- Infobox.Show("Cannot Pin", "You cannot pin a system drive.");
+ Infobox.Show("Cannot Pin", "You can only pin files or folders.");
}
}
@@ -438,5 +476,26 @@ namespace ShiftOS.WinForms.Applications
}
catch { }
}
+
+ private void pinnedItems_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (pinnedItems.SelectedNode != null)
+ {
+ string path = pinnedItems.SelectedNode.Tag.ToString();
+ if (DirectoryExists(path))
+ {
+ currentdir = path;
+ ResetList();
+ }
+ else if (FileExists(path))
+ {
+ FileSkimmerBackend.OpenFile(path);
+ }
+ }
+ }
+ catch { }
+ }
}
}