Esempio n. 1
0
        public void OpenFile(string path)
        {
            try
            {
                switch (FileSkimmerBackend.GetFileType(path))
                {
                case FileType.TextFile:
                    if (!Shiftorium.UpgradeInstalled("textpad"))
                    {
                        throw new Exception();
                    }

                    var txt = new TextPad();
                    AppearanceManager.SetupWindow(txt);
                    txt.LoadFile(path);
                    break;

                case FileType.Executable:
                    //NYI
                    throw new Exception();

                case FileType.Lua:
                    try
                    {
                        var runner = new Engine.Scripting.LuaInterpreter();
                        runner.ExecuteFile(path);
                    }
                    catch (Exception ex)
                    {
                        Infobox.Show("{LUA_ERROR}", ex.Message);
                    }
                    break;

                case FileType.JSON:
                    //NYI
                    throw new Exception();

                case FileType.Filesystem:
                    MountPersistent(path);
                    //If this doesn't fail...
                    FileSkimmerBackend.OpenDirectory((Mounts.Count - 1).ToString() + ":");
                    break;

                case FileType.Skin:
                    if (!Shiftorium.UpgradeInstalled("skinning"))
                    {
                        throw new Exception();
                    }

                    var sl = new Skin_Loader();
                    AppearanceManager.SetupWindow(sl);
                    sl.LoadedSkin = JsonConvert.DeserializeObject <Skin>(ReadAllText(path));
                    sl.SetupUI();
                    break;

                case FileType.Image:
                    if (!Shiftorium.UpgradeInstalled("artpad_open"))
                    {
                        throw new Exception();
                    }

                    var ap = new Artpad();
                    AppearanceManager.SetupWindow(ap);
                    ap.LoadPicture(path);
                    break;

                default:
                    throw new Exception();
                }
            }
            catch
            {
                Infobox.Show("{NO_APP_TO_OPEN}", "{NO_APP_TO_OPEN_EXP}");
            }
        }