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 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 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; })); }