public void CanReadEmbeddedResource() { var got = ResourceExtensions.ReadEmbeddedResource(@"res\test-file-01.txt", Assembly.GetExecutingAssembly()); output.WriteLine(got); Assert.NotNull(got); }
private void GetReport(List <NodeItem> nodes) { int entityFound = GetEntityCount(nodes); int realPropTotal = 0; int idealPropTotal = 0; decimal percentage; foreach (var node in nodes) { realPropTotal += GetRealPropCount(node); idealPropTotal += GetIdealPropCount(node); } if (realPropTotal != 0 && idealPropTotal != 0) { percentage = Math.Round(((decimal)realPropTotal / idealPropTotal) * 100, 2); } else { percentage = 0; } Keyword = $"{percentage}%"; KeywordDescription = $"{ResourceExtensions.GetLocalized("ReportInfo_Presence")}"; OriginalInfo = $"{entityFound} {ResourceExtensions.GetLocalized("ReportInfo_EntityFound")}"; TraitedInfo = $"{realPropTotal} {ResourceExtensions.GetLocalized("ReportInfo_PropertyFound")}"; }
public static string GetResource(string arg) { //There is an overload of GetResourceString that uses Cvent.Framework.Shared var resource = ResourceExtensions.GetResourceString(arg, 1033); return(resource); }
public ImageSet GetImages(string id) { if (this.managerImages == null) { this.managerImages = (IDictionary <string, ImageSet>) new Dictionary <string, ImageSet>(); string @string = ResourceExtensions.GetString(this.Resources["Microsoft.MediaCenter.Shell.dll"].GetResource("IMAGES.MCML", (object)10), Encoding.UTF8); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(@string); XmlNodeList childNodes = xmlDocument.DocumentElement.ChildNodes; for (int index = 0; index < childNodes.Count; ++index) { XmlElement element = childNodes[index] as XmlElement; if (element != null) { ImageSet imageSet = ImageSet.FromXml(this.Resources, element); if (imageSet.Name != null) { this.managerImages[imageSet.Name] = imageSet; } } } } ImageSet imageSet1; this.managerImages.TryGetValue(id, out imageSet1); if (imageSet1 == null) { Trace.TraceWarning("Could not find image set {0}.", new object[1] { (object)id }); } return(imageSet1); }
public void CanReadLibraryResource() { var got = ResourceExtensions.ReadLibraryResource(@"res\license.txt"); output.WriteLine(got); Assert.NotNull(got); }
/// <summary> /// Copy the given resource file into a given base folder. /// </summary> private void CopyResourceToFolder(string folder, string resourceFile, ResourceType resourceType) { var outputPath = ResourceExtensions.GetNormalizedResourcePath(folder, resourceFile, resourceType); var outputFolder = Path.GetDirectoryName(outputPath); if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } // Collect last modification date var modified = File.GetLastWriteTime(resourceFile); if (modified > lastModified) { lastModified = modified; } // Copy the resource file File.Copy(resourceFile, outputPath, true); // Make sure file is not readonly. File.SetAttributes(outputPath, FileAttributes.Normal); // Post process ProcessResource(outputPath, resourceType); }
protected override void Load() { string attribute1 = this.XmlElement.GetAttribute("Title"); int stringResourceId = MediaCenterUtil.GetMagicStringResourceID(attribute1); if (stringResourceId >= 0) { string stringResource = ResourceExtensions.GetStringResource(this.Manager.Resources["ehres.dll"], stringResourceId); if (stringResource != null) { this.originalTitle = stringResource; } } if (this.originalTitle == null) { this.originalTitle = attribute1; } this.Title = this.originalTitle; string attribute2 = this.XmlElement.GetAttribute("Icon"); this.images = ((DefaultStartMenuManager)this.Manager).GetImages(attribute2); if (this.images == null) { throw new ApplicationException("Could not find image set \"" + attribute2 + "\"."); } this.SetValue(XmlQuickLink.ImageProperty, (object)this.images["Focus"]); this.SetValue(XmlQuickLink.NonFocusImageProperty, (object)this.images["Default"]); string attribute3 = this.XmlElement.GetAttribute("Visible"); bool result; this.IsEnabled = string.IsNullOrEmpty(attribute3) || bool.TryParse(attribute3, out result) && result; this.originalStripID = this.XmlElement.GetAttribute("AppId"); this.originalStrip = (DefaultMenuStrip)null; }
private void InitializeSearchEngine() { logger.Trace("Initializing search engine"); var stopwords = ResourceExtensions.GetResource(stopwords_filename); search_engine.Initialize(stopwords); }
public void AddResourceFileDifferences(string baseResourcesPath, string modifiedResourcesPath) { using (UnmanagedLibrary unmanagedLibrary1 = new UnmanagedLibrary(baseResourcesPath)) { using (UnmanagedLibrary unmanagedLibrary2 = new UnmanagedLibrary(modifiedResourcesPath)) { string fileName = Path.GetFileName(baseResourcesPath); foreach (IResource resource in Enumerable.Where <IResource>(unmanagedLibrary2[(object)10], (Func <IResource, bool>)(o => o.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase)))) { bool flag1 = true; byte[] bytes1 = ResourceExtensions.GetBytes(unmanagedLibrary1.GetResource(resource.Name, (object)10)); byte[] bytes2 = ResourceExtensions.GetBytes(resource); if (bytes1 != null && bytes1.Length == bytes2.Length) { bool flag2 = true; for (int index = 0; index < bytes1.Length; ++index) { if ((int)bytes1[index] != (int)bytes2[index]) { flag2 = false; break; } } flag1 = !flag2; } if (flag1) { this.ThemeItems.Add((IThemeItem) new ImageResourceThemeItem(fileName, resource.Name, bytes2)); } } } } }
public static IPromise PreloadAll() { var types = GetTypes(); var preloadPromises = types.Select(t => { var argName = t.Name; if (t.IsSubclassOf(typeof(AddressableSingletonAsset))) { return(AddressableExtensions.LoadAsync <AddressableSingletonAsset>(argName)); } else { return(ResourceExtensions.LoadAsync(argName)); } }); return(Promise.All(preloadPromises) .ThenDo <object[]>(assets => { for (var i = 0; i < assets.Length; i++) { var singletonAsset = (SingletonAsset)assets[i]; AssetDictionary.Add(types[i], singletonAsset); } })); }
protected override void InitializePage() { base.InitializePage(); this.RouteNames = Request.GetRouteNames(); this.Flash = MvcFlash.Core.Flash.Instance; string controller = Request.RequestContext.RouteData.GetRequiredString("controller"); string action = Request.RequestContext.RouteData.GetRequiredString("action"); IHtmlString controllerName = new HtmlString(ResourceExtensions.ResourceString(Context, "Common", controller)); IHtmlString actionName = new HtmlString(ResourceExtensions.ResourceString(Context, "Common", action)); Page.Description = string.Format("{0} :: {1}", controllerName, actionName); object areaDataToken = null; if (Request.RequestContext.RouteData.DataTokens.TryGetValue("area", out areaDataToken)) { IHtmlString areaName = new HtmlString(ResourceExtensions.ResourceString(Context, "Common", areaDataToken.ToString())); Page.Title = string.Format("{0} :: {1} :: {2} | {3}", areaName, controllerName, actionName, Context.Request.Url.Host); } else { Page.Title = string.Format("{0} :: {1} | {2}", controllerName, actionName, Context.Request.Url.Host); } }
public void UpdateDefaultLanguage() { if (!string.IsNullOrEmpty(SelectedDomain)) { string languangeCode = DomainDic[SelectedDomain].Domain.DefaultLanguageCode; DefaultLanguage = $"{ResourceExtensions.GetLocalized("ClassificationPage_DefaultLanguage")}: {LanguageDic[languangeCode]}"; } }
private void OnFileDragOver(object sender, Windows.UI.Xaml.DragEventArgs e) { e.AcceptedOperation = DataPackageOperation.Copy; e.DragUIOverride.Caption = ResourceExtensions.GetLocalized("Tool_OnFileDragOver"); e.DragUIOverride.IsGlyphVisible = true; e.DragUIOverride.IsContentVisible = true; e.DragUIOverride.IsCaptionVisible = true; this.DragDropPanel.Opacity = 0.5; }
public JsonResult <CustomerOrderFormSearchResult> CustomerOrderFormSearch(CustomerOrderFormSearchModel Model_) { CustomerOrderFormSearchResult ret_ = new CustomerOrderFormSearchResult(); ret_.Errors.Add(ResourceExtensions.Language("SHARED_MESSAGE_SESSIONCLOSED")); return(OK(ret_)); //Better to return Ok in your search result // If you want validation use NotFound() or something slimier to that }
/// <summary> /// Use the original resource name (if available). /// </summary> private string UnfixResourceName(string key) { if (key.StartsWith(androidPrefix)) { key = key.Substring(androidPrefix.Length); } var pair = resources.FirstOrDefault(x => ResourceExtensions.GetNormalizedResourceName(x.Item1, ResourceType.Unknown) == key); return (pair != null) ? ConfigurationQualifiers.StripQualifiers(pair.Item1, true, false) : key.Replace(' ', '_'); }
public static List <Step> GenerateIfcValidatorSteps() { List <Step> steps = new List <Step>(); steps.Add(new Step(1, ResourceExtensions.GetLocalized("ValidatorPage_Step1"), true)); steps.Add(new Step(2, ResourceExtensions.GetLocalized("ValidatorPage_Step2"))); steps.Add(new Step(3, ResourceExtensions.GetLocalized("ValidatorPage_Step3"))); steps.Add(new Step(4, ResourceExtensions.GetLocalized("ValidatorPage_Step4"))); return(steps); }
private void InitializeSpellChecker() { logger.Trace("Initializing spell checker"); var en_aff = ResourceExtensions.GetResource(aff_filename); var en_aff_data = Encoding.ASCII.GetBytes(en_aff); var en_dic = ResourceExtensions.GetResource(dic_filename); var en_dic_data = Encoding.ASCII.GetBytes(en_dic); SpellChecker.Default.HunspellInstance = new Hunspell(en_aff_data, en_dic_data); }
// Preperation Methods /// <summary> /// Sets up a new document for use in this ViewModel /// </summary> private void PrepareNewDocument() { TextDataModel emptyData = new TextDataModel(); emptyData.DocumentTitle = ResourceExtensions.GetLocalized("UnititledLabel"); Data = emptyData; File = null; SetEditedFalse(); RefreshTitlebarTitle(); }
private static ThemeSummary[] GetAppliedThemes(IResourceLibraryCache cache) { IResource resource = cache["ehres.dll"].GetResource("VmcStudio.Themes.xml", (object)23); if (!resource.Exists(new ushort?())) { return(new ThemeSummary[0]); } using (MemoryStream memoryStream = new MemoryStream(ResourceExtensions.GetBytes(resource))) return(((ThemeManager.AppliedThemesDocument) new XmlSerializer(typeof(ThemeManager.AppliedThemesDocument)).Deserialize((Stream)memoryStream)).AppliedThemes); }
public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache) { ResourceThemeItem resourceThemeItem = (ResourceThemeItem)themeItem; byte[] data = resourceThemeItem.Save(false); if (data == null || data.Length <= 0) { return; } ResourceExtensions.Update(writeCache[resourceThemeItem.DllName].GetResource(resourceThemeItem.ResourceName, (object)resourceThemeItem.ResourceType), data); }
private void MainViewModel_ShareDataRequested(DataTransferManager sender, DataRequestedEventArgs args) { // Show the Share UI DataRequest request = args.Request; // Set the metadata request.Data.Properties.Title = Windows.ApplicationModel.Package.Current.DisplayName; request.Data.Properties.Description = (ResourceExtensions.GetLocalized("ShareDescription") + " " + FilesToShare[0].Name); // Set the StorageItem request.Data.SetStorageItems(FilesToShare); }
public static XmlReader GetXml(this IResource res) { byte[] bytes = ResourceExtensions.GetBytes(res); if (bytes != null) { return(MediaCenterUtil.GetXmlResource(bytes)); } else { return((XmlReader)null); } }
public static string GetMagicString(IResourceLibraryCache cache, string proc, out int resourceID) { resourceID = MediaCenterUtil.GetMagicStringResourceID(proc); if (resourceID >= 0) { string stringResource = ResourceExtensions.GetStringResource(cache["ehres.dll"], resourceID); if (stringResource != null) { return(stringResource); } } return(proc); }
public static byte[] GetResource(IResourceLibraryCache cache, string uri, int resourceType, out string resourceName) { string dll; if (MediaCenterUtil.TryParseResourceUri(uri, out dll, out resourceName)) { return(ResourceExtensions.GetBytes(cache[dll].GetResource(resourceName, (object)resourceType))); } else { throw new Exception("Could not find resource: " + uri); } }
private void LoadLanguages() { var response = new LanguageApi(LocalData.baseHttp).ApiLanguageV1Get(); List <string> languages = new List <string>(); languages.Add(ResourceExtensions.GetLocalized("ClassificationPage_AllLanguage")); foreach (var item in response) { LanguageDic.Add(item.IsoCode, item.Name); languages.Add($"{item.Name} ({item.IsoCode})"); } _languages = new BindableCollection <string>(languages); }
private void UpdateSelecedClassesNotice() { if (_selectedClasses.Count > 0) { SelectedNotice = $"{ResourceExtensions.GetLocalized("ClassificationPage_Selected")}: {_selectedClasses.Count}"; HasSelection = true; } else { SelectedNotice = null; HasSelection = false; } }
public async Task <Stream> GetWidgetAsync(LootWidgetOptions lootWidgetOptions) { var headerStream = ResourceExtensions.GetStreamCopy(typeof(Program), "RS3Bot.Cli.Images.Loot_Head.png"); using (var headerImage = Image.FromStream(headerStream)) using (var footerStream = ResourceExtensions.GetStreamCopy(typeof(Program), "RS3Bot.Cli.Images.Loot_Footer.png")) using (var footerImage = Image.FromStream(footerStream)) { var rowAmount = (int)Math.Ceiling(lootWidgetOptions.Items.Count / (double)MaxRowSize); var headerHeight = headerImage.Height; using (var lootImage = new Bitmap(headerImage.Width, headerHeight + (rowAmount * RowHeight) + FooterHeight)) using (var font = new Font(_fontCollection.Families[0], 8)) using (var titleFont = new Font(_fontCollection.Families[0], 12)) using (var rowStream = ResourceExtensions.GetStreamCopy(typeof(Program), "RS3Bot.Cli.Images.Loot_Row.png")) using (var rowImage = Image.FromStream(rowStream)) using (Graphics g = Graphics.FromImage(lootImage)) { g.DrawImage(headerImage, 0, 0); for (int i = 0; i < lootWidgetOptions.Items.Count; i++) { var row = (int)Math.Floor(i / (double)MaxRowSize); var addNewRow = i % MaxRowSize == 0; var itemX = 20 + ((i % MaxRowSize) * 45); var itemY = 45 + (row * RowHeight); var item = lootWidgetOptions.Items[i]; if (addNewRow) { g.DrawImage(rowImage, 0, headerHeight + (row * RowHeight)); } using (var itemStream = await _imageGrabber.GetAsync(item.Item.ItemId)) using (var imageStream = Image.FromStream(itemStream)) using (SolidBrush drawBrush = new SolidBrush(StackFormatter.GetColor(item.Item.Amount))) { var horizontalCenter = itemY + ((32 - imageStream.Height) / 2); var verticalCenter = itemX + ((32 - imageStream.Width) / 2); g.DrawImage(imageStream, verticalCenter, horizontalCenter, imageStream.Width, imageStream.Height); g.DrawString(StackFormatter.QuantityToRSStackSize((long)item.Item.Amount), font, drawBrush, itemX - 7, itemY - 4); } } g.DrawImage(footerImage, 0, lootImage.Height - FooterHeight); headerStream.Position = 0; lootImage.Save(headerStream, System.Drawing.Imaging.ImageFormat.Png); headerStream.Position = 0; } return(headerStream); } }
/// <summary> /// Process the output of AAPT to display property errors in VisualStudio. /// </summary> private static void ProcessAaptErrors(string output, string tempFolder, List <Tuple <string, ResourceType> > resources) { #if DEBUG //Debugger.Launch(); #endif const string errorPrefix = "Error: "; const string errorLevel = "error"; var lines = output.Split(new[] { '\n', '\r' }); var paths = resources.Select(x => Tuple.Create(x.Item1, ResourceExtensions.GetNormalizedResourcePath(tempFolder, x.Item1, x.Item2))).ToList(); foreach (var line in lines) { var parts = SplitAaptErrorLine(line.Trim(), 4).ToArray(); int lineNr; if ((parts.Length < 4) || !int.TryParse(parts[1], out lineNr)) { if (line.Length > 0) { Console.WriteLine(line); } continue; } // src:line:severity:remaining var msg = parts[3].Trim(); if (msg.StartsWith(errorPrefix)) { msg = msg.Substring(errorPrefix.Length); } var url = parts[0]; var level = parts[2].Trim(); var pathEntry = paths.FirstOrDefault(x => x.Item2 == url); url = (pathEntry != null) ? pathEntry.Item1 : url; switch (level.ToLowerInvariant()) { case errorLevel: DLog.Error(DContext.ResourceCompilerAaptError, url, 0, lineNr, msg); break; default: DLog.Warning(DContext.ResourceCompilerAaptError, url, 0, lineNr, msg); break; } //Console.WriteLine(line); // DEBUG PURPOSES } }
/// <summary> /// Method which performs the work of the background task. /// </summary> /// <param name="taskInstance">The interface to an instance of the background task</param> private async void Update(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); #if !DEBUG if (!(DateTime.Today.Month == 7 || DateTime.Today.Month == 8)) #else if (true) #endif { PasswordCredential credential = SecurityExtensions.RetrieveCredentials(); if (credential != null) { credential.RetrievePassword(); try { TileUpdateManager.CreateTileUpdaterForApplication().Clear(); ToastNotificationManager.History.Clear(); using (ClientExtensions client = new ClientExtensions()) { await client.AuthenticateAndInitDataAsync(new UserCredentials(credential.UserName, credential.Password), false); CheckAndSendNotification(BackgroundTaskExtensions.EVENTS, client.AccountDetails.AbsenceEvents.Count(item => !item.IsJustified), "AbsenceNotification".GetLocalized()); CheckAndSendNotification(BackgroundTaskExtensions.APPOINTMENTS, client.AccountDetails.AgendaEvents.Count, "AgendaNotification".GetLocalized()); CheckAndSendNotification(BackgroundTaskExtensions.DIDACTICS, client.AccountDetails.DidacticsItems.Count, "DidactictNotification".GetLocalized()); CheckAndSendNotification(BackgroundTaskExtensions.GRADES, client.AccountDetails.Grades.Count, "GradeNotification".GetLocalized()); CheckAndSendNotification(BackgroundTaskExtensions.NOTES, client.AccountDetails.Notes.Count, "NoteNotification".GetLocalized()); CheckAndSendNotification(BackgroundTaskExtensions.ITEMS, client.AccountDetails.NoticeboardItems.Count, "NoticeboardNotification".GetLocalized()); } } catch (Exception) { // } } } else { ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.EVENTS, 0); ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.APPOINTMENTS, 0); ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.DIDACTICS, 0); ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.GRADES, 0); ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.NOTES, 0); ResourceExtensions.StoreRoamingObject(BackgroundTaskExtensions.ITEMS, 0); } deferral.Complete(); }
private void NextBtn_Click(object sender, RoutedEventArgs e) { int step = StepServices.GetCompletedStepCount(ViewModel.Steps); switch (step) { case 1: if (classificationPage.ViewModel.HasSelection) { propertyPage.ViewModel.GetAllProperties(classificationPage.ViewModel.SelectedClasses); propertyPage.UpdateSelection(); Workspace1.Content = propertyPage; StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoClasses")); } break; case 2: if (propertyPage.ViewModel.HasSelection) { LocalConfig.SaveConfigFile(propertyPage.ViewModel.SelectedClasses); Workspace1.Content = inputFilePage; StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoProps")); } break; case 3: if (inputFilePage.ViewModel.InputFiles.Count > 0) { reportPage.ViewModel.LoadReport(inputFilePage.ViewModel.InputFiles, propertyPage.ViewModel.SelectedClasses); StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); Workspace1.Content = reportPage; } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoFile")); } break; default: break; } }