public void DeepCopy_1() { var p1 = ManifestUtilsTests.Get_TEZT_PATH(); var p2 = p1 + "_2"; IOMiscUtils.EnsureDirectoryDeleted(p2); Directory.CreateDirectory(p2); using (var fs = new LocalFileSystem("L1")) { using (var session = fs.StartSession()) { var fromDir = session[p1] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(fromDir); var toDir = session[p2] as FileSystemDirectory; fromDir.DeepCopyTo(toDir, FileSystemDirectory.DirCopyFlags.Directories | FileSystemDirectory.DirCopyFlags.Files); var manifest2 = ManifestUtils.GeneratePackagingManifest(toDir); Console.WriteLine(manifest1.Configuration.ContentView); Assert.IsTrue(ManifestUtils.HasTheSameContent(manifest1, manifest2)); } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); var settings = ModuleContext.OpenContentSettings(); Manifest manifest = settings.Manifest; if (settings.TemplateKey.Extention != ".manifest") { manifest = ManifestUtils.LoadManifestFileFromCacheOrDisk(settings.TemplateKey.TemplateDir); } if (manifest != null) { string addEditControl = manifest.AdditionalEditControl; if (!string.IsNullOrEmpty(addEditControl)) { var contr = LoadControl(addEditControl); PortalModuleBase mod = contr as PortalModuleBase; if (mod != null) { mod.ModuleConfiguration = this.ModuleConfiguration; mod.ModuleId = this.ModuleId; mod.LocalResourceFile = this.LocalResourceFile; } this.Controls.Add(contr); } } }
public OpenContentSettings(IDictionary moduleSettings) { var template = moduleSettings["template"] as string; //templatepath+file or //manifestpath+key FirstTimeInitialisation = string.IsNullOrEmpty(template); if (!FirstTimeInitialisation) { var templateUri = new FileUri(template); TemplateKey = new TemplateKey(templateUri); TemplateManifest templateManifest; Manifest = ManifestUtils.GetManifest(TemplateKey, out templateManifest); Template = templateManifest; } var sTabId = moduleSettings["tabid"] as string; var sModuleId = moduleSettings["moduleid"] as string; TabId = -1; ModuleId = -1; if (sTabId != null && sModuleId != null) { TabId = int.Parse(sTabId); ModuleId = int.Parse(sModuleId); } Data = moduleSettings["data"] as string; _query = moduleSettings["query"] as string; var sDetailTabId = moduleSettings["detailtabid"] as string; DetailTabId = -1; if (!string.IsNullOrEmpty(sDetailTabId)) { DetailTabId = int.Parse(sDetailTabId); } }
public void Install_1() { var source = ManifestUtilsTests.Get_TEZT_PATH(); var target = source + "_INSTALLED"; using (var fs = new LocalFileSystem("L1")) { var session = fs.StartSession(); var sourceDir = session[source] as FileSystemDirectory; var manifest = ManifestUtils.GeneratePackagingManifest(sourceDir, packageName: "Package1"); var fn = Path.Combine(source, ManifestUtils.MANIFEST_FILE_NAME); try { manifest.Configuration.ToLaconicFile(fn); var set = new List <LocalInstallation.PackageInfo> { new LocalInstallation.PackageInfo("Package1", sourceDir, null)//no relative path }; using (var install = new LocalInstallation(target)) { Console.WriteLine("Installed anew: " + install.CheckLocalAndInstallIfNeeded(set)); } } finally { IOMiscUtils.EnsureFileEventuallyDeleted(fn); } } }
public static int Main(string[] args) { int exitCode = ERROR_BAD_ARGUMENTS; if (args.Length == 2) { if (args[0].ToLower() == "create") { ManifestUtils.ShowAssemblyInfo(); ManifestUtils.GenerateManifest(args[1]); exitCode = ERROR_SUCCESS; } else if (args[0].ToLower() == "verify") { string tmpFilePath = Path.GetTempFileName(); ManifestUtils.GenerateManifest(tmpFilePath); exitCode = FilesMatch(args[1], tmpFilePath) ? exitCode = ERROR_SUCCESS : exitCode = ERROR_MANIFEST_INVALID; File.Delete(tmpFilePath); } } if (exitCode == ERROR_BAD_ARGUMENTS) { Console.WriteLine("ManifestGenerator: Error - Invalid Arguments."); ShowUsage(); } return(exitCode); }
private static void generateManifests(Metabank mb, bool silent) { mb.fsAccess("amm.GenerateManifest()", Metabank.BIN_CATALOG, (session, dir) => { foreach (var sdn in dir.SubDirectoryNames) { using (var sdir = dir.GetSubDirectory(sdn)) { var computed = ManifestUtils.GeneratePackagingManifest(sdir); var computedContent = computed.Configuration.ToLaconicString(); if (!silent) { ConsoleUtils.WriteMarkupContent( "<push><f color=gray>Pckg: <f color=white>{0,-42}<f color=gray> Mnfst.Sz: <f color=yellow>{1}<pop>\n".Args("'{0}'".Args(sdn), computedContent.Length)); } using (var file = sdir.CreateFile(ManifestUtils.MANIFEST_FILE_NAME)) { file.WriteAllText(computedContent); } } } return(true); } ); }
private void OnAddButtonClicked() { ManifestUtils.AddRegistry(RegistrySettings.Instance().Registry); ShowPackageManager(); UpdateAddButtonEnabled(); UpdateRemoveButtonEnabled(); UpdateAllStatus(); }
private void OnRemoveButtonClicked() { ManifestUtils.RemoveRegistry(RegistrySettings.Instance().Registry.Name); RegistrySettings.Instance().SetAutoCheckEnabled(false); AutoCheckToggle.value = false; UpdateAddButtonEnabled(); UpdateRemoveButtonEnabled(); UpdateAllStatus(); }
public override void Validate(ValidationContext ctx) { var output = ctx.Output; try { var packages = Packages; } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error)); return; } try { Metabank.fsAccess("BinCatalog.Validate", BIN_CATALOG, (session, dir) => { foreach (var sdn in dir.SubDirectoryNames) { using (var sdir = dir.GetSubDirectory(sdn)) using (var mf = sdir.GetFile(ManifestUtils.MANIFEST_FILE_NAME)) { if (mf == null) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, StringConsts.METABASE_BIN_PACKAGE_MISSING_MANIFEST_ERROR .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null) ); continue; } var manifest = LaconicConfiguration.CreateFromString(mf.ReadAllText()).Root; var computed = ManifestUtils.GeneratePackagingManifest(sdir); if (!ManifestUtils.HasTheSameContent(manifest, computed, oneWay: false)) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, StringConsts.METABASE_BIN_PACKAGE_OUTDATED_MANIFEST_ERROR .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null) ); } } } return(true); } ); } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error)); return; } }
public void Compare_1() { using (var fs = new LocalFileSystem("L1")) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(dir); var manifest2 = ManifestUtils.GeneratePackagingManifest(dir); Assert.IsTrue(manifest1.HasTheSameContent(manifest2)); } }
public void Compare_2() { using (var fs = new LocalFileSystem(NOPApplication.Instance)) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(dir); var manifest2 = Azos.Conf.LaconicConfiguration.CreateFromString(EXPECTED).Root; Aver.IsTrue(manifest1.HasTheSameContent(manifest2)); } }
public void Compare_2() { using (var fs = new LocalFileSystem("L1")) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(dir); var manifest2 = NFX.Environment.LaconicConfiguration.CreateFromString(EXPECTED).Root; Assert.IsTrue(manifest1.HasTheSameContent(manifest2)); } }
public void Compare_4() { using (var fs = new LocalFileSystem(NOPApplication.Instance)) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(dir); var manifest2 = ManifestUtils.GeneratePackagingManifest(dir); manifest2[2].Delete(); Aver.IsFalse(manifest1.HasTheSameContent(manifest2)); } }
public void Compare_3() { using (var fs = new LocalFileSystem("L1")) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest1 = ManifestUtils.GeneratePackagingManifest(dir); var manifest2 = ManifestUtils.GeneratePackagingManifest(dir); manifest2[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).Value = "123"; Assert.IsFalse(manifest1.HasTheSameContent(manifest2)); } }
private void UpdateRegistryStatus() { RegistryStatusLabel.RemoveFromClassList(StatusSuccessClass); RegistryStatusLabel.RemoveFromClassList(StatusErrorClass); if (ManifestUtils.CheckRegistryExists(RegistrySettings.Instance().Registry)) { RegistryStatusLabel.AddToClassList(StatusSuccessClass); RegistryStatusLabel.text = RegistryStatusSuccessString; } else { RegistryStatusLabel.AddToClassList(StatusErrorClass); RegistryStatusLabel.text = RegistryStatusErrorString; } }
public OpenContentSettings(string template, int tabId, int moduleId, string templateSettings = "", string filterSettings = "", int detailTabId = -1) { // template = //templatepath+file or //manifestpath+key FirstTimeInitialisation = string.IsNullOrEmpty(template); if (!FirstTimeInitialisation) { TemplateKey = new TemplateKey(new FileUri(template)); TemplateManifest templateManifest; Manifest = ManifestUtils.GetManifest(TemplateKey, out templateManifest); Template = templateManifest; } TabId = tabId; ModuleId = moduleId; Data = templateSettings; _query = filterSettings; DetailTabId = detailTabId; }
public OpenContentSettings(ComponentSettingsInfo moduleSettings) { FirstTimeInitialisation = string.IsNullOrEmpty(moduleSettings.Template); if (!FirstTimeInitialisation) { TemplateKey = new TemplateKey(new FileUri(moduleSettings.Template)); TemplateManifest templateManifest; Manifest = ManifestUtils.GetManifest(TemplateKey, out templateManifest); Template = templateManifest; } TabId = moduleSettings.TabId; ModuleId = moduleSettings.ModuleId; Data = moduleSettings.Data; _query = moduleSettings.Query; DetailTabId = moduleSettings.DetailTabId; }
public static string GetDefaultTemplate(string physicalFolder) { string template = ""; FolderUri folder = new FolderUri(FolderUri.ReverseMapPath(physicalFolder)); var manifest = ManifestUtils.GetFileManifest(folder); if (manifest != null && manifest.HasTemplates) { //get the requested template key //var templateManifest = manifest.Templates.First().Value; //var templateUri = new FileUri(folder, templateManifest.Main.Template); template = folder.FolderPath + "/" + manifest.Templates.First().Key; } else { foreach (var item in Directory.GetFiles(physicalFolder)) { string fileName = Path.GetFileName(item).ToLower(); if (fileName == "template.hbs") { template = item; break; } else if (fileName == "template.cshtml") { template = item; break; } if (fileName.EndsWith(".hbs")) { template = item; } if (fileName.EndsWith(".cshtml")) { template = item; } } } return(FileUri.ReverseMapPath(template)); }
public void Generate_1() { using (var fs = new LocalFileSystem("L1")) { var session = fs.StartSession(); var dir = session[Get_TEZT_PATH()] as FileSystemDirectory; var manifest = ManifestUtils.GeneratePackagingManifest(dir); Console.WriteLine(manifest.Configuration.ContentView); Assert.AreEqual("SubDir1", manifest[0].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value); Assert.AreEqual("SubDir2", manifest[1].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value); Assert.AreEqual("Gagarin.txt", manifest[2].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value); Assert.AreEqual("TextFile1.txt", manifest[3].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value); Assert.AreEqual(500066, manifest[0].Children.First(c => c.IsSameNameAttr("Bitmap1.bmp")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).ValueAsInt()); Assert.AreEqual(1248671023, manifest[0].Children.First(c => c.IsSameNameAttr("Bitmap1.bmp")).AttrByName(ManifestUtils.CONFIG_CSUM_ATTR).ValueAsInt()); Assert.AreEqual(105, manifest[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).ValueAsInt()); Assert.AreEqual(1399856254, manifest[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_CSUM_ATTR).ValueAsInt()); } }
private static string[] GetDirs(TemplateManifest selectedTemplate, FileUri otherModuleTemplate, bool advanced, string basePath, string[] dirs, List <ListItem> lst, string folderType) { if (Directory.Exists(basePath)) { dirs = Directory.GetDirectories(basePath); if (otherModuleTemplate != null /*&& */) { var selDir = otherModuleTemplate.PhysicalFullDirectory; if (!dirs.Contains(selDir)) { selDir = Path.GetDirectoryName(selDir); } if (dirs.Contains(selDir)) { dirs = new string[] { selDir } } ; else { dirs = new string[] { } }; } foreach (var dir in dirs) { string templateCat = folderType; IEnumerable <string> files = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories); IEnumerable <string> manifestfiles = files.Where(s => s.EndsWith("manifest.json")); var manifestTemplateFound = false; if (manifestfiles.Any()) { foreach (string manifestFile in manifestfiles) { FileUri manifestFileUri = FileUri.FromPath(manifestFile); var manifest = ManifestUtils.LoadManifestFileFromCacheOrDisk(manifestFileUri); if (manifest != null && manifest.HasTemplates) { manifestTemplateFound = true; foreach (var template in manifest.Templates) { FileUri templateUri = new FileUri(manifestFileUri.FolderPath, template.Key); string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!String.IsNullOrEmpty(template.Value.Title)) { if (advanced) { templateName = templateName + " - " + template.Value.Title; } } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); if (!advanced) { break; } } } } } if (!manifestTemplateFound) { var scriptfiles = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".cshtml") || s.EndsWith(".vbhtml") || s.EndsWith(".hbs")); foreach (string script in scriptfiles) { string scriptName = script.Remove(script.LastIndexOf(".")).Replace(basePath, ""); if (scriptName.ToLower().EndsWith("template")) { scriptName = scriptName.Remove(scriptName.LastIndexOf("\\")); } else { scriptName = scriptName.Replace("\\", " - "); } FileUri templateUri = FileUri.FromPath(script); var item = new ListItem(templateCat + " : " + scriptName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } return(dirs); }
private void UpdateRemoveButtonEnabled() { RemoveButton.SetEnabled(ManifestUtils.CheckRegistryExists(RegistrySettings.Instance().Registry)); }
private void syncButton_Click(object sender, EventArgs e) { SaveSettingsToConfig(ConfigStateCurrentIndex); _dlMode = playlistRadio.Checked ? EnumUtil.DownloadMode.Playlist : userPlaylists.Checked ? EnumUtil.DownloadMode.UserPlaylists : favoritesRadio.Checked ? EnumUtil.DownloadMode.Favorites : artistRadio.Checked ? EnumUtil.DownloadMode.Artist : EnumUtil.DownloadMode.Track; if (!string.IsNullOrWhiteSpace(url.Text?.ToLower()) && !string.IsNullOrWhiteSpace(directoryPath.Text?.ToLower()) && !IsSyncButtonClicked) { IsSyncButtonClicked = true; syncButton.Tag = "STR_ABORT"; syncButton.Text = LanguageManager.Language[syncButton.Tag.ToString()]; status.Tag = "STR_MAIN_STATUS_CHECK"; status.Text = LanguageManager.Language[status.Tag.ToString()]; progressUtil.Completed = false; progressBar.Value = 0; progressBar.Maximum = 0; progressBar.Minimum = 0; TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal); Highqualitysong = chk_highquality.Checked; ConvertToMp3 = chk_convertToMp3.Checked; SyncMethod = rbttn_oneWay.Checked ? 1 : 2; FoldersPerArtist = chk_folderByArtist.Checked; ReplaceIllegalCharacters = chk_replaceIllegalCharacters.Checked; ExcludeAac = chk_excl_m4a.Checked; ExcludeM4A = chk_excl_m4a.Checked; CreatePlaylists = chk_CreatePlaylists.Checked; ConcurrentDownloads = (int)nudConcurrency.Value; MergePlaylists = chk_MergePlaylists.Checked; Uri soundCloudUri; try { soundCloudUri = new Uri(url?.Text?.ToLower()); } catch (Exception) { status.Tag = "STR_MAIN_STATUS_INVALIDURL"; status.Text = LanguageManager.Language[status.Tag.ToString()]; progressUtil.Completed = true; InvokeSyncComplete(); return; } var filesystemUtil = new FilesystemUtils(new DirectoryInfo(directoryPath?.Text?.ToLower()), trackRadio.Checked ? FormatForTag : FormatForName, FoldersPerArtist, ReplaceIllegalCharacters); var manifestUtil = new ManifestUtils(progressUtil, filesystemUtil, soundCloudUri, _dlMode, SyncMethod); var playlistUtil = new PlaylistUtils(manifestUtil); DownloadUtils downloadUtil = new DownloadUtils(clientIdUtil, ExcludeM4A, ExcludeAac, ConvertToMp3, manifestUtil, Highqualitysong, ConcurrentDownloads); var syncUtil = new SyncUtils(CreatePlaylists, manifestUtil, downloadUtil, playlistUtil); if (_dlMode != EnumUtil.DownloadMode.Track) { bool differentmanifest; if (!manifestUtil.FindManifestAndBackup(out differentmanifest)) { if (differentmanifest) { status.Tag = "STR_MAIN_STATUS_DIFFMANY"; status.Text = LanguageManager.Language[status.Tag.ToString()]; progressUtil.Completed = true; InvokeSyncComplete(); return; } } } new Thread(() => { // perform progress updates while (!progressUtil.Completed && !progressUtil.Exiting) { Thread.Sleep(500); InvokeUpdateStatus(); this.Invoke((MethodInvoker)(() => lb_progressOfTracks.DataSource = progressUtil.GetTrackProgressValues())); this.Invoke((MethodInvoker)(() => lb_progressOfTracks.Refresh())); InvokeUpdateProgressBar(); } if (!progressUtil.Exiting) { InvokeUpdateStatus(); } }).Start(); new Thread(() => { try { var sync = new SoundcloudSync(syncUtil, MergePlaylists); sync.Synchronize(url?.Text?.ToLower()); } catch (Exception ex) { MessageBox.Show($"{ex.Message} { ExceptionHandlerUtils.GetInnerExceptionMessages(ex)}", LanguageManager.Language["STR_ERR"]); } finally { progressUtil.Completed = true; InvokeSyncComplete(); } }).Start(); } else if (progressUtil.IsActive && IsSyncButtonClicked) { progressUtil.IsActive = false; syncButton.Enabled = false; } else if (!IsSyncButtonClicked && string.IsNullOrWhiteSpace(url.Text)) { status.Tag = "STR_MAIN_STATUS_NULLURL"; status.Text = LanguageManager.Language[status.Tag.ToString()]; } else if (!IsSyncButtonClicked && string.IsNullOrWhiteSpace(directoryPath.Text)) { status.Tag = "STR_MAIN_STATUS_NULLDIR"; status.Text = LanguageManager.Language[status.Tag.ToString()]; } }
public static List <ListItem> GetTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir, FileUri otherModuleTemplate) { //bool otherModuleSkinTemplate = otherModuleTemplate != null && otherModuleTemplate.PhysicalFilePath.Contains(HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir))); string basePath = HostingEnvironment.MapPath(GetSiteTemplateFolder(portalSettings, moduleSubDir)); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } var dirs = Directory.GetDirectories(basePath); if (otherModuleTemplate != null) { var selDir = otherModuleTemplate.PhysicalFullDirectory; if (!dirs.Contains(selDir)) { selDir = Path.GetDirectoryName(selDir); } if (dirs.Contains(selDir)) { dirs = new string[] { selDir } } ; else { dirs = new string[] { } }; } List <ListItem> lst = new List <ListItem>(); foreach (var dir in dirs) { string templateCat = "Site"; //string dirName = Path.GetFileNameWithoutExtension(dir); string dirName = dir.Substring(basePath.Length); int modId = -1; if (int.TryParse(dirName, out modId)) { // if numeric directory name --> module template if (modId == moduleId) { // this module -> show templateCat = "Module"; } else { // if it's from an other module -> don't show continue; } } IEnumerable <string> files = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories); IEnumerable <string> manifestfiles = files.Where(s => s.EndsWith("manifest.json")); var manifestTemplateFound = false; if (manifestfiles.Any()) { foreach (string manifestFile in manifestfiles) { FileUri manifestFileUri = FileUri.FromPath(manifestFile); var manifest = ManifestUtils.GetFileManifest(manifestFileUri); if (manifest != null && manifest.HasTemplates) { manifestTemplateFound = true; foreach (var template in manifest.Templates) { FileUri templateUri = new FileUri(manifestFileUri.FolderPath, template.Key); string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!string.IsNullOrEmpty(template.Value.Title)) { templateName = templateName + " - " + template.Value.Title; } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } if (!manifestTemplateFound) { IEnumerable <string> scriptfiles = files.Where(s => s.EndsWith(".cshtml") || s.EndsWith(".vbhtml") || s.EndsWith(".hbs")); foreach (string script in scriptfiles) { FileUri templateUri = FileUri.FromPath(script); string scriptName = script.Remove(script.LastIndexOf(".")).Replace(basePath, ""); if (templateCat == "Module") { if (scriptName.ToLower().EndsWith("template")) { scriptName = ""; } else { scriptName = scriptName.Substring(scriptName.LastIndexOf("\\") + 1); } } else if (scriptName.ToLower().EndsWith("template")) { scriptName = scriptName.Remove(scriptName.LastIndexOf("\\")); } else { scriptName = scriptName.Replace("\\", " - "); } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + scriptName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } // skin basePath = HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir)); if (Directory.Exists(basePath)) { dirs = Directory.GetDirectories(basePath); if (otherModuleTemplate != null /*&& */) { var selDir = otherModuleTemplate.PhysicalFullDirectory; if (!dirs.Contains(selDir)) { selDir = Path.GetDirectoryName(selDir); } if (dirs.Contains(selDir)) { dirs = new string[] { selDir } } ; else { dirs = new string[] { } }; } foreach (var dir in dirs) { string templateCat = "Skin"; IEnumerable <string> files = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories); IEnumerable <string> manifestfiles = files.Where(s => s.EndsWith("manifest.json")); var manifestTemplateFound = false; if (manifestfiles.Any()) { foreach (string manifestFile in manifestfiles) { FileUri manifestFileUri = FileUri.FromPath(manifestFile); var manifest = ManifestUtils.GetFileManifest(manifestFileUri); if (manifest != null && manifest.HasTemplates) { manifestTemplateFound = true; foreach (var template in manifest.Templates) { FileUri templateUri = new FileUri(manifestFileUri.FolderPath, template.Key); string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!string.IsNullOrEmpty(template.Value.Title)) { templateName = templateName + " - " + template.Value.Title; } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } if (!manifestTemplateFound) { var scriptfiles = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".cshtml") || s.EndsWith(".vbhtml") || s.EndsWith(".hbs")); foreach (string script in scriptfiles) { string scriptName = script.Remove(script.LastIndexOf(".")).Replace(basePath, ""); if (scriptName.ToLower().EndsWith("template")) { scriptName = scriptName.Remove(scriptName.LastIndexOf("\\")); } else { scriptName = scriptName.Replace("\\", " - "); } FileUri templateUri = FileUri.FromPath(script); var item = new ListItem(templateCat + " : " + scriptName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } return(lst); }
public override void OnPreferenceGUI() { const string title = "OpenVR"; if (canSupport) { var wasSupported = support; support = m_foldouter.ShowFoldoutButtonOnToggleEnabled(new GUIContent(title, "VIVE, VIVE Pro, VIVE Pro Eye, VIVE Cosmos\nOculus Rift, Oculus Rift S, Windows MR"), wasSupported); s_symbolChanged |= wasSupported != support; } else { GUILayout.BeginHorizontal(); Foldouter.ShowFoldoutBlank(); if (activeBuildTargetGroup != BuildTargetGroup.Standalone) { GUI.enabled = false; ShowToggle(new GUIContent(title, "Standalone platform required."), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); ShowSwitchPlatformButton(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64); } #if UNITY_2020_2_OR_NEWER && FALSE // openxr not fully supported yet else if (!PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME)) { GUI.enabled = false; ShowToggle(new GUIContent(title, "OpenXR Plugin ackage required."), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); ShowAddPackageButton("OpenXR Plugin", OPENXR_PLUGIN_PACKAGE_NAME); } #elif UNITY_2019_3_OR_NEWER && FALSE // openvr xr plugin on Valve registry is obsolete else if (!PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME)) { GUI.enabled = false; ShowToggle(new GUIContent(title, "OpenVR XR Plugin package required."), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Add OpenVR XR Plugin Package", "Add " + OPENVR_XR_PACKAGE_NAME + " to Package Manager"), GUILayout.ExpandWidth(false))) { if (!ManifestUtils.CheckRegistryExists(ValveRegistry)) { ManifestUtils.AddRegistry(ValveRegistry); } PackageManagerHelper.AddToPackageList(OPENVR_XR_PACKAGE_NAME); VIUProjectSettings.Instance.isInstallingOpenVRXRPlugin = true; } } #elif UNITY_2018_2_OR_NEWER && FALSE // obsolete else if (!PackageManagerHelper.IsPackageInList(OPENVR_PACKAGE_NAME)) { GUI.enabled = false; ShowToggle(new GUIContent(title, "OpenVR (Desktop) package required."), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); ShowAddPackageButton("OpenVR (Desktop)", OPENVR_PACKAGE_NAME); } #endif else if (!VRModule.isSteamVRPluginDetected) { GUI.enabled = false; ShowToggle(new GUIContent(title, "SteamVR Plugin required."), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); ShowUrlLinkButton(URL_STEAM_VR_PLUGIN); } GUILayout.EndHorizontal(); } if (support && m_foldouter.isExpended) { EditorGUI.indentLevel += 2; // Vive Hand Tracking Submodule const string vhtSdkUrl = "https://developer.vive.com/resources/vive-sense/sdk/vive-hand-tracking-sdk/"; const string vhtTitle = "Enable Vive Hand Tracking"; if (!VRModule.isViveHandTrackingDetected) { GUILayout.BeginHorizontal(); GUI.enabled = false; EditorGUILayout.ToggleLeft(new GUIContent(vhtTitle, "Vive Hand Tracking SDK required"), false, GUILayout.Width(230f)); GUI.enabled = true; GUILayout.FlexibleSpace(); ShowUrlLinkButton(vhtSdkUrl); GUILayout.EndHorizontal(); } else { EditorGUI.BeginChangeCheck(); VRModuleSettings.activateViveHandTrackingSubmodule = EditorGUILayout.ToggleLeft(new GUIContent(vhtTitle, "Works on Vive, VIVE Pro, Vive Pro Eye, VIVE Cosmos, VIVE Cosmos XR and Valve Index"), VRModuleSettings.activateViveHandTrackingSubmodule); s_guiChanged |= EditorGUI.EndChangeCheck(); } if (VRModule.isSteamVRPluginDetected) { EditorGUI.BeginChangeCheck(); } else { GUI.enabled = false; } // Skeleton mode VIUSettings.steamVRLeftSkeletonMode = (SteamVRSkeletonMode)EditorGUILayout.EnumPopup(new GUIContent("Left Controller Skeleton", "This effects RenderModelHook's behaviour"), VIUSettings.steamVRLeftSkeletonMode); VIUSettings.steamVRRightSkeletonMode = (SteamVRSkeletonMode)EditorGUILayout.EnumPopup(new GUIContent("Right Controller Skeleton", "This effects RenderModelHook's behaviour"), VIUSettings.steamVRRightSkeletonMode); VIUSettings.autoLoadExternalCameraConfigOnStart = EditorGUILayout.ToggleLeft(new GUIContent("Load Config and Enable External Camera on Start", "You can also load config by calling ExternalCameraHook.LoadConfigFromFile(path) in script."), VIUSettings.autoLoadExternalCameraConfigOnStart); if (!VIUSettings.autoLoadExternalCameraConfigOnStart) { GUI.enabled = false; } { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); VIUSettings.externalCameraConfigFilePath = EditorGUILayout.DelayedTextField(new GUIContent("Config Path"), VIUSettings.externalCameraConfigFilePath); if (string.IsNullOrEmpty(VIUSettings.externalCameraConfigFilePath)) { VIUSettings.externalCameraConfigFilePath = VIUSettings.EXTERNAL_CAMERA_CONFIG_FILE_PATH_DEFAULT_VALUE; EditorGUI.EndChangeCheck(); } else if (EditorGUI.EndChangeCheck() && VIUSettings.externalCameraConfigFilePath.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { VIUSettings.externalCameraConfigFilePath = VIUSettings.EXTERNAL_CAMERA_CONFIG_FILE_PATH_DEFAULT_VALUE; } // Create button that writes default config file if (VIUSettings.autoLoadExternalCameraConfigOnStart && !File.Exists(VIUSettings.externalCameraConfigFilePath)) { if (VRModule.isSteamVRPluginDetected) { s_guiChanged |= EditorGUI.EndChangeCheck(); } ShowCreateExCamCfgButton(); if (VRModule.isSteamVRPluginDetected) { EditorGUI.BeginChangeCheck(); } } EditorGUI.indentLevel--; } if (!VIUSettings.autoLoadExternalCameraConfigOnStart) { GUI.enabled = true; } VIUSettings.enableExternalCameraSwitch = EditorGUILayout.ToggleLeft(new GUIContent("Enable External Camera Switch", VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP), VIUSettings.enableExternalCameraSwitch); if (!VIUSettings.enableExternalCameraSwitch) { GUI.enabled = false; } { EditorGUI.indentLevel++; VIUSettings.externalCameraSwitchKey = (KeyCode)EditorGUILayout.EnumPopup("Switch Key", VIUSettings.externalCameraSwitchKey); VIUSettings.externalCameraSwitchKeyModifier = (KeyCode)EditorGUILayout.EnumPopup("Switch Key Modifier", VIUSettings.externalCameraSwitchKeyModifier); EditorGUI.indentLevel--; } if (!VIUSettings.enableExternalCameraSwitch) { GUI.enabled = true; } EditorGUI.indentLevel -= 2; if (VRModule.isSteamVRPluginDetected) { s_guiChanged |= EditorGUI.EndChangeCheck(); } else { GUI.enabled = true; } } if (support && !VRModule.isSteamVRPluginDetected && !PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME)) { EditorGUI.indentLevel += 2; GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox( #if VIU_XR_GENERAL_SETTINGS "Input" + #elif UNITY_2017_1_OR_NEWER "External-Camera(Mix-Reality), animated controller model" + ", VIVE Controller haptics(vibration)" + ", VIVE Tracker USB/Pogo-pin input" + #else "External-Camera(Mix-Reality), animated controller model" + ", VIVE Controller haptics(vibration)" + ", VIVE Tracker device" + #endif " NOT supported! " + "Install SteamVR Plugin to get support." , MessageType.Warning); s_warningHeight = Mathf.Max(s_warningHeight, GUILayoutUtility.GetLastRect().height); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(GUILayout.Height(s_warningHeight)); GUILayout.FlexibleSpace(); ShowUrlLinkButton(URL_STEAM_VR_PLUGIN, "Get SteamVR Plugin"); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); EditorGUI.indentLevel -= 2; } #if UNITY_2019_3_OR_NEWER if (VIUProjectSettings.Instance.isInstallingOpenVRXRPlugin) { bool isPackageInstalled = PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD); bool isLoaderEnabled = XRPluginManagementUtils.IsXRLoaderEnabled(SteamVRModule.OPENVR_XR_LOADER_NAME, BuildTargetGroup.Standalone); if (isPackageInstalled && !isLoaderEnabled) { XRPluginManagementUtils.SetXRLoaderEnabled(SteamVRModule.OPENVR_XR_LOADER_CLASS_NAME, BuildTargetGroup.Standalone, true); OpenVRSDK.enabled = true; VIUProjectSettings.Instance.isInstallingOpenVRXRPlugin = false; } } #endif }