mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Slight... very slight... fileskimmer mods
This commit is contained in:
parent
cd2190f6ca
commit
00cd41ea92
11 changed files with 139 additions and 16 deletions
|
@ -42,13 +42,17 @@ using System.Diagnostics;
|
|||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
[FileHandler("Artpad Picture", ".pic", "fileiconpicture")]
|
||||
[FileHandler("JPEG Picture", ".jpg", "fileiconpicture")]
|
||||
[FileHandler("PNG Picture", ".png", "fileiconpicture")]
|
||||
[FileHandler("Bitmap Picture", ".bmp", "fileiconpicture")]
|
||||
[MultiplayerOnly]
|
||||
[Launcher("{TIITLE_ARTPAD}", true, "al_artpad", "{AL_GRAPHICS}")]
|
||||
[RequiresUpgrade("artpad")]
|
||||
[WinOpen("{WO_ARTPAD}")]
|
||||
[DefaultIcon("iconArtpad")]
|
||||
[DefaultTitle("{TITLE_ARTPAD}")]
|
||||
public partial class Artpad : UserControl, IShiftOSWindow
|
||||
public partial class Artpad : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// artpad_'s GUI.
|
||||
|
@ -1589,6 +1593,12 @@ namespace ShiftOS.WinForms.Applications
|
|||
setmagnification();
|
||||
|
||||
}
|
||||
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
AppearanceManager.SetupWindow(this);
|
||||
LoadPicture(file);
|
||||
}
|
||||
}
|
||||
|
||||
public class undo
|
||||
|
|
|
@ -19,7 +19,8 @@ namespace ShiftOS.WinForms.Applications
|
|||
[MultiplayerOnly]
|
||||
[DefaultTitle("{TITLE_INSTALLER}")]
|
||||
[Launcher("{TITLE_INSTALLER}", true, "al_installer", "{AL_UTILITIES}")]
|
||||
public partial class Installer : UserControl, IShiftOSWindow
|
||||
[FileHandler("Name Pack", ".names", "fileiconnames")]
|
||||
public partial class Installer : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
public Installer()
|
||||
{
|
||||
|
@ -27,6 +28,13 @@ namespace ShiftOS.WinForms.Applications
|
|||
lbtitle.Text = "Select file";
|
||||
}
|
||||
|
||||
public void OpenFile(string path)
|
||||
{
|
||||
var stpInstall = new StpInstallation(path);
|
||||
AppearanceManager.SetupWindow(this);
|
||||
InitiateInstall(stpInstall);
|
||||
}
|
||||
|
||||
public void InitiateInstall(Installation install)
|
||||
{
|
||||
pnlselectfile.Hide();
|
||||
|
|
|
@ -37,20 +37,27 @@ using ShiftOS.Objects.ShiftFS;
|
|||
using ShiftOS.WinForms.Tools;
|
||||
|
||||
namespace ShiftOS.WinForms.Applications {
|
||||
|
||||
[FileHandler("Name Pack", ".nme", "fileiconnames")]
|
||||
[MultiplayerOnly]
|
||||
[Launcher("{TITLE_NAMECHANGER}", false, null, "{AL_CUSTOMIZATION}")]
|
||||
[AppscapeEntry("name_changer", "{TITLE_NAMECHANGER}", "{DESC_NAMECHANGER}", 342, 500, "skinning;file_skimmer;wm_titlebar", "{AL_CUSTOMIZATION}")]
|
||||
[WinOpen("{WO_NAMECHANGER}")]
|
||||
[DefaultTitle("{TITLE_NAMECHANGER}")]
|
||||
[DefaultIcon("iconNameChanger")]
|
||||
public partial class NameChanger : UserControl, IShiftOSWindow
|
||||
public partial class NameChanger : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
public NameChanger()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
AppearanceManager.SetupWindow(this);
|
||||
names = JsonConvert.DeserializeObject<Dictionary<string, string>>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(file));
|
||||
SetupUI();
|
||||
}
|
||||
|
||||
private Dictionary<string, string> names = new Dictionary<string, string>();
|
||||
|
||||
public void OnLoad()
|
||||
|
|
|
@ -37,12 +37,13 @@ using ShiftOS.WinForms.Tools;
|
|||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
[FileHandler("ShiftOS Skin", ".skn", "fileiconskin")]
|
||||
[Launcher("{TITLE_SKINLOADER}", true, "al_skin_loader", "{AL_CUSTOMIZATION}")]
|
||||
[RequiresUpgrade("skinning")]
|
||||
[WinOpen("skin_loader")]
|
||||
[DefaultTitle("{TITLE_SKINLOADER}")]
|
||||
[DefaultIcon("iconSkinLoader")]
|
||||
public partial class Skin_Loader : UserControl, IShiftOSWindow
|
||||
public partial class Skin_Loader : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
public Skin_Loader()
|
||||
{
|
||||
|
@ -54,6 +55,13 @@ namespace ShiftOS.WinForms.Applications
|
|||
|
||||
}
|
||||
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
AppearanceManager.SetupWindow(this);
|
||||
LoadedSkin = JsonConvert.DeserializeObject<Skin>(Objects.ShiftFS.Utils.ReadAllText(file));
|
||||
SetupUI();
|
||||
}
|
||||
|
||||
public void SetupControls(Control ctrl)
|
||||
{
|
||||
ctrl.Tag = "keepbg keepfg keepfont";
|
||||
|
|
|
@ -47,12 +47,51 @@ using ShiftOS.WinForms.Tools;
|
|||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
[FileHandler("Shell script", ".trm", "fileicontrm")]
|
||||
[Launcher("{TITLE_TERMINAL}", false, null, "{AL_UTILITIES}")]
|
||||
[WinOpen("{WO_TERMINAL}")]
|
||||
[DefaultTitle("{TITLE_TERMINAL}")]
|
||||
[DefaultIcon("iconTerminal")]
|
||||
public partial class Terminal : UserControl, IShiftOSWindow
|
||||
public partial class Terminal : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
int lastline = 0;
|
||||
string lastlinetext = "";
|
||||
|
||||
try
|
||||
{
|
||||
var lines = new List<string>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(file).Split(new[] { Environment.NewLine.ToString() }, StringSplitOptions.RemoveEmptyEntries));
|
||||
AppearanceManager.SetupWindow(this);
|
||||
var parser = CommandParser.GenerateSample();
|
||||
foreach (var line in lines)
|
||||
{
|
||||
lastline = lines.IndexOf(line) + 1;
|
||||
lastlinetext = line;
|
||||
var command = parser.ParseCommand(line);
|
||||
TerminalBackend.InvokeCommand(command.Key, command.Value);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Red;
|
||||
ConsoleEx.Bold = true;
|
||||
Console.WriteLine("Script exception");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Yellow;
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.Italic = true;
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex.Message);
|
||||
#endif
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
if(lastline > 0)
|
||||
{
|
||||
Console.WriteLine(" at " + lastlinetext + " (line " + lastline + ") in " + file);
|
||||
}
|
||||
}
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
|
||||
public static Stack<string> ConsoleStack = new Stack<string>();
|
||||
|
||||
public static System.Windows.Forms.Timer ti = new System.Windows.Forms.Timer();
|
||||
|
|
|
@ -36,18 +36,25 @@ using ShiftOS.Engine;
|
|||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
[FileHandler("Text File", ".txt", "fileicontext")]
|
||||
[Launcher("{TITLE_TEXTPAD}", true, "al_textpad", "{AL_ACCESSORIES}")]
|
||||
[RequiresUpgrade("textpad")]
|
||||
[WinOpen("{WO_TEXTPAD}")]
|
||||
[DefaultTitle("{TITLE_TEXTPAD}")]
|
||||
[DefaultIcon("iconTextPad")]
|
||||
public partial class TextPad : UserControl, IShiftOSWindow
|
||||
public partial class TextPad : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
public TextPad()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
AppearanceManager.SetupWindow(this);
|
||||
LoadFile(file);
|
||||
}
|
||||
|
||||
private void newToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtcontents.Text = "";
|
||||
|
|
|
@ -12,11 +12,12 @@ using ShiftOS.Engine;
|
|||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
[FileHandler("TriWrite Document", ".rtf", "fileicontext")]
|
||||
[WinOpen("triwrite")]
|
||||
[AppscapeEntry("triwrite", "TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, "file_skimmer;textpad", "Office")]
|
||||
[DefaultTitle("TriWrite")]
|
||||
[Launcher("TriWrite", false, null, "Office")]
|
||||
public partial class TriWrite : UserControl, IShiftOSWindow
|
||||
public partial class TriWrite : UserControl, IShiftOSWindow, IFileHandler
|
||||
{
|
||||
|
||||
public TriWrite()
|
||||
|
@ -24,6 +25,12 @@ namespace ShiftOS.WinForms.Applications
|
|||
InitializeComponent(); //From the library of babel: "FIRST COMMIT FROM A MAC WOOOO TURIANS ARE COOL"
|
||||
}
|
||||
|
||||
public void OpenFile(string file)
|
||||
{
|
||||
AppearanceManager.SetupWindow(this);
|
||||
LoadFile(file);
|
||||
}
|
||||
|
||||
private void newToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtcontents.Text = "";
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
}
|
||||
|
||||
internal static CommandParser GenerateSample()
|
||||
public static CommandParser GenerateSample()
|
||||
{
|
||||
var parser = new CommandParser();
|
||||
parser.AddPart(new CommandFormatCommand());
|
||||
|
|
|
@ -46,14 +46,20 @@ namespace ShiftOS.Engine
|
|||
/// <param name="path">The path to open.</param>
|
||||
public static void OpenFile(string path)
|
||||
{
|
||||
_fs.OpenFile(path);
|
||||
if (!Objects.ShiftFS.Utils.FileExists(path))
|
||||
throw new System.IO.FileNotFoundException("ShiftFS could not find the file specified.", path);
|
||||
foreach (var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IFileHandler)) && Shiftorium.UpgradeAttributesUnlocked(x)))
|
||||
{
|
||||
foreach(FileHandlerAttribute attrib in type.GetCustomAttributes(false).Where(x => x is FileHandlerAttribute))
|
||||
{
|
||||
if (path.ToLower().EndsWith(attrib.Extension))
|
||||
{
|
||||
var obj = (IFileHandler)Activator.CreateInstance(type);
|
||||
obj.OpenFile(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file type of a given path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to check</param>
|
||||
/// <returns>The FileType of the path</returns>
|
||||
public static FileType GetFileType(string path)
|
||||
{
|
||||
|
||||
|
|
30
ShiftOS_TheReturn/IFileHandler.cs
Normal file
30
ShiftOS_TheReturn/IFileHandler.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShiftOS.Engine
|
||||
{
|
||||
public interface IFileHandler
|
||||
{
|
||||
void OpenFile(string file);
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class FileHandlerAttribute : Attribute
|
||||
{
|
||||
public FileHandlerAttribute(string name, string extension, string iconid)
|
||||
{
|
||||
Name = name;
|
||||
Extension = extension;
|
||||
IconID = iconid;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Extension { get; set; }
|
||||
public string IconID { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +132,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Desktop.cs" />
|
||||
<Compile Include="FileSkimmerBackend.cs" />
|
||||
<Compile Include="IFileHandler.cs" />
|
||||
<Compile Include="Infobox.cs" />
|
||||
<Compile Include="IShiftOSWindow.cs" />
|
||||
<Compile Include="IStatusIcon.cs" />
|
||||
|
|
Loading…
Reference in a new issue