public void GetResource() { var resourceBytes = ResourceUtility.GetResource(Assembly.GetExecutingAssembly(), "Remotion.Development.UnitTests.Core.UnitTesting.Resources.TestEmbeddedResource.txt"); Assert.That(resourceBytes.Length, Is.EqualTo(11)); }
public override void OnPropertyChanged([CallerMemberName] string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == nameof(this.SelectedCard)) { this.SelectedCardLabelStyle = this.SelectedCard.Length > 2 ? (Style)ResourceUtility.GetResource("SelectedCardLabelStyle2") : (Style)ResourceUtility.GetResource("SelectedCardLabelStyle"); } }
public HomeView() { this.InitializeComponent(); Theme.Init(Themes.Light); this.Detail = new NavigationPage(new CardSelectionView()) { Style = (Style)ResourceUtility.GetResource("CardSelectionBarBackgroundColor") }; }
public static Asset FromResource(string path) { byte[] embedded = ResourceUtility.GetResource(path); return(new Asset() { Content = embedded, ContentLoaded = true, AssetType = AssetType.Model, IsLocal = true, Loaded = true, Id = 0 }); }
public ActionResult GetResource(int id) { string errorMessage; Resource resource = ResourceUtility.GetResource(id, out errorMessage); if (errorMessage != null) { return(Json(errorMessage, JsonRequestBehavior.AllowGet)); } else if (resource.ResourcesType != ResourcesType.Self) { return(Json(resource, JsonRequestBehavior.AllowGet)); } else { return(View("SelfResource", resource)); } }
public static Asset FromResource(string path) { byte[] embedded = ResourceUtility.GetResource(path); Asset local = new Asset(); local.Content = embedded; local.ContentLoaded = true; local.AssetType = AssetType.Model; local.Id = 0; local.IsLocal = true; ProductInfo dummyInfo = new ProductInfo(); dummyInfo.Name = "???"; dummyInfo.AssetTypeId = AssetType.Model; local.Loaded = true; return(local); }
public static byte[] GetRdbmsMappingSchema() { return(ResourceUtility.GetResource(typeof(ResourceManager), "RdbmsMapping.xsd")); }
public static byte[] GetMappingExportOutput() { return(ResourceUtility.GetResource(typeof(ResourceManager), "MappingExportOutput.xml")); }
public static byte[] GetImageLarger1MB() { return(ResourceUtility.GetResource(typeof(ResourceManager), "ImageLarger1MB.bmp")); }
public void SetCredentialsError(string culture) => ErrorMessage.Text = string.Format(ResourceUtility.GetCultureInfo(culture), ResourceUtility.GetResource <LoadingErrorStrings, LoadingErrorResourcesHelper>(culture).InvalidCredentialsErrorMessage);
public JsonResult ExecuteCommand(Command command) { string fileNameFullPath, fileContents, newfileContents, searchTerm = "", newTerm = "", message, errorMessage; int startIndexSearchTerm, index; PageEntity pageEntity; try { if ((command.Cmd == "menu") || (command.Cmd == "sub1") || (command.Cmd == "sub2")) { fileNameFullPath = string.Format("C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Views\\Main\\_Layout{0}.cshtml", command.Page.ToString()); fileContents = Utility.ReturnFileContents(fileNameFullPath, out errorMessage); if (errorMessage != null) { return(Json(string.Format("ERROR!!\r\n{0}", errorMessage), JsonRequestBehavior.AllowGet)); } switch (command.Cmd) { case "menu": searchTerm = string.Format("<span class='title' data-location='Menu{0}'>", command.Menu.ToString()); break; case "sub1": searchTerm = string.Format("<span class='title' data-location='Menu{0}Sub{1}'>", command.Menu.ToString(), command.Sub1.ToString()); break; case "sub2": searchTerm = string.Format("<span class='title' data-location='Menu{0}Sub{1}Sub{2}'>", command.Menu.ToString(), command.Sub1.ToString(), command.Sub2.ToString()); break; } if (!Utility.IsSearchTermUniqueInString(fileContents, searchTerm, out startIndexSearchTerm, out errorMessage)) { return(Json(string.Format("ERROR!!\r\n{0}", errorMessage), JsonRequestBehavior.AllowGet)); } index = fileContents.IndexOf("</span>", startIndexSearchTerm + searchTerm.Length - 1); if (index == -1) { return(Json("ERROR!! Can't find </span> after search term!", JsonRequestBehavior.AllowGet)); } searchTerm = fileContents.Substring(startIndexSearchTerm, index + 7 - startIndexSearchTerm); switch (command.Cmd) { case "menu": newTerm = string.Format("<span class='title' data-location='Menu{0}'>{1}</span>", command.Menu.ToString(), command.Val); break; case "sub1": newTerm = string.Format("<span class='title' data-location='Menu{0}Sub{1}'>{2}</span>", command.Menu.ToString(), command.Sub1.ToString(), command.Val); break; case "sub2": newTerm = string.Format("<span class='title' data-location='Menu{0}Sub{1}Sub{2}'>{3}</span>", command.Menu.ToString(), command.Sub1.ToString(), command.Sub2.ToString(), command.Val); break; } newfileContents = fileContents.Replace(searchTerm, newTerm); Utility.CreateNewFile(fileNameFullPath, newfileContents); } else if ((command.Cmd == "icon") || (command.Cmd == "title") || ((command.Cmd.Length >= 3) && (command.Cmd.Substring(0, 3) == "tab"))) { if ((command.Cmd == "icon") && !Utility.IconExists(command.Val)) { return(Json("ERROR!! The icon does not exist!!", JsonRequestBehavior.AllowGet)); } switch (command.Cmd) { case "icon": pageEntity = PageEntity.Icon; break; case "title": pageEntity = PageEntity.Title; break; default: pageEntity = PageEntity.Tab; break; } HandleSaveOfPageEntity(pageEntity, command.Page, command.Menu, command.Sub1, command.Sub2, command.Tab, command.Val); } else if ((command.Cmd == "nr") || (command.Cmd == "er")) //New resource or edit resource { LoadResourceData loadResourceData = new LoadResourceData(); loadResourceData.ArrayWithKeyWords = KeyWordUtility.ReturnArrayWithKeyWords(out errorMessage); if (errorMessage != null) { return(Json(errorMessage, JsonRequestBehavior.AllowGet)); } if (command.Cmd == "nr") { ResourcesType resourcesType; switch (command.Val) { case "ThumbUpLocation": resourcesType = ResourcesType.ThumbUpLocation; break; case "Html": resourcesType = ResourcesType.Html; break; case "Self": resourcesType = ResourcesType.Self; break; default: return(Json("ERROR!! Incorrect ResourcesType!", JsonRequestBehavior.AllowGet)); } loadResourceData.Resource = new Resource(0, resourcesType, "", "", "", "", 0, 0, "", "", "", ""); } else { loadResourceData.Resource = ResourceUtility.GetResource(int.Parse(command.Val), out errorMessage); if (errorMessage != null) { return(Json(string.Format("ERROR!!\r\n", errorMessage), JsonRequestBehavior.AllowGet)); } } return(Json(loadResourceData, JsonRequestBehavior.AllowGet)); } else if ((command.Cmd == "r") && (command.Val == "rg")) { ResourcePresentationInSearchUtility.RegenerateResourceFile(out message); return(Json(message, JsonRequestBehavior.AllowGet)); } else if ((command.Cmd == "r") && (command.Val == "check")) { ResourcePresentationInSearchUtility.CheckResourceFile(out message); return(Json(message, JsonRequestBehavior.AllowGet)); } else if (command.Cmd == "task") { WorkUtility.CreateTask(command.Val, out message); return(Json(message, JsonRequestBehavior.AllowGet)); } else { return(Json(string.Format("ERROR!! The command \"{0}\" is not supported", command.Cmd), JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(string.Format("ERROR!! An Exception happened! e.Message:\r\n{0}", e.Message), JsonRequestBehavior.AllowGet)); } return(Json("Success", JsonRequestBehavior.AllowGet)); }
public static byte[] GetDomainObjectsConfigurationWithFakeMappingLoader() { return(ResourceUtility.GetResource(typeof(ResourceManager), "DomainObjectsConfigurationWithFakeMappingLoader.xml")); }
public static TextureBindings BindTextures(Dictionary <string, ValveMaterial> materials) { Contract.Requires(materials != null); var textures = new TextureBindings(); var images = textures.Images; foreach (string mtlName in materials.Keys) { ValveMaterial material = materials[mtlName]; Asset textureAsset = material.TextureAsset; if (textureAsset == null || textureAsset.Id == 9854798) { var linkedTo = material.LinkedTo; Color3 color; if (linkedTo.BrickColor != null) { BrickColor bc = linkedTo.BrickColor; color = bc.Color; } else if (linkedTo.Color3uint8 != null) { color = linkedTo.Color3uint8; } else { BrickColor def = BrickColor.FromNumber(-1); color = def.Color; } float r = color.R, g = color.G, b = color.B; if (!images.ContainsKey("BrickColor")) { byte[] rawImg = ResourceUtility.GetResource("Images/BlankWhite.png"); using (MemoryStream imgStream = new MemoryStream(rawImg)) { Image image = Image.FromStream(imgStream); textures.BindTexture("BrickColor", image, false); } } material.UseEnvMap = true; material.VertexColor = new Vector3(r, g, b); textures.BindTextureAlias(mtlName, "BrickColor"); } else { byte[] rawImg = textureAsset.GetContent(); using (MemoryStream imgStream = new MemoryStream(rawImg)) { Image image = Image.FromStream(imgStream); textures.BindTexture(mtlName, image); } } } return(textures); }
public static async Task <string> Compile(GameInfo gameInfo, AssemblerData data) { if (!gameInfo.ReadyToUse) { throw new Exception("This gameinfo.txt file isn't ready to use!"); } Rbx2Source.PrintHeader("COMPILING MODEL"); string studioMdlPath = gameInfo.StudioMdlPath; ThirdPartyUtility studioMdl = new ThirdPartyUtility(studioMdlPath); studioMdl.AddParameter("game", gameInfo.GameDirectory); studioMdl.AddParameter("nop4"); studioMdl.AddParameter(UtilParameter.FilePush(data.CompilerScript)); await studioMdl.Run(); Rbx2Source.MarkTaskCompleted("CompileModel"); Rbx2Source.PrintHeader("COMPILING TEXTURES"); if (!File.Exists(vtfCompilerPath)) { byte[] vtfZip = ResourceUtility.GetResource("VTFCmd.zip"); MemoryStream extract = new MemoryStream(vtfZip); ZipArchive archive = new ZipArchive(extract); foreach (ZipArchiveEntry entry in archive.Entries) { string name = entry.Name; string path = Path.Combine(utilityDir, name); Stream stream = entry.Open(); byte[] file = FileUtility.ReadFullStream(stream); FileUtility.WriteFile(path, file); } } string pngWildcard = Path.Combine(data.TextureDirectory, "*.png"); vtfCompiler = new ThirdPartyUtility(vtfCompilerPath); vtfCompiler.AddParameter("folder", pngWildcard); vtfCompiler.AddParameter("resize"); vtfCompiler.AddParameter("format", "ABGR8888"); // No compression? THIS IS FINE.png vtfCompiler.AddParameter("output", data.MaterialDirectory); await vtfCompiler.Run(); Rbx2Source.MarkTaskCompleted("CompileTextures"); string gameDirectory = gameInfo.GameDirectory; string modelPath = Path.Combine(gameDirectory, "models", data.ModelName); string materialPath = Path.Combine(gameDirectory, "materials", "models", data.CompileDirectory); FileUtility.InitiateEmptyDirectories(materialPath); foreach (string filePath in Directory.GetFiles(data.MaterialDirectory)) { FileInfo info = new FileInfo(filePath); string fileName = info.Name; string destFileName = Path.Combine(materialPath, fileName); info.CopyTo(destFileName); } Rbx2Source.MarkTaskCompleted("MoveTextures"); return(modelPath); }
public void GetResource_WithType() { var resourceBytes = ResourceUtility.GetResource(GetType(), "TestEmbeddedResource.txt"); Assert.That(resourceBytes.Length, Is.EqualTo(11)); }
public void SetConfigurationError(string culture) => ErrorMessage.Text = string.Format(ResourceUtility.GetCultureInfo(culture), ResourceUtility.GetResource <LoadingErrorStrings, LoadingErrorResourcesHelper>(culture).LoadingConfigurationErrorMessage);
private async void Launcher_Load(object sender, EventArgs e) { string myPath = Application.ExecutablePath; FileInfo myInfo = new FileInfo(myPath); try { // Check if the current process is attached to the legacy launcher, so we can phase it out. Process self = Process.GetCurrentProcess(); ManagementObjectSearcher search = new ManagementObjectSearcher(@"root\CIMV2", "SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = " + self.Id); ManagementObjectCollection results = search.Get(); var scanResults = results.GetEnumerator(); // using var because the type name is ridiculous. if (scanResults.MoveNext()) { ManagementBaseObject query = scanResults.Current; uint parentId = (uint)query.GetPropertyValue("ParentProcessId"); Process parent = Process.GetProcessById((int)parentId); string parentPath = parent.MainModule.FileName; FileInfo info = new FileInfo(parentPath); if (info.Name == "Rbx2Source.exe" || info.Name == "Rbx2SourceLauncher.exe") { await setStatus("Phasing out the legacy launcher"); parent.Kill(); parent.WaitForExit(); File.Copy(myPath, parentPath, true); Process.Start(parentPath); Application.Exit(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } string myName = myInfo.Name; string dir = myInfo.DirectoryName; if (myName.StartsWith("NEW_")) { string newPath = Path.Combine(dir, myName.Substring(4)); File.Copy(myInfo.FullName, newPath, true); Process.Start(newPath); Application.Exit(); } else { foreach (string filePath in Directory.GetFiles(dir)) { FileInfo info = new FileInfo(filePath); string fileName = info.Name; if (fileName.StartsWith("NEW_") && info.Extension.ToLower() == "exe") { File.Delete(info.FullName); break; } } } await setStatus("Checking for updates"); string latestVersion = await GetGitHubString("version.txt"); string myVersion = Settings.GetSetting <string>("CurrentVersion"); if (latestVersion != myVersion) { await setStatus("Updating Rbx2Source"); Settings.SetSetting("CurrentVersion", latestVersion); Settings.Save(); byte[] newVersion = await GetGitHubFile("Rbx2Source.exe"); string updatePath = Path.Combine(dir, "NEW_" + myName); File.WriteAllBytes(updatePath, newVersion); Process.Start(updatePath); Application.Exit(); } await setStatus("Checking for required DLL files"); bool addedLibraries = false; foreach (string library in ResourceUtility.GetFiles("Libraries")) { string libName = library.Replace("Libraries/", ""); string libPath = Path.Combine(dir, libName); if (!File.Exists(libPath)) { byte[] content = ResourceUtility.GetResource(library); addedLibraries = true; File.WriteAllBytes(libPath, content); } } if (addedLibraries) { Application.Restart(); } await setStatus("Starting Rbx2Source"); Rbx2Source rbx2Source = new Rbx2Source(); rbx2Source.baseProcess = this; await Task.Delay(1000); rbx2Source.Show(); await Task.Delay(50); Hide(); }
public static byte[] GetDomainObjectsConfigurationWithCustomSectionGroupName() { return(ResourceUtility.GetResource(typeof(ResourceManager), "DomainObjectsConfigurationWithCustomSectionGroupName.xml")); }
public static byte[] GetDomainObjectsConfigurationWithMinimumSettings() { return(ResourceUtility.GetResource(typeof(ResourceManager), "DomainObjectsConfigurationWithMinimumSettings.xml")); }
public static byte[] GetDomainObjectsConfigurationWithMixedStorageObjectFactory() { return(ResourceUtility.GetResource(typeof(ResourceManager), "DomainObjectsConfigurationWithMixedStorageObjectFactory.xml")); }
private async void Launcher_Load(object sender, EventArgs e) { string myPath = Application.ExecutablePath; FileInfo myInfo = new FileInfo(myPath); string myName = myInfo.Name; string dir = myInfo.DirectoryName; if (myName.StartsWith("NEW_")) { string newPath = Path.Combine(dir, myName.Substring(4)); File.Copy(myInfo.FullName, newPath, true); Process.Start(newPath); Application.Exit(); } else { foreach (string filePath in Directory.GetFiles(dir)) { FileInfo info = new FileInfo(filePath); string fileName = info.Name; if (fileName.StartsWith("NEW_") && info.Extension.ToLower() == "exe") { File.Delete(info.FullName); break; } } } setStatus("Checking for updates"); string latestVersion = await GetGitHubString("version.txt"); string myVersion = Settings.GetSetting <string>("CurrentVersion"); if (latestVersion != myVersion) { setStatus("Updating Rbx2Source"); byte[] newVersion = await GetGitHubFile("Rbx2Source.exe"); string updatePath = Path.Combine(dir, "NEW_" + myName); File.WriteAllBytes(updatePath, newVersion); Settings.SaveSetting("CurrentVersion", latestVersion); Process.Start(updatePath); Application.Exit(); } bool addedLibraries = false; setStatus("Checking for required DLL files"); foreach (string library in ResourceUtility.GetFiles("Libraries")) { string libName = library.Replace("Libraries/", ""); string libPath = Path.Combine(dir, libName); if (!File.Exists(libPath)) { byte[] content = ResourceUtility.GetResource(library); addedLibraries = true; File.WriteAllBytes(libPath, content); } } if (addedLibraries) { await Task.Delay(1000); Application.Restart(); } setStatus("Starting Rbx2Source"); await Task.Delay(500); Rbx2Source rbx2Source = null; Task startRbx2Source = Task.Run(() => { rbx2Source = new Rbx2Source(); rbx2Source.baseProcess = this; }); await startRbx2Source; rbx2Source.Show(); Hide(); }
public static byte[] GetImage2() { return(ResourceUtility.GetResource(typeof(ResourceManager), "Image2.png")); }
public static string GetText(string text, string integratedFontName = null) { var resource = ResourceUtility.GetResource <FigletTransform>($"Fonts.{integratedFontName ?? "cybermedium"}.flf"); return(GetText(text, resource)); }
public static TextureAssembly AssembleTextures(Dictionary <string, Material> materials) { TextureAssembly assembly = new TextureAssembly(); Dictionary <string, Image> images = new Dictionary <string, Image>(); assembly.Images = images; Dictionary <string, string> matLinks = new Dictionary <string, string>(); assembly.MatLinks = matLinks; foreach (string mtlName in materials.Keys) { Material material = materials[mtlName]; Asset textureAsset = material.TextureAsset; if (textureAsset == null) { string bcName = "Institutional white"; int brickColor = material.LinkedTo.BrickColor; if (BrickColors.NumericalSearch.ContainsKey(brickColor)) { BrickColor color = BrickColors.NumericalSearch[brickColor]; float r = color.R / 255.0f; float g = color.G / 255.0f; float b = color.B / 255.0f; material.VertexColor = new Vector3(r, g, b); bcName = color.Name; } else { material.VertexColor = new Vector3(1, 1, 1); } if (!images.ContainsKey("BrickColor")) { byte[] rawImg = ResourceUtility.GetResource("Images/BlankWhite.png"); using (MemoryStream imgStream = new MemoryStream(rawImg)) { Image image = Image.FromStream(imgStream); images.Add("BrickColor", image); } } string matKey = serializeBrickColorMtl(material); material.UseReflectance = true; matLinks.Add(mtlName, matKey); } else { byte[] rawImg = textureAsset.GetContent(); using (MemoryStream imgStream = new MemoryStream(rawImg)) { Image image = Image.FromStream(imgStream); images.Add(mtlName, image); matLinks.Add(mtlName, mtlName); } } } return(assembly); }