private void radioButton_CheckedChanged(object sender, EventArgs e) { ShapeFileFeatureLayer austinStreetsLayer = ((LayerOverlay)winformsMap1.Overlays["AustinStreetsOverlay"]).Layers["AustinStreetsLayer"] as ShapeFileFeatureLayer; austinStreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear(); austinStreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(LineStyles.LocalRoad1); if (rbnSingleStyle.Checked) { austinStreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.LocalRoad1("[FENAME] [FETYPE] [FRADDL]-[TOADDL]")); } else { TextStyle primaryTextStyle = TextStyles.LocalRoad1("[FENAME] [FETYPE]"); primaryTextStyle.XOffsetInPixel = 0; TextStyle secondaryTextStyle = TextStyles.LocalRoad1("[FRADDL]-[TOADDL]"); secondaryTextStyle.YOffsetInPixel = 15; secondaryTextStyle.Font = new GeoFont("Arial", 7); secondaryTextStyle.Mask = AreaStyles.County1; secondaryTextStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping; secondaryTextStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels; austinStreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(primaryTextStyle); austinStreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(secondaryTextStyle); } winformsMap1.Refresh(); }
/// <summary> /// Gets an overlay applied with ZedGraph style. /// </summary> public static LayerOverlay GetOverlayWithZedGraphStyle() { // Get the file path name from its relative path. string shpFilePathName = GetFullPath(@"App_Data/MajorCities.shp"); ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(shpFilePathName); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; TextStyle textStyle = TextStyles.CreateSimpleTextStyle("AREANAME", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.SimpleColors.White, 2, -20, 40); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new PieChartStyle()); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle); shapeFileFeatureLayer.DrawingMarginInPixel = 100; // Apply projection to the shape file which is used for display. Proj4Projection Proj4Projection = new Proj4Projection(); Proj4Projection.InternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString(); Proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString(); shapeFileFeatureLayer.FeatureSource.Projection = Proj4Projection; LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add(shapeFileFeatureLayer); return(layerOverlay); }
private void OnCheckStyle(bool isChecked) { var replacementSelected = ReplacementTextStyles.Count(x => x.IsSelected) > 0; foreach (var d in ReplacementTextStyles) { if (replacementSelected) { d.IsEnabled = d.IsSelected; continue; } d.IsEnabled = !TextStyles.Where(x => x.IsSelected).Contains(d); } // if none of the types are selected let's clean selection // in replacement table as well if (TextStyles.Any(x => x.IsSelected)) { return; } foreach (var d in ReplacementTextStyles) { d.IsSelected = false; } }
public Size MeasureText(string text, TextStyles textStyle, Measure maxTextWidth) { return(new Size(new Measure() { Draw = text.Length * 20, Print = text.Length }, LineHeight)); }
private void AddMyOwnCustomDataToAFeatureLayer_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); ShapeFileFeatureLayer worldShapeLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp"); worldShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)); worldShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ShapeFileFeatureLayer worldLabelLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp"); worldLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("DynamicPopulation", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Red, 0, -12); worldLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; worldLabelLayer.FeatureSource.CustomColumnFetch += new EventHandler <CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch); LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("WorldShapeLayer", worldShapeLayer); staticOverlay.Layers.Add("WorldLabelLayer", worldLabelLayer); winformsMap1.Overlays.Add(staticOverlay); winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2); winformsMap1.Refresh(); }
private static string GetXStyle(TextStyles style) { switch (style) { case TextStyles.Strong: return("strong"); case TextStyles.Emphasis: return("emphasis"); case TextStyles.Code: return("code"); case TextStyles.Sub: return("sub"); case TextStyles.Sup: return("sup"); case TextStyles.Strikethrough: return("strikethrough"); default: return(""); } }
private void DrawAndLabelANiceLookingRoad_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.ThreadingMode = MapThreadingMode.Multithreaded; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214)); ShapeFileFeatureLayer austinStreetsShapeLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\austinstreets.shp"); austinStreetsShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; austinStreetsShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(LineStyles.LocalRoad1); ShapeFileFeatureLayer austinStreetsLabelLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\austinstreets.shp"); austinStreetsLabelLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.LocalRoad1("FENAME")); austinStreetsLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("AustinStreetsShapeLayer", austinStreetsShapeLayer); staticOverlay.Layers.Add("AustinStreetsLabelLayer", austinStreetsLabelLayer); winformsMap1.Overlays.Add(staticOverlay); winformsMap1.CurrentExtent = new RectangleShape(-97.749141617693908, 30.300592918607943, -97.741202279009826, 30.29492809316849); winformsMap1.Refresh(); }
private void ChangeTheLabelPlacementForPoints_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp"); worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\USStates.shp"); statesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.State1; statesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.LineJoin = DrawingLineJoin.Round; statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ShapeFileFeatureLayer majorCitiesShapeLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\MajorCities.shp"); majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1; majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("AREANAME"); majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping; majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay statesOverlay = new LayerOverlay(); statesOverlay.Layers.Add("World", worldLayer); statesOverlay.Layers.Add("States", statesLayer); statesOverlay.Layers.Add("MajorCitiesShapes", majorCitiesShapeLayer); winformsMap1.Overlays.Add("StatesOverlay", statesOverlay); winformsMap1.CurrentExtent = new RectangleShape(-126.4, 48.8, -67.0, 19.0); winformsMap1.Refresh(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.DisplayMapView); TinyGeoFeatureLayer tinyGeoFeatureLayer = new TinyGeoFeatureLayer(SampleHelper.GetDataPath(@"Frisco/Frisco.tgeo")); tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel11.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false); tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level14; tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true); tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true); tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1); tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true; tinyGeoFeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; tinyGeoFeatureLayer.Open(); LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add(tinyGeoFeatureLayer); WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay(); androidMap = FindViewById <MapView>(Resource.Id.androidmap); androidMap.MapUnit = GeographyUnit.DecimalDegree; androidMap.Overlays.Add(worldMapKitOverlay); androidMap.Overlays.Add(layerOverlay); androidMap.CurrentExtent = tinyGeoFeatureLayer.GetBoundingBox(); SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType()); }
private void AddSpatialFenceOverlay(Map Map1) { LayerOverlay spatialFenceOverlay = new LayerOverlay("SpatialFenceOverlay"); spatialFenceOverlay.TileType = TileType.SingleTile; spatialFenceOverlay.IsBaseOverlay = false; spatialFenceOverlay.IsVisibleInOverlaySwitcher = false; Map1.CustomOverlays.Add(spatialFenceOverlay); // Initialize SpatialFenceLayers. InMemoryFeatureLayer spatialFenceLayer = new InMemoryFeatureLayer(); spatialFenceLayer.Open(); spatialFenceLayer.Columns.Add(new FeatureSourceColumn("Restricted", "Charater", 10)); spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.FromArgb(255, 204, 204, 204), 2), new GeoSolidBrush(GeoColor.FromArgb(112, 255, 0, 0))); spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Restricted", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.SimpleColors.White, 2); spatialFenceLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; spatialFenceOverlay.Layers.Add("SpatialFenceLayer", spatialFenceLayer); // Get the spatial fences from the database and insert fences from database into fence layer Collection <Feature> spatialFences = GetSpatialFences(); foreach (Feature spatialFence in spatialFences) { spatialFence.ColumnValues["Restricted"] = "Restricted"; spatialFenceLayer.InternalFeatures.Add(spatialFence); } }
private void DrawAndLabelWaterFeatures_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214)); ShapeFileFeatureLayer utahWaterShapeLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\UtahWater.shp"); utahWaterShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Water1; utahWaterShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ShapeFileFeatureLayer utahWaterLabelLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\UtahWater.shp"); utahWaterLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Water1("Landname"); utahWaterLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("UtahWaterShapes", utahWaterShapeLayer); staticOverlay.Layers.Add("UtahWaterLabels", utahWaterLabelLayer); winformsMap1.Overlays.Add(staticOverlay); winformsMap1.CurrentExtent = new RectangleShape(-113.11473388671875, 41.949816894531253, -111.08226318359375, 40.499621582031253); winformsMap1.Refresh(); }
public void Upadate() { foreach (var style in TextStyles) { style.IsActive = false; } var inline = _documentState.CurrentSelection.Start.Parent as Inline; if (inline == null) { return; } var styleName = FlowDocumentHelper.GetStyleName(inline); if (String.IsNullOrEmpty(styleName)) { return; } var textStyle = TextStyles.SingleOrDefault(s => s.TextStyle.Name == styleName); if (textStyle == null) { return; } textStyle.IsActive = true; }
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { Map1.MapUnit = GeographyUnit.Meter; // Load roads overlay LayerOverlay roadsOverlay = new LayerOverlay(); Map1.Overlays.Add(roadOverlayName, roadsOverlay); // Load road data from a shape file. ShapeFileFeatureLayer roadsFeatureLayer = new ShapeFileFeatureLayer(@"..\..\Data\Roads.shp"); roadsFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(GeoPens.Gray); roadsFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("ROAD_NAME", "Arial", 8, DrawingFontStyles.Regular, GeoColors.Black); roadsFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; roadsOverlay.Layers.Add(roadsFeatureLayer); // Add highlight overlay LayerOverlay highlightOverlay = new LayerOverlay(); Map1.Overlays.Add(roadHighlightOverlayName, highlightOverlay); InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer(); highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(new GeoColor(123, GeoColors.Green), 5.0f)); highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; highlightOverlay.Layers.Add(highlightLayer); // Add marker overlay SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay(); Map1.Overlays.Add(markerOverlayName, markerOverlay); // Set the map extent Map1.CurrentExtent = new RectangleShape(2478794.65996324, 7106797.82702127, 2482540.06498076, 7104117.76042073); Map1.Refresh(); }
private void customizeToolStripMenuItem_Click(object sender, EventArgs e) { if (TextStyles.ShowStyleEditor()) { SharedControls.RefreshGlobalStyles(); } }
// // GET: /UsingCustomData/ public ActionResult UsingCustomData() { Map map = new Map("Map1", new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage)); map.MapBackground = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")); map.CurrentExtent = new RectangleShape(-125, 72, 50, -46); map.MapUnit = GeographyUnit.DecimalDegree; WorldMapKitWmsWebOverlay worldMapKitOverlay = new WorldMapKitWmsWebOverlay(); map.CustomOverlays.Add(worldMapKitOverlay); ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/cntry02.shp")); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Test", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Red, 0, -12); worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; worldLayer.FeatureSource.CustomColumnFetch += new EventHandler <CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("Test"); LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.IsBaseOverlay = false; staticOverlay.Layers.Add(worldLayer); map.CustomOverlays.Add(staticOverlay); return(View(map)); }
/// <summary> /// Measures a string that is not a number. /// </summary> /// <param name="text">The string to measure.</param> /// <param name="textStyle">Style to use for the text.</param> /// <param name="maxTextWidth">The maximum width for a line of text. NaN means no limit.</param> /// <returns>The size of the string.</returns> public virtual Size MeasureText(string text, TextStyles textStyle, Measure maxTextWidth) { Brush Brush = GetBrush(StyleToForegroundBrush(textStyle)); FormattedText ft = CreateFormattedText(text, EmSize, Brush); if (!maxTextWidth.IsFloating) { ft.MaxTextWidth = maxTextWidth.Draw; } double TextWidth = ft.WidthIncludingTrailingWhitespace; if (TextWidth < InsertionCaretWidth) { TextWidth = InsertionCaretWidth; } Measure Width = new Measure() { Draw = TextWidth, Print = text.Length }; Measure Height = LineHeight; return(new Size(Width, Height)); }
/// <summary></summary> protected virtual BrushSettings StyleToForegroundBrush(TextStyles textStyle) { switch (textStyle) { default: case TextStyles.Default: return(BrushSettings.Default); case TextStyles.Character: return(BrushSettings.Character); case TextStyles.Discrete: return(BrushSettings.Discrete); case TextStyles.Keyword: return(BrushSettings.Keyword); case TextStyles.Type: return(BrushSettings.TypeIdentifier); case TextStyles.Comment: return(BrushSettings.CommentForeground); case TextStyles.LineNumber: return(BrushSettings.LineNumberForeground); } }
private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-97.7583, 30.2714, -97.7444, 30.2632); winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow); ShapeFileFeatureLayer streetLayer = new ShapeFileFeatureLayer(@"..\..\Data\Streets.shp"); streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1; streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add("StreetLayer", streetLayer); winformsMap1.Overlays.Add("LayerOverlay", layerOverlay); //InMemoryFeature to show the selected feature (the feature clicked on). InMemoryFeatureLayer selectLayer = new InMemoryFeatureLayer(); selectLayer.Open(); selectLayer.Columns.Add(new FeatureSourceColumn("FENAME")); selectLayer.Close(); selectLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(150, GeoColor.StandardColors.Red), 10, true); selectLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.LocalRoad1("FENAME"); selectLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay selectOverlay = new LayerOverlay(); selectOverlay.Layers.Add("SelectLayer", selectLayer); winformsMap1.Overlays.Add("SelectOverlay", selectOverlay); winformsMap1.Refresh(); }
/// <summary> /// Resets values. /// </summary> public static void ResetValues() { DebugEx.Verbose("Assets.Common.Toasts.ResetValues()"); TextStyles.ResetValues(); Textures.ResetValues(); }
/// <summary> /// Draws a string that is not a number, at the location specified in <paramref name="origin"/>. /// </summary> /// <param name="text">The text to draw.</param> /// <param name="origin">The location where to start drawing.</param> /// <param name="textStyle">Style to use for the text.</param> /// <param name="isFocused">true if the whole text has the focus.</param> public virtual void DrawText(string text, Point origin, TextStyles textStyle, bool isFocused) { Debug.Assert(WpfDrawingContext != null); if (isFocused && DisplayFocus) { ChangeFlashClockOpacity(isVisible: true); WpfDrawingContext.PushOpacity(1, FlashClock); } Brush Brush = GetBrush(StyleToForegroundBrush(textStyle)); FormattedText ft = CreateFormattedText(text, EmSize, Brush); double X = PagePadding.Left.Draw + origin.X.Draw; double Y = PagePadding.Top.Draw + origin.Y.Draw; double Width = ft.Width; double Height = LineHeight.Draw; if (textStyle == TextStyles.Comment) { X += CommentPadding.Left.Draw; Y += CommentPadding.Top.Draw; } WpfDrawingContext.DrawText(ft, new System.Windows.Point(X, Y)); if (isFocused && DisplayFocus) { WpfDrawingContext.Pop(); IsLastFocusedFullCell = true; } }
/// <summary> /// Get the caret position corresponding to <paramref name="x"/> in <paramref name="text"/>. /// </summary> /// <param name="x">X-coordinate of the caret location.</param> /// <param name="text">The text</param> /// <param name="textStyle">The style used to measure <paramref name="text"/>.</param> /// <param name="mode">The caret mode.</param> /// <param name="maxTextWidth">The maximum width for a line of text. NaN means no limit.</param> /// <returns>The position of the caret.</returns> public virtual int GetCaretPositionInText(double x, string text, TextStyles textStyle, CaretModes mode, Measure maxTextWidth) { Brush Brush = GetBrush(StyleToForegroundBrush(textStyle)); if (textStyle == TextStyles.Comment) { x += CommentPadding.Left.Draw; } int Result = 0; for (int i = 0; i < text.Length; i++) { FormattedText ft = CreateFormattedText(text.Substring(0, i + 1), EmSize, Brush); if (!maxTextWidth.IsFloating) { ft.MaxTextWidth = maxTextWidth.Draw; } if (ft.WidthIncludingTrailingWhitespace >= x) { break; } Result++; } return(Result); }
/// <summary> /// Draws the background of a selected text. /// </summary> /// <param name="text">The text</param> /// <param name="origin">The location where to start drawing.</param> /// <param name="textStyle">The style used to measure selected text.</param> /// <param name="start">The starting point of the selection.</param> /// <param name="end">The ending point of the selection.</param> public virtual void DrawSelectionText(string text, Point origin, TextStyles textStyle, int start, int end) { Debug.Assert(WpfDrawingContext != null); Debug.Assert(start >= 0 && start <= text.Length); Debug.Assert(end >= 0 && end <= text.Length); Debug.Assert(start <= end); Brush Brush = GetBrush(StyleToForegroundBrush(textStyle)); FormattedText ft; double X = PagePadding.Left.Draw + origin.X.Draw; double Y = PagePadding.Top.Draw + origin.Y.Draw; if (textStyle == TextStyles.Comment) { X += CommentPadding.Left.Draw; Y += CommentPadding.Top.Draw; } ft = CreateFormattedText(text.Substring(0, start), EmSize, Brush); X += ft.WidthIncludingTrailingWhitespace; ft = CreateFormattedText(text.Substring(start, end - start), EmSize, Brush); System.Windows.Rect SelectionRect = new System.Windows.Rect(X, Y, ft.WidthIncludingTrailingWhitespace, LineHeight.Draw); WpfDrawingContext.DrawRectangle(GetBrush(BrushSettings.Selection), GetPen(PenSettings.SelectionText), SelectionRect); }
private static ClassBreakClusterPointStyle GetClusterPointStyle() { ClassBreakClusterPointStyle clusterPointStyle = new ClassBreakClusterPointStyle(); clusterPointStyle.CellSize = 65; PointStyle pointStyle1 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 222, 226, 153)), new GeoPen(GeoColor.FromArgb(100, 222, 226, 153), 5), 8); clusterPointStyle.ClassBreakPoint.Add(1, pointStyle1); PointStyle pointStyle2 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 222, 226, 153)), new GeoPen(GeoColor.FromArgb(100, 222, 226, 153), 8), 15); clusterPointStyle.ClassBreakPoint.Add(2, pointStyle2); PointStyle pointStyle3 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 255, 183, 76)), new GeoPen(GeoColor.FromArgb(100, 255, 183, 76), 10), 25); clusterPointStyle.ClassBreakPoint.Add(50, pointStyle3); PointStyle pointStyle4 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 243, 193, 26)), new GeoPen(GeoColor.FromArgb(100, 243, 193, 26), 15), 35); clusterPointStyle.ClassBreakPoint.Add(150, pointStyle4); PointStyle pointStyle5 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 245, 7, 10)), new GeoPen(GeoColor.FromArgb(100, 245, 7, 10), 15), 40); clusterPointStyle.ClassBreakPoint.Add(350, pointStyle5); PointStyle pointStyle6 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 245, 7, 10)), new GeoPen(GeoColor.FromArgb(100, 245, 7, 10), 20), 50); clusterPointStyle.ClassBreakPoint.Add(500, pointStyle6); clusterPointStyle.TextStyle = TextStyles.CreateSimpleTextStyle("FeatureCount", "Arail", 10, DrawingFontStyles.Regular, GeoColor.SimpleColors.Black); clusterPointStyle.TextStyle.PointPlacement = PointPlacement.Center; return(clusterPointStyle); }
private void DrawCurvedLabels_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214)); ShapeFileFeatureLayer austinStreetsShapeLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\austinstreets.shp"); austinStreetsShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; austinStreetsShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(LineStyles.LocalRoad1); ShapeFileFeatureLayer austinStreetsLabelLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\austinstreets.shp"); austinStreetsLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; TextStyle textStyle = TextStyles.LocalRoad1("FENAME"); textStyle.TextLineSegmentRatio = double.MaxValue; textStyle.SplineType = SplineType.StandardSplining; austinStreetsLabelLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle); LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("AustinStreetsShapeLayer", austinStreetsShapeLayer); staticOverlay.Layers.Add("AustinStreetsLabelLayer", austinStreetsLabelLayer); winformsMap1.Overlays.Add(staticOverlay); winformsMap1.CurrentExtent = new RectangleShape(-97.6881803712033, 30.3177912428115, -97.6723016938352, 30.3064615919325); winformsMap1.Refresh(); }
private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1")); winformsMap1.CurrentExtent = new RectangleShape(-97.763384, 30.299707, -97.712382, 30.259309); ShapeFileFeatureLayer austinstreetsLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Austinstreets.shp"); austinstreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(GetRoadStyle()); austinstreetsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay austinstreetsOverlay = new LayerOverlay(); austinstreetsOverlay.Layers.Add("AustinstreetsLayer", austinstreetsLayer); winformsMap1.Overlays.Add("AustinstreetsOverlay", austinstreetsOverlay); // The layer for rendering routing result InMemoryFeatureLayer routingLayer = new InMemoryFeatureLayer(); routingLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(100, GeoColor.StandardColors.Purple), 5); routingLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); // The layer for rendering start and end points InMemoryFeatureLayer stopLayer = new InMemoryFeatureLayer(); stopLayer.Open(); stopLayer.Columns.Add(new FeatureSourceColumn("Order")); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.SimpleColors.LightGreen), new GeoPen(GeoColor.SimpleColors.Black), 12); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Urban1("Order"); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.XOffsetInPixel = -4; stopLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay stopOverlay = new LayerOverlay(); stopOverlay.Layers.Add("StopLayer", stopLayer); winformsMap1.Overlays.Add("StopOverlay", stopOverlay); // Add start and end points to the layer RoutingSource routingSource = new RtgRoutingSource(@"..\..\SampleData\Austinstreets.rtg"); routingSource.Open(); austinstreetsLayer.Open(); Feature startRoad = austinstreetsLayer.FeatureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns); Feature startPoint = new Feature(startRoad.GetShape().GetCenterPoint().GetWellKnownBinary()); startPoint.ColumnValues["Order"] = "1"; stopLayer.InternalFeatures.Add(startPoint); Feature endRoad = austinstreetsLayer.FeatureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns); Feature endPoint = new Feature(endRoad.GetShape().GetCenterPoint().GetWellKnownBinary()); endPoint.ColumnValues["Order"] = "2"; stopLayer.InternalFeatures.Add(endPoint); routingSource.Close(); austinstreetsLayer.Close(); winformsMap1.Refresh(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.DisplayASimpleMap); ShapeFileFeatureLayer txwatFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXwat.shp")); txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(255, 153, 179, 204); txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("LandName", "Arial", 9, DrawingFontStyles.Italic, GeoColor.StandardColors.Navy); txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle.SuppressPartialLabels = true; txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ShapeFileFeatureLayer txlkaA40FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA40.shp")); txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel14.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false); txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true); txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true); txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1); txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true; txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; txlkaA40FeatureLayer.DrawingMarginPercentage = 80; ShapeFileFeatureLayer txlkaA20FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA20.shp")); txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 6, GeoColor.StandardColors.LightGray, 9, true); txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 9, GeoColor.StandardColors.LightGray, 12, true); txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1); txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true; txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay(); Marker thinkGeoMarker = new Marker(BaseContext); thinkGeoMarker.Position = new PointShape(-96.809523, 33.128675); thinkGeoMarker.YOffset = -(int)(22 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density); thinkGeoMarker.SetImageBitmap(BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin)); thinkGeoMarker.Click += ThinkGeoMarkerClick; LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add(txlkaA40FeatureLayer); layerOverlay.Layers.Add(txwatFeatureLayer); layerOverlay.Layers.Add(txlkaA20FeatureLayer); MarkerOverlay markerOverlay = new MarkerOverlay(); markerOverlay.Markers.Add(thinkGeoMarker); androidMap = FindViewById <MapView>(Resource.Id.androidmap); androidMap.MapUnit = GeographyUnit.DecimalDegree; androidMap.CurrentExtent = new RectangleShape(-96.8172, 33.1299, -96.8050, 33.1226); androidMap.Overlays.Add(worldMapKitOverlay); androidMap.Overlays.Add(layerOverlay); androidMap.Overlays.Add(markerOverlay); androidMap.Overlays.Add("PopupOverlay", new PopupOverlay()); SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType()); }
/// <summary> /// Resets values. /// </summary> public static void ResetValues() { DebugEx.Verbose("Assets.Common.Popups.ResetValues()"); TextStyles.ResetValues(); Textures.ResetValues(); SpriteStates.ResetValues(); }
/// <summary> /// Resets values. /// </summary> public static void ResetValues() { DebugEx.Verbose("Assets.Common.DockWidgets.ResetValues()"); Colors.ResetValues(); TextStyles.ResetValues(); Textures.ResetValues(); SpriteStates.ResetValues(); }
public void createTextFX(string text, TextStyles ts = TextStyles.BasicComic, TextMoods tm = TextMoods.Positive) { // POSITION GameObject prefab; switch (ts){ default: case TextStyles.BasicComic: prefab = BasicComicStyle; break; } GameObject temp = GameObject.Instantiate(prefab, Vector3.zero,Quaternion.identity) as GameObject; temp.GetComponent<Text>().text = text; temp.transform.SetParent(WorldSpace); RectTransform rt = temp.GetComponent<RectTransform>(); rt.offsetMin = new Vector2(0f, 0f); rt.offsetMax = new Vector2(0f, 0f); rt.anchoredPosition3D = new Vector3(Random.Range (-0.3f,0.3f), Random.Range (-0.3f,0.3f), 1f); temp.GetComponent<RectTransform>().localRotation = Quaternion.Euler(Vector3.zero); // COLOR Color32 top; Color32 bottom; switch (tm){ default: case TextMoods.Positive: float topRandom = Random.Range(0f,1f); if (topRandom > .9f) { top = Color.blue; bottom = Color.green; } else if (topRandom > 0.6f){ top = Color.green; bottom = Color.yellow; } else if (topRandom > 0.3f) { top = new Color(.5f, 0f, .7f); // purple bottom = new Color(1f, 0f, 1f); // pink } else { top = new Color(0f, .7f, .2f); bottom = Color.white; } break; case TextMoods.Negative: top = Color.red; bottom = Color.yellow; break; } temp.GetComponent<Gradient>().topColor = top; temp.GetComponent<Gradient>().bottomColor = bottom; // ANIMATION MoveTowardCamera mtc = temp.GetComponent<MoveTowardCamera>(); mtc.target = new Vector3(0f,0f,0f); }
public void Text(string text, TextStyles styles) { if (!string.IsNullOrEmpty(text)) { BeginTextStyles(styles); Text(text); EndTextStyles(styles); } }
/// <summary> /// Returns a ThinkGEO style for the region names. /// </summary> /// <returns></returns> public static Style GetRegionNameStyle() { TextStyle aux = TextStyles.CreateSimpleTextStyle("ermtregionname", "Arial", 9, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, -12); aux.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels; aux.YOffsetInPixel = 3; return(aux); }
private void AddDefaultObjects() { // collections this.vports = new VPorts(this); this.views = new Views(this); this.appRegistries = new ApplicationRegistries(this); this.layers = new Layers(this); this.linetypes = new Linetypes(this); this.textStyles = new TextStyles(this); this.dimStyles = new DimensionStyles(this); this.mlineStyles = new MLineStyles(this); this.ucss = new UCSs(this); this.blocks = new BlockRecords(this); this.imageDefs = new ImageDefinitions(this); this.underlayDgnDefs = new UnderlayDgnDefinitions(this); this.underlayDwfDefs = new UnderlayDwfDefinitions(this); this.underlayPdfDefs = new UnderlayPdfDefinitions(this); this.groups = new Groups(this); this.layouts = new Layouts(this); //add default viewport (the active viewport is automatically added when the collection is created, is the only one supported) //this.vports.Add(VPort.Active); //add default layer this.layers.Add(Layer.Default); // add default line types this.linetypes.Add(Linetype.ByLayer); this.linetypes.Add(Linetype.ByBlock); this.linetypes.Add(Linetype.Continuous); // add default text style this.textStyles.Add(TextStyle.Default); // add default application registry this.appRegistries.Add(ApplicationRegistry.Default); // add default dimension style this.dimStyles.Add(DimensionStyle.Default); // add default MLine style this.mlineStyles.Add(MLineStyle.Default); // add ModelSpace layout this.layouts.Add(Layout.ModelSpace); // raster variables this.RasterVariables = new RasterVariables(); }
/// <summary> /// Copies any missing source formatting over to the destination. /// </summary> private MarkupRange FixupDestinationFormatting() { // We'll use the concept of a "fixup segment" to describe a destination segment that needs to be // reformatted to match its corresponding source segment. This is very similar to what MSHTML does // internally. var openFixupSegments = new Dictionary<Type, FixupSegment>(); var registeredFixupSegments = new List<FixupSegment>(); // We'll use these to track our current range as we scan through the source and destination ranges. MarkupRange currentSource = sourceMarkupServices.CreateMarkupRange(sourceRange.Start.Clone(), sourceRange.Start.Clone()); MarkupRange currentDestination = destinationMarkupServices.CreateMarkupRange(destinationRange.Start.Clone(), destinationRange.Start.Clone()); MarkupContext sourceContext = MoveNext(currentSource); MarkupContext destinationContext = MoveNext(currentDestination); // Loop through the source and destination at the same time, scanning to the right. while (currentSource.End.IsLeftOfOrEqualTo(sourceRange.End)) { Trace.Assert(sourceContext.Context == destinationContext.Context, "Mismatched contexts!"); Trace.Assert((sourceContext.Element == null && destinationContext.Element == null) || (sourceContext.Element != null && destinationContext.Element != null && String.Compare(sourceContext.Element.tagName, destinationContext.Element.tagName, StringComparison.OrdinalIgnoreCase) == 0), "Mismatched tags!"); // If it is an image, add attribute marker to suppress applying default values for image decorators if (sourceContext.Element != null && destinationContext.Element != null && string.Compare(sourceContext.Element.tagName, "IMG", StringComparison.OrdinalIgnoreCase) == 0) { destinationContext.Element.setAttribute("wlNoDefaultDecorator", "true", 0); } if (IsBeginTag(sourceContext)) { // Fix up all but text-related formatting. CopyMinimumCss(sourceContext.Element, destinationContext.Element); RemoveTextRelatedInlineCss(destinationContext.Element); MoveCssPropertiesToHtmlAttributes(sourceContext.Element, destinationContext.Element); } if (IsText(sourceContext)) { // Fix up text-related formatting. TextStyles sourceStyles = new TextStyles(currentSource.Start); TextStyles destinationStyles = new TextStyles(currentDestination.Start); IEnumerator<TextStyle> sourceEnumerator = sourceStyles.GetEnumerator(); IEnumerator<TextStyle> destinationEnumerator = destinationStyles.GetEnumerator(); while (sourceEnumerator.MoveNext() && destinationEnumerator.MoveNext()) { TextStyle sourceStyle = sourceEnumerator.Current; TextStyle destinationStyle = destinationEnumerator.Current; FixupSegment fixupSegment; if (openFixupSegments.TryGetValue(destinationStyle.GetType(), out fixupSegment)) { // We've moved into a new range, so we may want to end an open fixup segment. if (ShouldEndFixupSegment(sourceStyle, destinationStyle, fixupSegment)) { registeredFixupSegments.Add(fixupSegment); openFixupSegments.Remove(destinationStyle.GetType()); fixupSegment = null; } } // We've moved into a new range, so we may want to start a new fixup segment. if (ShouldStartFixupSegment(sourceStyle, destinationStyle, fixupSegment)) { openFixupSegments[destinationStyle.GetType()] = new FixupSegment(currentDestination, sourceStyle); } else if (fixupSegment != null) { // There's an open fixup segment for this style and we don't want to start a new one. // That must mean we want to extend the current one. fixupSegment.RangeToFixup.End.MoveToPointer(currentDestination.End); } } } else if (IsEndTag(sourceContext) && !IsInlineElement(sourceContext.Element)) { // We're moving out of a block element and <font> tags cannot wrap block elements so we need to // end any open fixup segments. EndOpenFixupSegments(openFixupSegments, registeredFixupSegments); } // Move along. sourceContext = MoveNext(currentSource); destinationContext = MoveNext(currentDestination); } EndOpenFixupSegments(openFixupSegments, registeredFixupSegments); ExecuteRegisteredFixupSegments(registeredFixupSegments); return destinationRange; }
/// <summary> /// Restarts the zmachine. /// </summary> protected override void Restart() { this.bufferOutput = true; this.textStyles = TextStyles.None; base.Restart(); }
/// <summary> /// Operation 241. /// </summary> /// <remarks> /// Infocom name: HLIGHT /// Inform name: set_text_style /// This operation sets the text style used for output. /// Operands: /// 0) Text style. /// </remarks> protected override void Operation241() { var style = (TextStyles)this.Operands.First; if (style == TextStyles.None) { this.textStyles = style; return; } this.textStyles |= style; }
/// <summary> /// Fixes up a range that is contained in a single header element. /// </summary> /// <param name="range">A range that is contained in a single header element.</param> /// <param name="turnBold">Whether or not the text should be turning bold.</param> private void FixupHeaderRange(MarkupRange range, bool turnBold) { IHTMLElement parentHeaderElement = range.ParentBlockElement(); if (parentHeaderElement == null || !ElementFilters.IsHeaderElement(parentHeaderElement)) { Debug.Fail("Expected entire range to be inside a single header element."); return; } MarkupRange expandedRange = range.Clone(); // Make sure we expand the selection to include any <font> tags that may be wrapping us. MarkupPointerMoveHelper.MoveUnitBounded(expandedRange.Start, MarkupPointerMoveHelper.MoveDirection.LEFT, MarkupPointerAdjacency.BeforeVisible, parentHeaderElement); MarkupPointerMoveHelper.MoveUnitBounded(expandedRange.End, MarkupPointerMoveHelper.MoveDirection.RIGHT, MarkupPointerAdjacency.BeforeVisible, parentHeaderElement); // Walks in-scope elements and clears out any elements or styles that might affect the bold formatting. var elementsToRemove = new List<IHTMLElement>(); expandedRange.WalkRange( delegate (MarkupRange currentexpandedRange, MarkupContext context, string text) { IHTMLElement currentElement = context.Element; if (currentElement != null && context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_EnterScope) { if (IsStrongOrBold(currentElement)) { elementsToRemove.Add(currentElement); } else if (IsFontableElement(currentElement) && HTMLElementHelper.IsBold((IHTMLElement2)currentElement) != turnBold) { currentElement.style.fontWeight = String.Empty; } } return true; }, true); elementsToRemove.ForEach(e => markupServices.RemoveElement(e)); // Walks the range to find any segments of text that need to be fixed up. var rangesToWrap = new List<MarkupRange>(); range.WalkRange( delegate (MarkupRange currentRange, MarkupContext context, string text) { if (context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_Text) { TextStyles currentTextStyles = new TextStyles(currentRange.Start); if (currentTextStyles.Bold != turnBold) { rangesToWrap.Add(currentRange.Clone()); } } return true; }, true); rangesToWrap.ForEach(r => WrapRangeInFontIfNecessary(r, turnBold)); }
private static string GetXStyle(TextStyles style) { switch (style) { case TextStyles.Strong: return "strong"; case TextStyles.Emphasis: return "emphasis"; case TextStyles.Code: return "code"; case TextStyles.Sub: return "sub"; case TextStyles.Sup: return "sup"; case TextStyles.Strikethrough: return "strikethrough"; default: return ""; } }
public void Load(XNode xText) { subtext.Clear(); if (xText == null) { throw new ArgumentNullException("xText"); } switch (xText.NodeType) { case XmlNodeType.Text: XText textNode = (XText) xText; if (!string.IsNullOrEmpty(textNode.Value)) { Text = textNode.Value; style = TextStyles.Normal; } break; case XmlNodeType.Element: XElement xTextElement = (XElement)xText; if (xTextElement.HasElements) { Text = string.Empty; style = GetStyle(xTextElement.Name.LocalName); IEnumerable<XNode> childElements = xTextElement.Nodes(); foreach (var node in childElements) { if (node.NodeType == XmlNodeType.Element) { XElement element = (XElement) node; switch (element.Name.LocalName) { case InternalLinkItem.Fb2InternalLinkElementName: InternalLinkItem link = new InternalLinkItem(); try { link.Load(element); subtext.Add(link); } catch (Exception) { continue; } break; case InlineImageItem.Fb2InlineImageElementName: InlineImageItem image = new InlineImageItem(); try { image.Load(element); subtext.Add(image); } catch (Exception) { continue; } break; default: SimpleText text = new SimpleText(); try { text.Load(element); subtext.Add(text); } catch (Exception) { continue; } break; } } else { SimpleText text = new SimpleText(); try { text.Load(node); subtext.Add(text); } catch (Exception) { continue; } } } } else { style = GetStyle(xTextElement.Name.LocalName); Text = xTextElement.Value; //switch (xTextElement.Name.LocalName) //{ // case "strong": // Text = xTextElement.Value; // break; // case "emphasis": // Text = xTextElement.Value; // break; // case "code": // Text = xTextElement.Value; // break; // case "sub": // Text = xTextElement.Value; // break; // case "sup": // Text = xTextElement.Value; // break; // case "strikethrough": // Text = xTextElement.Value; // break; // default: // Text = xTextElement.Value; // break; //} } break; } }