public void CanParse() { // ARRANGE var provider = new StylesheetProvider(TestHelper.TestBaseMapcssFile, TestHelper.GetFileSystemService()); // ACT & ASSERT var stylesheet = provider.Get(); Assert.AreEqual(9, stylesheet.Count); var testStyle1 = MapCssHelper.GetStyles(stylesheet)[1]; Assert.AreEqual(2, testStyle1.Selectors.Count); Assert.AreEqual(7, testStyle1.Declarations.Count); var testSelector1 = testStyle1.Selectors.First(); Assert.AreEqual("man_made", testSelector1.Tag); Assert.AreEqual("tower", testSelector1.Value); Assert.AreEqual("=", testSelector1.Operation); var testSelector2 = testStyle1.Selectors.Last(); Assert.AreEqual("building", testSelector2.Tag); Assert.AreEqual("OP_EXIST", testSelector2.Operation); var lastStyle = MapCssHelper.GetStyles(stylesheet)[7]; Assert.AreEqual(2, lastStyle.Selectors.Count); Assert.AreEqual(1, lastStyle.Declarations.Count); }
public override void Draw(RectangleF rect) { var context = UIGraphics.GetCurrentContext(); MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this); context.SaveState(); styleSheet.BackgroundColorForMessageType(MessageType).SetColor(); context.FillRect(rect); context.RestoreState(); context.SaveState(); context.BeginPath(); context.MoveTo(0, rect.Size.Height); context.SetStrokeColorWithColor(styleSheet.StrokeColorForMessageType(MessageType).CGColor); context.SetLineWidth(1); context.AddLineToPoint(rect.Size.Width, rect.Size.Height); context.StrokePath(); context.RestoreState(); context.SaveState(); float xOffset = Padding; float yOffset = Padding; if (!ShowFromBottom) { yOffset += GetStatusBarFrame().Height; } styleSheet.IconImageForMessageType(MessageType).Draw(new RectangleF(xOffset, yOffset, IconSize, IconSize)); context.SaveState(); yOffset -= TextOffset; xOffset += IconSize + Padding; SizeF titleLabelSize = TitleSize(); if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Description)) { yOffset = (float)(Math.Ceiling((double)rect.Size.Height * 0.5) - Math.Ceiling((double)titleLabelSize.Height * 0.5) - TextOffset); } TitleColor.SetColor(); var titleRectangle = new RectangleF(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height); Title.DrawString(titleRectangle, TitleFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); yOffset += titleLabelSize.Height; SizeF descriptionLabelSize = DescriptionSize(); DescriptionColor.SetColor(); var descriptionRectangle = new RectangleF(xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height); Description.DrawString(descriptionRectangle, DescriptionFont, UILineBreakMode.TailTruncation, UITextAlignment.Left); }
public static Stylesheet GetStylesheetFromFile(string file, bool canUseExprTree = true) { var provider = new StylesheetProvider(file, TestHelper.GetFileSystemService()); var config = new Mock <IConfigSection>(); config.Setup(c => c.GetBool(It.IsAny <string>(), false)).Returns(!canUseExprTree); config.Setup(c => c.GetString(It.IsAny <string>(), null)).Returns(file); provider.Configure(config.Object); return(provider.Get()); }
public void CanCreate() { // ARRANGE var provider = new StylesheetProvider(TestHelper.TestBaseMapcssFile, TestHelper.GetFileSystemService()); // ACT var stylesheet = provider.Get(); // ASSERT Assert.IsNotNull(stylesheet); }
public static Stylesheet GetStylesheetFromContent(string content, bool canUseExprTree = true) { var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(content); writer.Flush(); stream.Position = 0; var provider = new StylesheetProvider(stream, canUseExprTree); return(provider.Get()); }
public void CanUseClosed() { // ARRANGE var provider = new StylesheetProvider(TestHelper.TestBaseMapcssFile, TestHelper.GetFileSystemService()); var stylesheet = provider.Get(); var closedWay = new Way { Points = new List <GeoCoordinate>() { new GeoCoordinate(0, 0), new GeoCoordinate(1, 0), new GeoCoordinate(1, 0), new GeoCoordinate(0, 0) }, Tags = new Dictionary <string, string>() { { "barrier", "yes" } }.ToTags() }; var openWay = new Way { Points = new List <GeoCoordinate>() { new GeoCoordinate(0, 0), new GeoCoordinate(1, 0), new GeoCoordinate(1, 0), new GeoCoordinate(0, 1) }, Tags = new Dictionary <string, string>() { { "barrier", "yes" } }.ToTags() }; // ACT & ASSERT Assert.IsTrue(stylesheet.GetModelRule(closedWay, MapConsts.MaxZoomLevel).IsApplicable); Assert.IsFalse(stylesheet.GetModelRule(openWay, MapConsts.MaxZoomLevel).IsApplicable); }
public void CanGetBuildingStyle() { // ARRANGE var provider = new StylesheetProvider(TestHelper.DefaultMapcssFile, TestHelper.GetFileSystemService()); var stylesheet = provider.Get(); var tags = new TagCollection(); tags.Add("building", "residential"); var building = new Area() { Id = 1, Points = new List <GeoCoordinate>(), Tags = tags.AsReadOnly() }; // ACT var rule = stylesheet.GetModelRule(building, MapConsts.MaxZoomLevel); var style = rule.GetFacadeBuilder(); // ASSERT Assert.AreEqual("default", style); }
public override void Draw(CGRect rect) { var context = UIGraphics.GetCurrentContext(); MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this); context.SaveState(); styleSheet.BackgroundColorForMessageType(MessageType).SetColor(); context.FillRect(rect); context.RestoreState(); context.SaveState(); context.BeginPath(); context.MoveTo(0, rect.Size.Height); context.SetStrokeColor(styleSheet.StrokeColorForMessageType(MessageType).CGColor); context.SetLineWidth(1); context.AddLineToPoint(rect.Size.Width, rect.Size.Height); context.StrokePath(); context.RestoreState(); context.SaveState(); nfloat xOffset = Padding; nfloat yOffset = Padding; var icon = styleSheet.IconImageForMessageType(MessageType); if (icon != null) { icon.Draw(new CGRect(xOffset, yOffset, IconSize, IconSize)); } context.SaveState(); yOffset -= TextOffset; xOffset += (icon == null ? 0 : IconSize) + Padding; CGSize titleLabelSize = TitleSize(); if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Description)) { yOffset = (float)(Math.Ceiling((double)rect.Size.Height * 0.5) - Math.Ceiling((double)titleLabelSize.Height * 0.5) - TextOffset); } TitleColor.SetColor(); var titleRectangle = new CGRect(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height); Title.DrawString(titleRectangle, new UIStringAttributes { Font = TitleFont, ForegroundColor = TitleColor }); yOffset += titleLabelSize.Height; CGSize descriptionLabelSize = DescriptionSize(); DescriptionColor.SetColor(); var descriptionRectangle = new CGRect(xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height); Description.DrawString(descriptionRectangle, new UIStringAttributes { Font = DescriptionFont, ForegroundColor = DescriptionColor }); }