public void GenerateSummarizedStyleTest4() { //Arrange Style style1 = new Style(); style1.FontName = "Arial"; Style style2 = new Style(); style2.FontName = "MS Serif"; Style[] allStyles = { style1, style2 }; StyleAssignment styleAssign = new StyleAssignment(); styleAssign.StyleIndex = 0; styleAssign.StyleName = "HeadingStyle"; styleAssign.NamedStyleIndex = 1; NamedStyle namedStyle = new NamedStyle(); namedStyle.Style = style2; string expectedResult = "Arial"; List <NamedStyle> namedStyles = new List <NamedStyle>(); namedStyles.Add(namedStyle); //Act XElement element = Utilities.GenerateSummarizedStyle(allStyles, namedStyles, styleAssign); string actualResult = element.Attribute("FontName").Value; //Assert Assert.AreEqual(expectedResult, actualResult); }
public async Task <IStyleSheet?> GetStyleForVisualAsync(IVisualElement visual, IAttributeDictionary attributeDictionary) { if (TryGetExistingStyle(visual, out var existing)) { return(existing); } var vType = visual.GetType(); if (attributeDictionary.TryGetAttributeValue("class", out var className) && !String.IsNullOrEmpty(className)) { var typeStyles = GetOrBuildTypeStyleRules(vType); var classRules = new HashSet <IStyleRule>(); await foreach (var r in GetStylesByClassNameAsync(className)) { classRules.Add(r); } foreach (var r in typeStyles) { classRules.Add(r); } var res = new NamedStyle(className, classRules); _typeClassStyles[vType, className] = res; return(res); } if (attributeDictionary.TryGetAttributeValue("Style", out var styleName)) { var typeStyles = GetOrBuildTypeStyleRules(vType); var rules = await GetStyleByNameAsync(styleName); if (rules != null) { if (typeStyles.Count > 0) { return(rules.AddDefaultRules(typeStyles)); } return(rules); } } // the visual should have had no class/Style specified by the time we get here return(GetOrBuildTypeStyle(vType)); }
public void ReadNamedStyleInfoTest() { // Arrange FrxReader frxReader = new FrxReader(); frxReader.FrxFile = new byte[] { 0x4E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x00, 0x06, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1C, 0xDE, 0xFB, 0x04, 0x60, 0x0C, 0xAA, 0x06, 0x00, 0x0B, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; TrueDBGrid grid = new TrueDBGrid(); grid.AllStyles = new Style[]{ new Style() }; // Act frxReader.ReadNamedStyleInfo(grid, 1); NamedStyle namedStyle = grid.NamedStyles[0]; bool actualResult = namedStyle.Name == "Normal" && namedStyle.Index == 1; // Assert Assert.IsTrue(actualResult); }
void UpdateExample(NamedStyle Style) { lb_Example.Font = Style.Font; lb_Example.ForeColor = Style.ForeColor; lb_Example.BackColor = Style.BackColor; }