/* =============
         * = FUNCTIONS =
         * =============
         */



        public void LoadPage(string path, int id)
        {
            if (!isLoaded)
            {
                html_view = new WebView(WebViewExecutionMode.SeparateThread);
                html_view.NavigationStarting += Html_view_NavigationStarting;
                html_view.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Visible);
                MasterGrid.Children.Insert(0, html_view);

                isLoaded = true;
            }

            if (!string.IsNullOrEmpty(path))
            {
                current_id = id;

                InfosModule ModuleAccess = ModulesAccessManager.GetModuleViaID(id);

                if (ModuleAccess.ModuleSystem)
                {
                    html_view.Navigate(new Uri("ms-appx-web:///SerrisModulesServer/SystemModules/Addons/" + id + "/" + path));
                }
                else
                {
                    html_view.Navigate(new Uri("ms-appdata:///local/modules/" + id + "/" + path));
                    Debug.WriteLine("ms-appdata:///local/modules/" + id + "/" + path);
                }
            }
        }
示例#2
0
        public static async Task <bool> PushUpdateModuleAsync(InfosModule module)
        {
            using (var reader = new StreamReader(await file.OpenStreamForReadAsync()))
                using (JsonReader JsonReader = new JsonTextReader(reader))
                {
                    try
                    {
                        ModulesList list         = new JsonSerializer().Deserialize <ModulesList>(JsonReader);
                        InfosModule _module      = list.Modules.First(m => m.ID == module.ID);
                        int         index_module = list.Modules.IndexOf(_module);

                        list.Modules[index_module] = module;

                        await FileIO.WriteTextAsync(file, JsonConvert.SerializeObject(list, Formatting.Indented));

                        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);
                    }
                }
        }
        private async void OpenModuleButton_Click(object sender, RoutedEventArgs e)
        {
            var opener = new FileOpenPicker();

            opener.ViewMode = PickerViewMode.Thumbnail;
            opener.SuggestedStartLocation = PickerLocationId.Downloads;
            opener.FileTypeFilter.Add(".zip");
            opener.FileTypeFilter.Add(".scea");

            StorageFile Module = await opener.PickSingleFileAsync();

            if (Module != null)
            {
                ModuleFile = Module;
                StorageApplicationPermissions.FutureAccessList.Add(Module);

                //ModuleFile = await Module.CopyAsync(ApplicationData.Current.TemporaryFolder);
                VerifyAssistant = new ModulesVerifyAssistant(Module);

                //Get package infos and show them !
                InfosModule infos = await VerifyAssistant.GetPackageInfosAsync();

                TitleModule.Text     = infos.ModuleName;
                AuthorName.Text      = infos.ModuleAuthor;
                DescriptionText.Text = infos.ModuleDescription;
                ModuleType.Text      = infos.ModuleType.ToString();
                VersionNumber.Text   = infos.ModuleVersion.GetVersionInString();

                SelectModuleGrid.Visibility = Visibility.Collapsed;
                VerifyModuleGrid.Visibility = Visibility.Visible;
            }
        }
示例#4
0
        public ThemeReader(int ID)
        {
            id_module = ID;
            InfosModule ModuleAccess = ModulesAccessManager.GetModuleViaID(ID);

            system_module = ModuleAccess.ModuleSystem;
        }
示例#5
0
        public static async Task <InfosModule> GetModuleViaIDAsync(int id)
        {
            StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("modules_list.json", CreationCollisionOption.OpenIfExists);

            using (var reader = new StreamReader(await file.OpenStreamForReadAsync()))
                using (JsonReader JsonReader = new JsonTextReader(reader))
                {
                    try
                    {
                        ModulesList list = new JsonSerializer().Deserialize <ModulesList>(JsonReader);

                        if (list != null)
                        {
                            foreach (InfosModule _module in SystemModulesList.Modules)
                            {
                                list.Modules.Add(_module);
                            }

                            InfosModule module = list.Modules.Where(m => m.ID == id).FirstOrDefault();

                            if (module != null)
                            {
                                return(module);
                            }
                        }
                    }
                    catch
                    {
                        return(null);
                    }
                }

            return(null);
        }
示例#6
0
        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);
            }
        }
