diff options
| author | AShifter <[email protected]> | 2017-11-17 20:29:46 -0700 |
|---|---|---|
| committer | AShifter <[email protected]> | 2017-11-17 20:29:46 -0700 |
| commit | ebdc09fe679b4b06fd149c8fc6539244100ce896 (patch) | |
| tree | 65dfe45bbfd194ddb534cc80107ab8e6d80cf5bc /ShiftOS.Engine/ShiftFS/ShiftFile.cs | |
| parent | 1d0b393e6969d9671daead8049973a374421046f (diff) | |
| parent | 97722fbe9d474adffbba0b92e9727c48a8205234 (diff) | |
| download | shiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.tar.gz shiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.tar.bz2 shiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.zip | |
Merge remote-tracking branch 'refs/remotes/ShiftOS-Rewind/master'
Diffstat (limited to 'ShiftOS.Engine/ShiftFS/ShiftFile.cs')
| -rw-r--r-- | ShiftOS.Engine/ShiftFS/ShiftFile.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ShiftOS.Engine/ShiftFS/ShiftFile.cs b/ShiftOS.Engine/ShiftFS/ShiftFile.cs new file mode 100644 index 0000000..c8a8ef4 --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftFile.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using Whoa; + +namespace ShiftOS.Engine.ShiftFS +{ + [Serializable] + public class ShiftFile<T> : ShiftFile + { + public ShiftFile(string name) => Name = name; + public ShiftFile(string name, ShiftDirectory directory) + { + Name = name; + Parent = directory; + } + public ShiftFile(string name, T @object, ShiftDirectory directory) + { + Name = name; + Object = @object; + Parent = directory; + } + public ShiftFile(string name, T @object, ShiftDirectory directory, Bitmap icon) + { + Name = name; + Object = @object; + Parent = directory; + Icon = icon; + } + public ShiftFile(string name, T @object) + { + Name = name; + Object = @object; + } + public ShiftFile(string name, T @object, Bitmap icon) + { + Name = name; + Object = @object; + Icon = icon; + } + + + + public T Object { get; set; } + } + + [Serializable] + public abstract class ShiftFile : IShiftNode + { + public Bitmap Icon { get; set; } + + public string Name { get; set; } + + public string FullName + { + get + { + var list = new List<string> { Name }; + var currentNode = Parent; + while (currentNode?.Parent != null) + { + list.Add(currentNode.Name); + currentNode = currentNode.Parent; + } + + return Path.Combine(list.Reverse<string>().ToArray()) + "\\"; + } + } + + public ShiftDirectory Parent + { + get => Drive.FlattenFolders().FirstOrDefault(x => x.Contains(this)); + set + { + value.Add(this); + Parent?.Remove(this); + } + } + + public ShiftTree Drive => ShiftFS.Drives.First(d => d.FlattenFolders().FirstOrDefault(f => f.Contains(this)) != null); + + + public Guid Guid { get; } = Guid.NewGuid(); + + } +}
\ No newline at end of file |
