From e8dfafa17a492bdba99151379d5d4926c267dde5 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Feb 2017 09:05:25 -0500 Subject: ugh more debugging --- ShiftOS.Wpf/Applications/FileDialog.xaml | 29 -- ShiftOS.Wpf/Applications/FileDialog.xaml.cs | 309 -------------------- ShiftOS.Wpf/Applications/FileSkimmer.xaml | 20 -- ShiftOS.Wpf/Applications/FileSkimmer.xaml.cs | 324 --------------------- ShiftOS.Wpf/Applications/Infobox.xaml | 13 - ShiftOS.Wpf/Applications/Infobox.xaml.cs | 87 ------ ShiftOS.Wpf/Applications/MainWindow.xaml | 10 - ShiftOS.Wpf/Applications/MainWindow.xaml.cs | 203 ------------- ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml | 24 -- .../Applications/ShiftoriumFrontend.xaml.cs | 164 ----------- ShiftOS.Wpf/Applications/SkinLoader.xaml | 75 ----- ShiftOS.Wpf/Applications/SkinLoader.xaml.cs | 200 ------------- ShiftOS.Wpf/Applications/TextPad.xaml | 17 -- ShiftOS.Wpf/Applications/TextPad.xaml.cs | 114 -------- 14 files changed, 1589 deletions(-) delete mode 100644 ShiftOS.Wpf/Applications/FileDialog.xaml delete mode 100644 ShiftOS.Wpf/Applications/FileDialog.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/FileSkimmer.xaml delete mode 100644 ShiftOS.Wpf/Applications/FileSkimmer.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/Infobox.xaml delete mode 100644 ShiftOS.Wpf/Applications/Infobox.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/MainWindow.xaml delete mode 100644 ShiftOS.Wpf/Applications/MainWindow.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml delete mode 100644 ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/SkinLoader.xaml delete mode 100644 ShiftOS.Wpf/Applications/SkinLoader.xaml.cs delete mode 100644 ShiftOS.Wpf/Applications/TextPad.xaml delete mode 100644 ShiftOS.Wpf/Applications/TextPad.xaml.cs (limited to 'ShiftOS.Wpf/Applications') diff --git a/ShiftOS.Wpf/Applications/FileDialog.xaml b/ShiftOS.Wpf/Applications/FileDialog.xaml deleted file mode 100644 index bdf3253..0000000 --- a/ShiftOS.Wpf/Applications/FileDialog.xaml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - Filename: - - - - - - - - - - - - - - diff --git a/ShiftOS.Wpf/Applications/FileDialog.xaml.cs b/ShiftOS.Wpf/Applications/FileDialog.xaml.cs deleted file mode 100644 index edeff65..0000000 --- a/ShiftOS.Wpf/Applications/FileDialog.xaml.cs +++ /dev/null @@ -1,309 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.Engine; - -namespace ShiftOS.Wpf.Applications -{ - /// - /// Interaction logic for FileDialog.xaml - /// - public partial class FileDialog : UserControl, IShiftOSWindow - { - public FileDialog(string[] filters, FileOpenerStyle style, Action callback) - { - InitializeComponent(); - Filters = filters; - OpenerStyle = style; - Callback = callback; - } - - public string[] Filters { get; set; } - public FileOpenerStyle OpenerStyle { get; set; } - public Action Callback { get; set; } - - private string currentFolder = "0:"; - - public void OnLoad() - { - Reset(); - foreach(var f in Filters) - { - filter.Items.Add(f); - } - filter.SelectedIndex = 0; - } - - public string GetParent(string path) - { - string[] pathlist = path.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - if (pathlist.Length > 1) - { - if (path.EndsWith("/")) - { - path = path.Remove(path.Length - 1, 1); - } - path = path.Remove(path.LastIndexOf('/'), path.Length - path.LastIndexOf('/')); - return path; - } - else - { - return "__system"; - } - } - - public void Reset() - { - if (currentFolder != "__system") - this.SetTitle("File Skimmer - " + currentFolder); - else - this.SetTitle("File Skimmer"); - - lbfiles.Children.Clear(); - if (currentFolder == "__system") - { - foreach (var dir in Utils.Mounts) - { - var sp = new StackPanel(); - sp.Width = 50; - sp.Margin = new Thickness(5); - var label = new TextBlock(); - label.Text = dir.Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(Utils.Mounts.IndexOf(dir) + ":").ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - ChangeDirectory(Utils.Mounts.IndexOf(dir) + ":"); - } - }; - - lbfiles.Children.Add(sp); - - } - } - else - { - var __up = CreateUpOneDirectory(); - lbfiles.Children.Add(__up); - - foreach (var dir in Utils.GetDirectories(currentFolder)) - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = Utils.GetDirectoryInfo(dir).Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - ChangeDirectory(dir); - } - }; - - lbfiles.Children.Add(sp); - - } - - foreach (var dir in Utils.GetFiles(currentFolder)) - { - if (dir.EndsWith(filter.SelectedItem.ToString())) - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = Utils.GetFileInfo(dir).Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - if(OpenerStyle == FileOpenerStyle.Open) - { - Callback?.Invoke(dir); - AppearanceManager.Close(this); - } - } - else - { - txtfilename.Text = Utils.GetFileInfo(dir).Name; - } - }; - - lbfiles.Children.Add(sp); - } - } - } - } - - public void ChangeDirectory(string path) - { - currentFolder = path; - Reset(); - } - - private StackPanel CreateUpOneDirectory() - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = "Up one directory"; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage("__upone").ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - GoUp(); - } - }; - - return sp; - } - - public void GoUp() - { - if (currentFolder.EndsWith(":")) - { - currentFolder = "__system"; - Reset(); - } - else - { - currentFolder = GetParent(currentFolder); - Reset(); - } - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - - } - - - private void btnconfirm_Click(object sender, RoutedEventArgs e) - { - if (!string.IsNullOrWhiteSpace(txtfilename.Text)) - { - if (!txtfilename.Text.EndsWith(filter.SelectedItem.ToString())) - txtfilename.Text += filter.SelectedItem.ToString(); - - switch (OpenerStyle) - { - case FileOpenerStyle.Open: - if(Utils.FileExists(currentFolder + "/" + txtfilename.Text)) - { - Callback?.Invoke(currentFolder + "/" + txtfilename.Text); - AppearanceManager.Close(this); - } - else - { - Infobox.Show("File not found", $"The file {currentFolder}/{txtfilename.Text} was not found."); - } - break; - case FileOpenerStyle.Save: - Callback?.Invoke(currentFolder + "/" + txtfilename.Text); - AppearanceManager.Close(this); - break; - } - } - else - { - Infobox.Show("File Skimmer", "Please provide a filename."); - } - } - - private void filter_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - Reset(); - } - } -} diff --git a/ShiftOS.Wpf/Applications/FileSkimmer.xaml b/ShiftOS.Wpf/Applications/FileSkimmer.xaml deleted file mode 100644 index ae4f435..0000000 --- a/ShiftOS.Wpf/Applications/FileSkimmer.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/ShiftOS.Wpf/Applications/FileSkimmer.xaml.cs b/ShiftOS.Wpf/Applications/FileSkimmer.xaml.cs deleted file mode 100644 index 51021c0..0000000 --- a/ShiftOS.Wpf/Applications/FileSkimmer.xaml.cs +++ /dev/null @@ -1,324 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.Engine; - -namespace ShiftOS.Wpf.Applications -{ - /// - /// Interaction logic for FileSkimmer.xaml - /// - [Launcher("File Skimmer", true, "al_file_skimmer")] - [RequiresUpgrade("file_skimmer")] - public partial class FileSkimmer : UserControl, IShiftOSWindow - { - public FileSkimmer() - { - InitializeComponent(); - } - - private string currentFolder = "0:"; - - static FileSkimmer() - { - FileSkimmerBackend.Init(new WpfFSFrontend()); - } - - public void OnLoad() - { - Reset(); - } - - public string GetParent(string path) - { - string[] pathlist = path.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - if (pathlist.Length > 1) - { - if (path.EndsWith("/")) - { - path = path.Remove(path.Length - 1, 1); - } - path = path.Remove(path.LastIndexOf('/'), path.Length - path.LastIndexOf('/')); - return path; - } - else - { - return "__system"; - } - } - - public void Reset() - { - if (currentFolder != "__system") - this.SetTitle("File Skimmer - " + currentFolder); - else - this.SetTitle("File Skimmer"); - - lbfiles.Children.Clear(); - if (currentFolder == "__system") - { - foreach(var dir in Utils.Mounts) - { - var sp = new StackPanel(); - sp.Width = 50; - sp.Margin = new Thickness(5); - var label = new TextBlock(); - label.Text = dir.Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(Utils.Mounts.IndexOf(dir) + ":").ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - ChangeDirectory(Utils.Mounts.IndexOf(dir) + ":"); - } - }; - - lbfiles.Children.Add(sp); - - } - } - else - { - var __up = CreateUpOneDirectory(); - lbfiles.Children.Add(__up); - - foreach(var dir in Utils.GetDirectories(currentFolder)) - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = Utils.GetDirectoryInfo(dir).Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - ChangeDirectory(dir); - } - }; - - lbfiles.Children.Add(sp); - - } - - foreach(var dir in Utils.GetFiles(currentFolder)) - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = Utils.GetFileInfo(dir).Name; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage(dir).ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if (a.ClickCount == 2) - { - FileSkimmerBackend.OpenFile(dir); - } - }; - - lbfiles.Children.Add(sp); - - } - } - } - - public void ChangeDirectory(string path) - { - currentFolder = path; - Reset(); - } - - private StackPanel CreateUpOneDirectory() - { - var sp = new StackPanel(); - sp.Margin = new Thickness(5); - sp.Width = 50; - var label = new TextBlock(); - label.Text = "Up one directory"; - label.TextWrapping = TextWrapping.Wrap; - label.TextAlignment = TextAlignment.Center; - - var img = new Image(); - img.Width = 42; - img.Height = 42; - img.Source = FileSkimmerBackend.GetImage("__upone").ToBitmapImage(); - - sp.Children.Add(img); - sp.Children.Add(label); - - sp.PreviewMouseLeftButtonDown += (o, a) => - { - if(a.ClickCount == 2) - { - GoUp(); - } - }; - - return sp; - } - - public void GoUp() - { - if (currentFolder.EndsWith(":")) - { - currentFolder = "__system"; - Reset(); - } - else - { - currentFolder = GetParent(currentFolder); - Reset(); - } - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - - } - } - - public class WpfFSFrontend : IFileSkimmer - { - public void GetPath(string[] filetypes, FileOpenerStyle style, Action callback) - { - AppearanceManager.SetupDialog(new FileDialog(filetypes, style, callback)); - } - - public void OpenDirectory(string path) - { - var fs = new FileSkimmer(); - fs.ChangeDirectory(path); - AppearanceManager.SetupWindow(fs); - } - - public void OpenFile(string path) - { - bool opened = true; - - string ext = path.Split('.')[path.Split('.').Length - 1]; - switch(ext) - { - case "txt": - if (Shiftorium.UpgradeInstalled("textpad_open")) - { - var txt = new TextPad(); - txt.LoadFile(path); - AppearanceManager.SetupWindow(txt); - } - else - { - opened = false; - } - break; - case "pic": - case "png": - case "jpg": - case "bmp": - - break; - case "wav": - case "mp3": - - break; - case "lua": - - break; - case "py": - - break; - case "skn": - - break; - case "mfs": - Utils.MountPersistent(path); - string mount = (Utils.Mounts.Count - 1).ToString() + ":"; - OpenDirectory(mount); - break; - default: - opened = false; - break; - } - if(opened == false) - { - Infobox.Show("File Skimmer - Can't open file", "File Skimmer can't find an application to open this file!"); - } - } - } -} diff --git a/ShiftOS.Wpf/Applications/Infobox.xaml b/ShiftOS.Wpf/Applications/Infobox.xaml deleted file mode 100644 index e2ad454..0000000 --- a/ShiftOS.Wpf/Applications/Infobox.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - Message goes here. - - - diff --git a/ShiftOS.Wpf/Applications/Infobox.xaml.cs b/ShiftOS.Wpf/Applications/Infobox.xaml.cs deleted file mode 100644 index 1786f6e..0000000 --- a/ShiftOS.Wpf/Applications/Infobox.xaml.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Engine; - -namespace ShiftOS.Wpf.Applications -{ - /// - /// Interaction logic for Infobox.xaml - /// - public partial class Infobox : UserControl, IShiftOSWindow - { - public Infobox(string title, string msg) - { - InitializeComponent(); - Title = title; - Message = msg; - } - - public static void Show(string title, string msg) - { - ShiftOS.Engine.Infobox.Show(title, msg); - } - - public string Title { get; set; } - public string Message { get; set; } - - public void OnLoad() - { - this.SetTitle(Title); - txtmessage.Text = Message; - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - private void btnokay_Click(object sender, RoutedEventArgs e) - { - AppearanceManager.Close(this); - } - } -} diff --git a/ShiftOS.Wpf/Applications/MainWindow.xaml b/ShiftOS.Wpf/Applications/MainWindow.xaml deleted file mode 100644 index 22b992f..0000000 --- a/ShiftOS.Wpf/Applications/MainWindow.xaml +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/ShiftOS.Wpf/Applications/MainWindow.xaml.cs b/ShiftOS.Wpf/Applications/MainWindow.xaml.cs deleted file mode 100644 index c76acec..0000000 --- a/ShiftOS.Wpf/Applications/MainWindow.xaml.cs +++ /dev/null @@ -1,203 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Engine; -using backend = ShiftOS.Engine.TerminalBackend; - -namespace ShiftOS.Wpf -{ - /// - /// Interaction logic for MainWindow.xaml - /// - [Launcher("Terminal", false)] - public partial class Terminal : UserControl, IShiftOSWindow - { - public Terminal() - { - InitializeComponent(); - Startup.ConsoleOut = this.txtterm; - - if (SaveSystem.CurrentSave == null) - { - Startup.InitiateEngine(new WpfTerminalTextWriter()); - SaveSystem.GameReady += () => - { - try - { - Dispatcher.Invoke(new Action(() => - { - txtterm.Text = ""; - backend.PrefixEnabled = true; - backend.InStory = false; - if (SaveSystem.CurrentSave.StoryPosition != 8) - { - Story.RunFromInternalResource("sys_shiftoriumstory"); - SaveSystem.CurrentSave.StoryPosition = 8; - } - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - txtterm.Background = SkinEngine.LoadedSkin.TerminalBackColor.CreateBrush(); - txtterm.Foreground = SkinEngine.LoadedSkin.TerminalForeColor.CreateBrush(); - txtterm.SetFont(SkinEngine.LoadedSkin.TerminalFont); - })); - } - catch { } - }; - } - else - { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - } - txtterm.Background = SkinEngine.LoadedSkin.TerminalBackColor.CreateBrush(); - txtterm.Foreground = SkinEngine.LoadedSkin.TerminalForeColor.CreateBrush(); - - txtterm.GotFocus += (o, a) => - { - Startup.ConsoleOut = txtterm; - }; - - txtterm.Focus(); - - } - - public void OnLoad() - { - this.SetTitle("Terminal"); - } - - public void OnSkinLoad() - { - txtterm.SetFont(SkinEngine.LoadedSkin.TerminalFont); - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - public void txtterm_KeyDown(object o, KeyEventArgs a) { - if (a.Key == Key.Enter) - { - try - { - a.Handled = true; - var text2 = txtterm.GetLineText(txtterm.LineCount - 1); - Console.WriteLine(""); - var text3 = ""; - var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); - - if (backend.PrefixEnabled) - { - text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); - } - backend.LastCommand = text3; - if (backend.InStory == false) - { - backend.InvokeCommand(text3); - } - if (backend.PrefixEnabled) - { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - } - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - } - else if (a.Key == Key.Back) - { - var tostring3 = txtterm.GetLineText(txtterm.LineCount - 1); - var tostringlen = tostring3.Length + 1; - var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; - var derp = workaround.Length + 1; - if (tostringlen != derp) - { - AppearanceManager.CurrentPosition--; - } - else - { - a.Handled = true; - } - } - else if (a.Key == Key.Left) - { - var getstring = txtterm.GetLineText(txtterm.LineCount - 1); - var stringlen = getstring.Length + 1; - var header = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; - var headerlen = header.Length + 1; - var selstart = txtterm.SelectionStart; - var remstrlen = txtterm.Text.Length - stringlen; - var finalnum = selstart - remstrlen; - - if (finalnum != headerlen) - { - AppearanceManager.CurrentPosition--; - } - else - { - a.Handled = true; - } - } - //( ͡° ͜ʖ ͡° ) You found the lennyface without looking at the commit message. Message Michael in the #shiftos channel on Discord saying "ladouceur" somewhere in your message if you see this. - else if (a.Key == Key.Up) - { - var tostring3 = txtterm.GetLineText(txtterm.LineCount - 1); - if (tostring3 == $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") - Console.Write(backend.LastCommand); - a.Handled = true; - - } - else - { - - AppearanceManager.CurrentPosition++; - } - - } - - private void txtterm_GotFocus(object sender, RoutedEventArgs e) - { - Startup.ConsoleOut = txtterm; - } - } -} diff --git a/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml b/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml deleted file mode 100644 index f2d0df1..0000000 --- a/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml +++ /dev/null @@ -1,24 +0,0 @@ - - - - Upgrades - Codepoints: 0 - - - - - - - Cost: {Binding Cost} CP - - {Binding Description} - - - diff --git a/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml.cs b/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml.cs deleted file mode 100644 index 8effa7c..0000000 --- a/ShiftOS.Wpf/Applications/ShiftoriumFrontend.xaml.cs +++ /dev/null @@ -1,164 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Timers; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Engine; - -namespace ShiftOS.Wpf.Applications -{ - /// - /// Interaction logic for ShiftoriumFrontend.xaml - /// - [Launcher("Shiftorium", true, "al_shiftorium")] - [RequiresUpgrade("shiftorium_gui")] - public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow - { - public ShiftoriumFrontend() - { - InitializeComponent(); - this.DataContextChanged += (o, a) => - { - if (this.DataContext is ShiftoriumUpgrade) - { - var upg = this.DataContext as ShiftoriumUpgrade; - title.Text = upg.Name; - this.SetTitle("Shiftorium - " + upg.Name); - description.Text = upg.Description; - cost.Text = upg.Cost.ToString(); - } - }; - this.DataContext = new ShiftoriumUpgrade - { - Name = "Welcome to the Shiftorium", - Description = @"The Shiftorium is an application that lets you buy upgrades for ShiftOS using Codepoints. - -Upgrades can be anything from new apps, to games, to system enhancements, to eyecandy, to anything else. Just be careful! The best thing to do is to buy new ways of earning Codepoints otherwise you'll find yourself unable to earn Codepoints later on.", - Cost = 0, - Dependencies = null - }; - } - - public void Setup() - { - lbupgrades.Items.Clear(); - - foreach(var itm in Shiftorium.GetAvailable()) - { - lbupgrades.Items.Add(itm.Name); - } - } - - public void OnLoad() - { - this.SetTitle("Shiftorium"); - var t = new Timer(); - t.Interval = 500; - t.Elapsed += (o,a) => - { - try - { - currentcodepoints.Text = SaveSystem.CurrentSave.Codepoints.ToString(); - } - catch { t.Stop(); } - - }; - t.Start(); - - lbupgrades.SelectionChanged += (o, a) => - { - try - { - btnbuy.Visibility = Visibility.Visible; - this.DataContext = GetUpgradeFromName(lbupgrades.SelectedItem.ToString()); - } - catch - { - - } - }; - - btnbuy.Visibility = Visibility.Collapsed; - Setup(); - } - - public ShiftoriumUpgrade GetUpgradeFromName(string upg) - { - foreach(var upgrade in Shiftorium.GetDefaults()) - { - if (upgrade.Name == upg) - return upgrade; - } - return null; - } - - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - codepointDisplay.Upgrade("shiftorium_gui_cp_display"); - } - - private void lbupgrades_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - - } - - private void btnbuy_Click_1(object sender, RoutedEventArgs e) - { - var upg = this.DataContext as ShiftoriumUpgrade; - Shiftorium.Silent = true; - if(Shiftorium.Buy(upg.ID, upg.Cost) == true) - { - btnbuy.Visibility = Visibility.Collapsed; - Setup(); - } - else - { - Infobox.Show("Shiftorium", $"You do not have enough Codepoints to buy this upgrade. You need {upg.Cost - SaveSystem.CurrentSave.Codepoints} more."); - } - } - } -} diff --git a/ShiftOS.Wpf/Applications/SkinLoader.xaml b/ShiftOS.Wpf/Applications/SkinLoader.xaml deleted file mode 100644 index 48b0f6d..0000000 --- a/ShiftOS.Wpf/Applications/SkinLoader.xaml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Template - - - - - - - - diff --git a/ShiftOS.Wpf/Applications/TextPad.xaml.cs b/ShiftOS.Wpf/Applications/TextPad.xaml.cs deleted file mode 100644 index 3438906..0000000 --- a/ShiftOS.Wpf/Applications/TextPad.xaml.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.Engine; - -namespace ShiftOS.Wpf.Applications -{ - /// - /// Interaction logic for TextPad.xaml - /// - [Launcher("TextPad", true, "al_textpad")] - [RequiresUpgrade("textpad")] - public partial class TextPad : UserControl, IShiftOSWindow - { - public TextPad() - { - InitializeComponent(); - } - - private void btnnew_Click(object sender, RoutedEventArgs e) - { - txtbody.Text = ""; - } - - private void btnsave_Click(object sender, RoutedEventArgs e) - { - string filters = ".txt"; - if (Shiftorium.UpgradeInstalled("textpad_lua_support")) - filters += ";.lua"; - if (Shiftorium.UpgradeInstalled("textpad_python_support")) - filters += ";.py"; - - FileSkimmerBackend.GetFile(filters.Split(';'), FileOpenerStyle.Save, new Action((file) => SaveFile(file))); - } - - private void btnopen_Click(object sender, RoutedEventArgs e) - { - string filters = ".txt"; - if (Shiftorium.UpgradeInstalled("textpad_lua_support")) - filters += ";.lua"; - if (Shiftorium.UpgradeInstalled("textpad_python_support")) - filters += ";.py"; - - FileSkimmerBackend.GetFile(filters.Split(';'), FileOpenerStyle.Open, new Action((file) => LoadFile(file))); - - } - - public void LoadFile(string path) - { - txtbody.Text = Utils.ReadAllText(path); - } - - public void SaveFile(string path) - { - Utils.WriteAllText(path, txtbody.Text); - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { -/* btnnew.Upgrade("textpad_new"); - btnopen.Upgrade("textpad_open"); - btnsave.Upgrade("textpad_save"); -*/ } - } -} -- cgit v1.2.3