aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/FileSkimmer.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-05-28 12:37:00 -0700
committerGitHub <[email protected]>2017-05-28 12:37:00 -0700
commit771c20cfb3a703e0f1550fdcf9eb07b78298c944 (patch)
tree59cb532e15ebff313fdba2be264d78ec0033f407 /ShiftOS.WinForms/Applications/FileSkimmer.cs
parent496b0cbf8659c99203f48210fd39c572400ae623 (diff)
parentc7ba7d733c756d196f98dd4533289a1ef4db715f (diff)
downloadshiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.tar.gz
shiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.tar.bz2
shiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.zip
Merge pull request #1 from shiftos-game/master
welp, no longer a dev.
Diffstat (limited to 'ShiftOS.WinForms/Applications/FileSkimmer.cs')
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.cs220
1 files changed, 217 insertions, 3 deletions
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs
index 2881dc0..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
{
@@ -125,6 +125,20 @@ namespace ShiftOS.WinForms.Applications
private string currentdir = "";
+ public void pinDirectory(string path)
+ {
+ int amountsCalled = -1;
+ amountsCalled = amountsCalled + 1;
+ 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)
{
currentdir = path;
@@ -145,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();
@@ -233,6 +279,8 @@ namespace ShiftOS.WinForms.Applications
return Properties.Resources.fileicon10;
case FileType.TextFile:
return Properties.Resources.fileicon2;
+ case FileType.CommandFormat:
+ return Properties.Resources.fileiconcf;
default:
return Properties.Resources.fileicon1;
}
@@ -257,6 +305,9 @@ namespace ShiftOS.WinForms.Applications
public void OnUpgrade()
{
+ moveToolStripMenuItem.Visible = false;
+ copyToolStripMenuItem.Visible = false;
+ deleteToolStripMenuItem.Visible = false;
}
private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
@@ -281,7 +332,170 @@ namespace ShiftOS.WinForms.Applications
}
});
}
- }
-
+ private void lvitems_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ try
+ {
+ if (currentdir != "__system")
+ {
+ var itm = lvitems.SelectedItems[0];
+ if (itm.Tag.ToString() != "__..")
+ {
+ if (DirectoryExists(currentdir + "/" + itm.Tag.ToString()))
+ {
+ deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_recursive_delete");
+ moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move_folder");
+ copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy_folder");
+ }
+ else if (FileExists(currentdir + "/" + itm.Tag.ToString()))
+ {
+ deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_delete");
+ moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move");
+ copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy");
+ }
+ }
+ }
+ }
+ catch
+ {
+ moveToolStripMenuItem.Visible = false;
+ copyToolStripMenuItem.Visible = false;
+ }
+ }
+
+ private void lvitems_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
+ {
+ if(lvitems.SelectedItems.Count == 0)
+ {
+ moveToolStripMenuItem.Visible = false;
+ copyToolStripMenuItem.Visible = false;
+ deleteToolStripMenuItem.Visible = false;
+ }
+ }
+
+ private void copyToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString();
+ if (DirectoryExists(path))
+ {
+ FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) =>
+ {
+ Copy(path, newPath);
+ ResetList();
+ });
+ }
+ else if (FileExists(path))
+ {
+ string[] psplit = path.Split('.');
+ string ext = "." + psplit[psplit.Length - 1];
+ FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) =>
+ {
+ Copy(path, newPath);
+ ResetList();
+ });
+
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
+ private void moveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString();
+ if (DirectoryExists(path))
+ {
+ FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) =>
+ {
+ Utils.Move(path, newPath);
+ ResetList();
+ });
+ }
+ else if (FileExists(path))
+ {
+ string[] psplit = path.Split('.');
+ string ext = psplit[psplit.Length - 1];
+ FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) =>
+ {
+ Utils.Move(path, newPath);
+ ResetList();
+ });
+
+ }
+ }
+ catch
+ {
+
+ }
+
+ }
+
+ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ Infobox.PromptYesNo("Delete file", "Are you sure you want to delete " + lvitems.SelectedItems[0].Text + "?", (result) =>
+ {
+ if (result == true)
+ {
+ Delete(currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString());
+ ResetList();
+ }
+ });
+ }
+ catch { }
+ }
+
+ private void pinToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ Infobox.PromptYesNo("Pin folder", "Are you sure you want to pin \"" + lvitems.SelectedItems[0].Text + "\"?", (result) =>
+ {
+ if (result == true)
+ {
+ if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one")
+ {
+ pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text);
+ ResetList();
+ }
+ else
+ {
+ Infobox.Show("Cannot Pin", "You can only pin files or folders.");
+ }
+
+ }
+ });
+ }
+ 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 { }
+ }
+ }
}