public static async Task <bool> DeleteModuleViaIDAsync(int id) { ModulesDataCache.LoadModulesData(); try { StorageFolder folder_module = await ModulesDataCache.ModulesListFolder.GetFolderAsync(id + ""); await folder_module.DeleteAsync(); ModulesDataCache.ModulesListDeserialized.Modules.Remove(ModulesDataCache.ModulesListDeserialized.Modules.First(m => m.ID == id)); ModulesDataCache.WriteModulesListContentFile(); foreach (CoreApplicationView view in CoreApplication.Views) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new SMSNotification { Type = TypeUpdateModule.ModuleDeleted, ID = id }); }); } return(true); } catch { return(false); } }
public static List <InfosModule> GetSpecificModules(bool GetSystemModules, ModuleTypesList ModuleType) { ModulesDataCache.LoadModulesData(); try { var ModulesList = new List <InfosModule>(); foreach (InfosModule Module in ModulesDataCache.ModulesListDeserialized.Modules) { if (Module.ModuleType == ModuleType) { ModulesList.Add(Module); } } if (GetSystemModules) { foreach (InfosModule Module in SystemModulesList.Modules) { if (Module.ModuleType == ModuleType) { ModulesList.Add(Module); } } } return(ModulesList); } catch { return(null); } }
public static async Task <bool> SetCurrentMonacoThemeIDAsync(int id, bool SendNotification) { ModulesDataCache.LoadModulesData(); try { ModulesDataCache.ModulesListDeserialized.CurrentThemeMonacoID = id; ModulesDataCache.WriteModulesListContentFile(); if (SendNotification) { foreach (CoreApplicationView view in CoreApplication.Views) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new SMSNotification { Type = TypeUpdateModule.CurrentThemeUpdated, ID = id }); }); } } return(true); } catch { return(false); } }
public static async Task <bool> PushUpdateModuleAsync(InfosModule module) { ModulesDataCache.LoadModulesData(); try { InfosModule _module = ModulesDataCache.ModulesListDeserialized.Modules.First(m => m.ID == module.ID); int index_module = ModulesDataCache.ModulesListDeserialized.Modules.IndexOf(_module); ModulesDataCache.ModulesListDeserialized.Modules[index_module] = module; ModulesDataCache.WriteModulesListContentFile(); foreach (CoreApplicationView view in CoreApplication.Views) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new SMSNotification { Type = TypeUpdateModule.UpdateModule, ID = module.ID }); }); } return(true); } catch { return(false); } }
public static async Task <bool> SetCurrentThemeAceEditorTempContentAsync() { ModulesDataCache.LoadModulesData(); try { InfosModule module = ModulesAccessManager.GetModuleViaID(ModulesAccessManager.GetCurrentThemeMonacoID()); StorageFile file_content = await ApplicationData.Current.LocalFolder.CreateFileAsync("themeace_temp.js", CreationCollisionOption.OpenIfExists); await FileIO.WriteTextAsync(file_content, await new ThemeReader(module.ID).GetThemeJSContentAsync()); return(true); } catch { return(false); } }
public static int GetCurrentThemeMonacoID() { ModulesDataCache.LoadModulesData(); try { if (ModulesDataCache.ModulesListDeserialized != null) { return(ModulesDataCache.ModulesListDeserialized.CurrentThemeMonacoID); } else { return(0); } } catch { return(0); } }
public static List <InfosModule> GetModules(bool GetSystemModules) { ModulesDataCache.LoadModulesData(); try { var ModulesList = new List <InfosModule>(ModulesDataCache.ModulesListDeserialized.Modules); if (GetSystemModules) { ModulesList.AddRange(SystemModulesList.Modules); } return(ModulesList); } catch { return(null); } }
public static InfosModule GetModuleViaID(int id) { ModulesDataCache.LoadModulesData(); try { InfosModule module = GetModules(true).Where(m => m.ID == id).FirstOrDefault(); if (module != null) { return(module); } } catch { return(null); } return(null); }
public static string GetCurrentThemeMonacoID() { ModulesDataCache.LoadModulesData(); try { if (ModulesDataCache.ModulesListDeserialized != null) { return(ModulesDataCache.ModulesListDeserialized.CurrentThemeMonacoID); } else { return(SMSInfos.DefaultMonacoThemeID); } } catch { return(SMSInfos.DefaultMonacoThemeID); } }
public static Task <bool> AddModuleAsync(StorageFile module_zip) { ModulesDataCache.LoadModulesData(); return(Task.Run(async() => { int id = new Random().Next(999999); StorageFolder folder_addon = await ModulesDataCache.ModulesListFolder.CreateFolderAsync(id + "", CreationCollisionOption.OpenIfExists); ZipFile.ExtractToDirectory(module_zip.Path, folder_addon.Path); StorageFile file_infos = await folder_addon.CreateFileAsync("infos.json", CreationCollisionOption.OpenIfExists); using (var reader = new StreamReader(await file_infos.OpenStreamForReadAsync())) using (JsonReader JsonReader = new JsonTextReader(reader)) { try { InfosModule content = new JsonSerializer().Deserialize <InfosModule>(JsonReader); if (content != null) { content.ID = id; content.ModuleSystem = false; content.IsEnabled = true; if (await folder_addon.TryGetItemAsync("theme_ace.js") != null) { content.ContainMonacoTheme = true; } else { content.ContainMonacoTheme = false; } switch (content.ModuleType) { case ModuleTypesList.Addon: content.CanBePinnedToToolBar = true; break; case ModuleTypesList.Theme: content.CanBePinnedToToolBar = false; break; case ModuleTypesList.ProgrammingLanguage: content.CanBePinnedToToolBar = false; break; } ModulesDataCache.ModulesListDeserialized.Modules.Add(content); ModulesDataCache.WriteModulesListContentFile(); foreach (CoreApplicationView view in CoreApplication.Views) { await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messenger.Default.Send(new SMSNotification { Type = TypeUpdateModule.NewModule, ID = id }); }); } return true; } } catch { return false; } } return true; })); }