public static List <Package> GetPackages() { packages = new List <Package>(); App.NewPackagesContext(); foreach (string st in Directory.GetFiles(AppPath, "*.csp", SearchOption.AllDirectories)) { if (Path.GetFileName(st).StartsWith(".")) { continue; } Console.WriteLine("Found package:" + st); // Open the package for reading using (ZipArchive archive = ZipFile.OpenRead(st)) { var p = PackageDetails(archive); p.Container = st; var v = RegistryKeeper.GetValue(p.Container); if (v == p.Product.Version) { p.Enabled = true; } if (p.Product.Name != null) { packages.Add(p); } } } return(packages); }
private void FirstRun() { // Check if first run int v = 0; try { v = int.Parse(RegistryKeeper.GetValue("lastversion")); } catch (Exception ex) { Debug.WriteLine(ex.Message); } if (CurrentBuild > v) { Intro iWindow = new Intro(); iWindow.ShowDialog(); RegistryKeeper.UpdateReg("lastversion", CurrentBuild.ToString()); } }
public static void LuaThread() { if (watcher == null) { Watch(); } App.c = Chroma.Instance; App.c.Initialize(); App.c.DeviceAccess += C_DeviceAccess; App.NewScriptsContext(); // WE NEED TO ENSURE CHROMA IS INITIALISED callbacks = new List <dynamic>(); var ms_luaDebug = new LuaStackTraceDebugger(); var ms_luaCompileOptions = new LuaCompileOptions(); ms_luaCompileOptions.DebugEngine = ms_luaDebug; scriptThreads = new Collection <Thread>(); string path = @"%appdata%\ChromaSync"; path = Environment.ExpandEnvironmentVariables(path); string scriptsPath = Path.Combine(path, "scripts"); string packagesPath = Path.Combine(path, "packages"); if (!Directory.Exists(scriptsPath)) { Directory.CreateDirectory(scriptsPath); } // Todo: Get all scripts including the packages var files = Directory.GetFiles(path, "*.lua", SearchOption.AllDirectories); foreach (string st in files) { var v = RegistryKeeper.GetValue(st); MenuItem menuItem = new MenuItem(Path.GetFileName(st)); menuItem.Name = Path.GetFileName(st); menuItem.Tag = st; menuItem.Click += MenuItem_Click; if (!st.Contains("\\ChromaSync\\packages\\")) { App.scriptsMenu.MenuItems.Add(menuItem); } if (v.Equals("True")) { menuItem.Checked = true; scriptThreads.Add( new Thread(() => { using (Lua l = new Lua()) { LuaGlobalPortable g = l.CreateEnvironment(); dynamic dg = g; dg.DebugLua = new Func <object, bool>(debug); dg.ConvertInt = new Func <object, int>(convertInt); dg.NewCustom = new Func <string, Color, object>(newCustom); dg.IntToByte = new Func <int, byte>(IntToByte); dg.Headset = Headset.Instance; dg.Keyboard = Keyboard.Instance; dg.Mouse = Mouse.Instance; dg.Keypad = Keypad.Instance; dg.Mousepad = Mousepad.Instance; dg.RegisterForEvents = new Func <string, object, bool>(registerEvents); debug("starting Lua script: " + st); try { LuaChunk compiled = l.CompileChunk(st, ms_luaCompileOptions); var d = g.DoChunk(compiled); } catch (LuaException e) { App.Log.Error(e); } catch (Exception e) { App.Log.Info(e); Thread.ResetAbort(); } } })); scriptThreads.Last().Start(); } } }