diff options
| author | Michael <[email protected]> | 2017-07-17 14:34:59 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-17 14:34:59 -0400 |
| commit | a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db (patch) | |
| tree | d974220621e6cfcfe745c2825149ca370e3a7aab /ShiftOS.Frontend/Apps | |
| parent | e929a9f5105c00b0a3a2b4e75a876bbb95bbfa7b (diff) | |
| download | shiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.tar.gz shiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.tar.bz2 shiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.zip | |
Hacking, barebones fskimmer, double clicking
Diffstat (limited to 'ShiftOS.Frontend/Apps')
| -rw-r--r-- | ShiftOS.Frontend/Apps/FileSkimmer.cs | 151 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Apps/Terminal.cs | 12 |
2 files changed, 162 insertions, 1 deletions
diff --git a/ShiftOS.Frontend/Apps/FileSkimmer.cs b/ShiftOS.Frontend/Apps/FileSkimmer.cs new file mode 100644 index 0000000..29c5802 --- /dev/null +++ b/ShiftOS.Frontend/Apps/FileSkimmer.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; +using static ShiftOS.Objects.ShiftFS.Utils; + +namespace ShiftOS.Frontend.Apps +{ + [WinOpen("fileskimmer")] + [Launcher("File Skimmer", false, null, "System")] + [DefaultTitle("File Skimmer")] + public class FileSkimmer : GUI.Control, IShiftOSWindow + { + private string _currentdirectory = "0:"; + private const string SD_SYSTEM = "__system"; + private GUI.ListBox _fList = null; + private GUI.TextControl _currentdirtext = null; + + public void OnLoad() + { + Width = 720; + Height = 480; + _fList = new GUI.ListBox(); + _fList.KeyEvent += (e) => + { + if(e.Key == Microsoft.Xna.Framework.Input.Keys.Enter) + { + Navigate(_fList.SelectedItem.ToString()); + } + }; + _fList.DoubleClick += () => + { + try + { + Navigate(_fList.SelectedItem.ToString()); + } + catch { } + }; + AddControl(_fList); + _currentdirtext = new GUI.TextControl(); + _currentdirtext.AutoSize = true; + AddControl(_currentdirtext); + ResetList(); + } + + public void Navigate(string relativepath) + { + if (relativepath == "Up one...") + { + if (_currentdirectory.Contains('/')) + { + int _index = _currentdirectory.LastIndexOf('/'); + int _len = _currentdirectory.Length - _index; + _currentdirectory = _currentdirectory.Remove(_index, _len); + ResetList(); + } + else + { + _currentdirectory = SD_SYSTEM; + ResetList(); + } + return; + } + + string path = ""; + if (_currentdirectory == SD_SYSTEM) + path = relativepath; + else + path = _currentdirectory + "/" + relativepath; + if (DirectoryExists(path)) + { + _currentdirectory = path; + ResetList(); + } + else if (FileExists(path)) + { + if (!FileSkimmerBackend.OpenFile(path)) + { + Engine.Infobox.Show("File Skimmer can't open this file!", "A program that can open files of this type was not found on your computer."); + } + } + } + + public void OnSkinLoad() + { + _currentdirtext.Font = SkinEngine.LoadedSkin.Header3Font; + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + + public void ResetList() + { + if (_currentdirectory == SD_SYSTEM) + _currentdirtext.Text = "My storage drives"; + else + _currentdirtext.Text = _currentdirectory; + + _fList.ClearItems(); + if (_currentdirectory != SD_SYSTEM) + _fList.AddItem("Up one..."); + + if(_currentdirectory == SD_SYSTEM) + { + foreach(var mount in Mounts) + { + _fList.AddItem(Mounts.IndexOf(mount) + ":"); + } + } + else + { + foreach(var dir in GetDirectories(_currentdirectory)) + { + var dinf = GetDirectoryInfo(dir); + _fList.AddItem(dinf.Name); + } + foreach (var dir in GetFiles(_currentdirectory)) + { + var dinf = GetFileInfo(dir); + _fList.AddItem(dinf.Name); + } + + } + InvalidateTopLevel(); + } + + + protected override void OnLayout() + { + try + { + _currentdirtext.Layout(); + _fList.X = 0; + _fList.Y = 0; + _fList.Width = Width; + _fList.Height = Height - _currentdirtext.Height; + _currentdirtext.X = (Width - _currentdirtext.Width) / 2; + _currentdirtext.Y = _fList.Height; + } + catch { } + } + } +} diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs index ea75f3a..6d03a0e 100644 --- a/ShiftOS.Frontend/Apps/Terminal.cs +++ b/ShiftOS.Frontend/Apps/Terminal.cs @@ -262,6 +262,16 @@ namespace ShiftOS.Frontend.Apps Debug.WriteLine("Drunky alert in terminal."); } } + else if(a.Key == Keys.Right) + { + if(Index < Text.Length) + { + Index++; + AppearanceManager.CurrentPosition++; + RecalculateLayout(); + InvalidateTopLevel(); + } + } else if (a.Key == Keys.Left) { if (SaveSystem.CurrentSave != null) @@ -274,7 +284,7 @@ namespace ShiftOS.Frontend.Apps var remstrlen = Text.Length - stringlen; var finalnum = selstart - remstrlen; - if (finalnum != headerlen) + if (finalnum > headerlen) { AppearanceManager.CurrentPosition--; base.OnKeyEvent(a); |