示例#7
0
        async Task IsSystemModuleOrNot(int _id)
        {
            InfosModule ModuleAccess = await ModulesAccessManager.GetModuleViaIDAsync(_id);

            if (ModuleAccess.ModuleSystem)
            {
                system_module = true;
            }
            else
            {
                system_module = false;
            }
        }
        private async void IntializeChakraAndExecute(string function_name)
        {
            /*
             * =============================
             * = ADDONS EXECUTOR VARIABLES =
             * =============================
             */


            host.Chakra.ProjectObjectToGlobal(_SCEELibs, "sceelibs");


            /*
             * ===========================
             * = ADDONS EXECUTOR CONTENT =
             * ===========================
             */


            InfosModule ModuleAccess = ModulesAccessManager.GetModuleViaID(_id);
            StorageFile MainFile     = AsyncHelpers.RunSync(async() => await StorageFile.GetFileFromApplicationUriAsync(new Uri(ModulesAccessManager.GetModuleFolderPath(ModuleAccess.ID, ModuleAccess.ModuleSystem) + "main.js")));

            foreach (string Path in ModuleAccess.JSFilesPathList)
            {
                try
                {
                    StorageFile FileFromPath = AsyncHelpers.RunSync(async() => await StorageFile.GetFileFromApplicationUriAsync(new Uri(ModulesAccessManager.GetModuleFolderPath(ModuleAccess.ID, ModuleAccess.ModuleSystem) + Path)));
                    host.Chakra.RunScript(AsyncHelpers.RunSync(async() => await FileIO.ReadTextAsync(FileFromPath)));
                }
                catch
                {
                    Debug.WriteLine("Erreur ! :(");
                }
            }

            try
            {
                string code = AsyncHelpers.RunSync(async() => await FileIO.ReadTextAsync(MainFile));
                host.Chakra.RunScript(code);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            try
            {
                host.Chakra.CallFunction(function_name);
            }
            catch { }
        }
示例#9
0
        public static async Task <bool> SetCurrentThemeAceEditorTempContentAsync()
        {
            try
            {
                InfosModule module = await ModulesAccessManager.GetModuleViaIDAsync(await 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 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 TemplatesReader(int ID) : base(ID)
 {
     ModuleContent = ModulesAccessManager.GetModuleViaID(ID);
 }
示例#12
0
        private async void IntializeChakraAndExecute(string function_name)
        {
            /*
             * =============================
             * = ADDONS EXECUTOR VARIABLES =
             * =============================
             */


            host.Chakra.ProjectObjectToGlobal(_SCEELibs, "sceelibs");


            /*
             * ===========================
             * = ADDONS EXECUTOR CONTENT =
             * ===========================
             */


            InfosModule   ModuleAccess = AsyncHelpers.RunSync(async() => await ModulesAccessManager.GetModuleViaIDAsync(_id));
            StorageFolder folder_module;

            if (ModuleAccess.ModuleSystem)
            {
                StorageFolder folder_content       = AsyncHelpers.RunSync(async() => await Package.Current.InstalledLocation.GetFolderAsync("SerrisModulesServer")),
                              folder_systemmodules = AsyncHelpers.RunSync(async() => await folder_content.GetFolderAsync("SystemModules"));
                folder_module = AsyncHelpers.RunSync(async() => await folder_systemmodules.CreateFolderAsync(_id + "", CreationCollisionOption.OpenIfExists));
            }
            else
            {
                StorageFolder folder_content = AsyncHelpers.RunSync(async() => await ApplicationData.Current.LocalFolder.CreateFolderAsync("modules", CreationCollisionOption.OpenIfExists));
                folder_module = AsyncHelpers.RunSync(async() => await folder_content.CreateFolderAsync(_id + "", CreationCollisionOption.OpenIfExists));
            }

            foreach (string path in ModuleAccess.JSFilesPathList)
            {
                StorageFolder _folder_temp = folder_module; StorageFile _file_read = AsyncHelpers.RunSync(async() => await folder_module.GetFileAsync("main.js")); bool file_found = false; string path_temp = path;

                while (!file_found)
                {
                    if (path_temp.Contains(Path.AltDirectorySeparatorChar))
                    {
                        //Debug.WriteLine(path_temp.Split(Path.AltDirectorySeparatorChar).First());
                        _folder_temp = AsyncHelpers.RunSync(async() => await _folder_temp.GetFolderAsync(path_temp.Split(Path.AltDirectorySeparatorChar).First()));
                        path_temp    = path_temp.Substring(path_temp.Split(Path.AltDirectorySeparatorChar).First().Length + 1);
                    }
                    else
                    {
                        _file_read = AsyncHelpers.RunSync(async() => await _folder_temp.GetFileAsync(path_temp));
                        file_found = true;
                        break;
                    }
                }

                try
                {
                    using (StreamReader reader = AsyncHelpers.RunSync(async() => new StreamReader(await _file_read.OpenStreamForReadAsync())))
                    {
                        host.Chakra.RunScript(AsyncHelpers.RunSync(async() => await reader.ReadToEndAsync()));
                    }
                }
                catch
                {
                    Debug.WriteLine("Erreur ! :(");
                }
            }

            StorageFile main_js = AsyncHelpers.RunSync(async() => await folder_module.GetFileAsync("main.js"));

            try
            {
                string code = AsyncHelpers.RunSync(async() => await FileIO.ReadTextAsync(main_js));
                host.Chakra.RunScript(code);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            try
            {
                host.Chakra.CallFunction(function_name);
            }
            catch { }
        }