static void Main(string[] args) { /*组合模式可以适用以下情形: * * ◊ 希望把对象表示成部分—整体层次结构; * * ◊ 希望用户忽略组合对象与单个对象的不同,用户将统一地使用组合结构中所有对象。 * * 组合模式具有以下特点: * * ◊ 定义了包含基本对象和组合对象的类层次结构。基本对象可以被组合成更复杂的组合对象,而这个组合对象又可以被组合,不断的递归下去。客户代码中,任何用到基本对象的地方都可以使用组合对象; * * ◊ 简化客户代码。客户可以一致地使用组合结构和单个对象。这样用户就不必关心处理的是一个叶子节点还是一个组合组件,从而简化了客户代码; * * ◊ 使得新增类型的组件更加容易。新定义的Composite或Leaf子类自动地与已有的结构和客户代码一起协同工作,客户程序不需因新的Component类而改变。 */ // Create a tree structure Composite root = new Composite("root"); root.Add(new Leaf("Leaf A")); root.Add(new Leaf("Leaf B")); Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Leaf XA")); comp.Add(new Leaf("Leaf XB")); root.Add(comp); root.Add(new Leaf("Leaf C")); // Add and remove a leaf Leaf leaf = new Leaf("Leaf D"); root.Add(leaf); root.Remove(leaf); // Recursively display tree root.Display(1); //Sample:graphics Graphics graphics = new Graphics("全部图形"); Circle circle = new Circle("圆形", 5); graphics.Add(circle); Rectangle rectangle = new Rectangle("矩形", 4, 5); graphics.Add(rectangle); Triangle triangle = new Triangle("三角形", 3, 4, 5); graphics.Add(triangle); graphics.Display(); }
private void _landRequest_DonationsReceived(object sender, EventArgs e) { var land = sender as List <DonationsLand>; if (land == null) { return; } foreach (var l in land) { var geom = WktConverter.PolygonWktToPolygon(l.geom); if (geom == null) { continue; } //FFA52A2A var fillSymbol = new SimpleFillSymbol { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = 1, Fill = new SolidColorBrush(Color.FromArgb(80, 176, 196, 222)) }; var g = new Graphic { Geometry = geom, Symbol = fillSymbol }; Graphics.Add(g); } }
/// <summary> /// Adds a Graphic to the Entity. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="g">The Graphic to add.</param> /// <param name="x">The X position to place the Graphic relative to the Entity.</param> /// <param name="y">The Y position to place the Graphic relative to the Entity.</param> /// <returns>The added Graphic.</returns> public T AddGraphic <T>(T g, float x, float y) where T : Graphic { Graphics.Add(g); g.X = x; g.Y = y; return(g); }
public SegFrameImageGraphic(int rows, int columns, float xLocation, float yLocation, Color color, int frameIndex, int index, string label, string description, byte[] pixelData, SegmentationDocumentReference segmentationDocumentReference) { Platform.CheckPositive(rows, "rows"); Platform.CheckPositive(columns, "columns"); Platform.CheckNonNegative(frameIndex, "frameIndex"); _index = index; _frameIndex = frameIndex; Label = string.IsNullOrEmpty(label) ? string.Empty : label; Description = string.IsNullOrEmpty(description) ? string.Empty : description; SegmentationDocumentReference = segmentationDocumentReference; // new empty pixel buffer if (pixelData == null) { pixelData = MemoryManager.Allocate <byte>(rows * columns); } _overlayGraphic = new GrayscaleImageGraphic( rows, columns, // the reported overlay dimensions 8, // bits allocated is always 8 8, // overlays always have bit depth of 1, but we upconverted the data 7, // the high bit is now 7 after upconverting false, false, // overlays aren't signed and don't get inverted 1, 0, // overlays have no rescale pixelData); // the upconverted overlay data _overlayGraphic.SpatialTransform.TranslationX = xLocation; _overlayGraphic.SpatialTransform.TranslationY = yLocation; Color = color; Graphics.Add(_overlayGraphic); }
private void Initialize() { if (_left == null) { Graphics.Add(_left = new InvariantLinePrimitive()); _left.InvariantBottomRight = PointF.Empty; } if (_right == null) { Graphics.Add(_right = new InvariantLinePrimitive()); _right.InvariantBottomRight = PointF.Empty; } if (_top == null) { Graphics.Add(_top = new InvariantLinePrimitive()); _top.InvariantBottomRight = PointF.Empty; } if (_bottom == null) { Graphics.Add(_bottom = new InvariantLinePrimitive()); _bottom.InvariantBottomRight = PointF.Empty; } RecomputeCrosshair(); }
private void _donationsRequest_DonationsReceived(object sender, EventArgs e) { var adopters = sender as List <Adopter>; if (adopters == null) { return; } DonationsViewerSystem.Instance.MainPage.overviewControl.UpdateOverview(adopters); foreach (var adopter in adopters) { //Create symbols and place it on the map var geom = WktConverter.PolygonWktToPolygon(adopter.geom); if (geom == null) { continue; } var fillSymbol = new SimpleFillSymbol { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = 1, Fill = new SolidColorBrush(GetRandomColor()) }; var g = new Graphic { Geometry = geom, Symbol = fillSymbol }; g.Attributes.Add("username", adopter.username); g.Attributes.Add("area", adopter.area); g.Attributes.Add("amount", adopter.amount); Graphics.Add(g); } }
/// <summary> /// 聚合计算 /// </summary> /// <param name="param"></param> private void DoCluster(object param) { List <ClusterItem> cs = param as List <ClusterItem>; for (;;) { //递归,完成聚合计算 if (!DoSingleCluster(cs)) { break; } } Dispatcher.Invoke(delegate { Graphics.Clear(); if (cs != null) { foreach (ClusterItem ci in cs) { //System.Windows.Point pt =Map.LocationToScreen(ci.GetGraphic().Geometry as MapPoint); //Graphic g= ci.GetGraphic(); //g.Attributes["Label"] = pt.X + "," + pt.Y; Graphics.Add(ci.GetGraphic()); } } }); }
private void Initialize() { if (_textControlGraphic == null) { _textControlGraphic = InitializeTextControlGraphic(new InvariantTextPrimitive()); _textControlGraphic.Name = "Text"; _textControlGraphic.Color = System.Drawing.Color.Yellow; this.Graphics.Add(_textControlGraphic); } this.TextGraphic.VisualStateChanged += OnTextVisualStateChanged; if (_pointControlGraphic == null) { _pointControlGraphic = InitializePointControlGraphic(new AnchorPointGraphic()); _pointControlGraphic.Name = "Point"; this.Graphics.Add(_pointControlGraphic); } if (_lineGraphic == null) { _lineGraphic = new CrosshairGraphic(false); _lineGraphic.Name = "Line"; _lineGraphic.Color = System.Drawing.Color.Yellow; _lineGraphic.LineStyle = LineStyle.Dash; Graphics.Add(_lineGraphic); } }
/// <summary> /// Constructs a <see cref="ScaleGraphic"/>. /// </summary> public ScaleGraphic() { Graphics.Add(_baseLine = new LinePrimitive { Name = _baseLineName }); _isDirty = false; }
/// <summary> /// 将聚合对象加入到聚合中 /// </summary> /// <param name="ci"></param> public void AddGraphics(ClusterItem ci) { double x = 0, y = 0, sx = ScreenLocation.X * Graphics.Count, sy = ScreenLocation.Y * Graphics.Count; foreach (var g in ci.Graphics) { Graphics.Add(g); } sx += ci.ScreenLocation.X * ci.Graphics.Count; sy += ci.ScreenLocation.Y * ci.Graphics.Count; ci.Graphics.Clear(); foreach (var g in Graphics) { var point = g.Geometry as MapPoint; if (point != null) { x += point.X; } var mapPoint = g.Geometry as MapPoint; if (mapPoint != null) { y += mapPoint.Y; } } _center = new MapPoint(x / Graphics.Count, y / Graphics.Count); ScreenLocation = new Point(sx / Graphics.Count, sy / Graphics.Count); _size = 25 + Graphics.Count / 20; }
public ErrorOverlayPlaneGraphic(string errorMessage) : base(10, 10) { errorMessage = !string.IsNullOrEmpty(errorMessage) ? errorMessage : string.Empty; Graphics.Add(new ErrorText { Color = System.Drawing.Color.WhiteSmoke, Text = errorMessage }); }
/// <summary> /// 地图边界盒改变,进行聚合操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Map_ExtentChanged(object sender, EventArgs e) { if (!IsCluster) { return; } if (Math.Abs(_lastScale - MapObj.MapView.Scale) < 0.001) { return; } _lastScale = MapObj.MapView.Scale; if (_originalGraphics == null) { _originalGraphics = new GraphicCollection(); foreach (var g in Graphics) { _originalGraphics.Add(new Graphic(g.Geometry, g.Attributes, g.Symbol)); } } Graphics.Clear(); var cs = new List <ClusterItem>(); foreach (var g in _originalGraphics) { if (!(g.Geometry is MapPoint)) { continue; } if (((MapPoint)g.Geometry).X < MapObj.MapView.Extent.XMin || ((MapPoint)g.Geometry).X > MapObj.MapView.Extent.XMax || ((MapPoint)g.Geometry).Y < MapObj.MapView.Extent.YMin || ((MapPoint)g.Geometry).Y > MapObj.MapView.Extent.YMax) { continue; } cs.Add(new ClusterItem(MapObj.MapView, g, _originalGraphics.Count)); } //如果地图已经放到最大那么就不再聚合 if (MapObj.TiledInfo != null && MapObj.TiledInfo.Lods.Count > 0 && Math.Abs(MapObj.TiledInfo.Lods[MapObj.TiledInfo.Lods.Count - 1].Scale - MapObj.MapView.Scale) < 0.001) { foreach (var ci in cs) { Graphics.Add(ci.GetGraphic()); } return; } _clusterThread?.Abort(); _clusterThread = new Thread(DoCluster); _clusterThread.Start(cs); }
protected BaseRobot() { Magic = 0; defaultTickers.ForEach(t => { if (DalSpot.Instance.GetTickerNames().Contains(t)) { Graphics.Add(new Cortege2 <string, BarSettings>(t, BarSettingsStorage.Instance.GetBarSettingsByName("H1"))); } }); }
private void Initialize(CompositeGraphic3D source, ICloningContext context) { foreach (var graphic in source.Graphics) { var clone = graphic.Clone(); if (clone != null) { Graphics.Add(clone); } } }
void LoadSecondaryTileset(Tileset tileset, int offset) { while (Graphics.Count < offset + tileset.Count) { Graphics.Add(Tile.Empty); } for (int i = 0; i < tileset.Count; i++) { Graphics[offset + i] = tileset[i]; } }
/// <summary> /// Initializes a new <see cref="ProgressGraphic"/>. /// </summary> /// <param name="progressProvider">The provider of progress information for which the <see cref="ProgressGraphic"/> will display updates.</param> /// <param name="autoClose">A value indicating whether or not the <see cref="ProgressGraphic"/> should automatically remove and dispose itself when the progress provider reports task completion or cancellation.</param> /// <param name="progressBarStyle">The style of progress bar to be displayed.</param> public ProgressGraphic(IProgressProvider progressProvider, bool autoClose = _defaultAutoClose, ProgressBarGraphicStyle progressBarStyle = _defaultStyle) { _autoClose = autoClose; _progressBarStyle = progressBarStyle; _progressProvider = progressProvider; _progressProvider.ProgressUpdated += OnProgressUpdated; _synchronizationContext = SynchronizationContext.Current; Graphics.Add(_graphics = new ProgressCompositeGraphic(_progressBarStyle)); }
public CompositeScaleGraphic() { Graphics.Add(_horizontalScale = new ScaleGraphic { Name = _horizontalName }); Graphics.Add(_verticalScale = new ScaleGraphic { Name = _verticalName }); _horizontalScale.Visible = false; _horizontalScale.IsMirrored = true; _verticalScale.Visible = false; _verticalScale.IsMirrored = true; }
public Graphic AddGraphic(Graphic graphic) { if (graphic == null) { throw new System.ArgumentNullException(nameof(graphic)); } if (!GraphicAdded(graphic)) { return(null); } Graphics.Add(graphic); graphic.Renderer = Renderer; return(graphic); }
public void AddNewLine(double[] line) { Line = new LineSeries(); var newLine = new ChartValues <ObservableValue>(); for (int point = 0; point < line.Length; point++) { newLine.Add(new ObservableValue(line[point])); } Line.Values = newLine; Line.Title = Guid.NewGuid().ToString(); Graphics.Add(Line); }
public FlashOverlayGraphic(FlashOverlayController controller, string message) { Controller = controller; Graphics.Add(new ColorImageGraphic(_rows = controller.Rows, _columns = controller.Columns, controller.GetPixelData)); if (!string.IsNullOrWhiteSpace(message)) { const int vOffset = 25; // fixed offset because we currently don't have a way to measure text size until after rendering once... Graphics.Add(new InvariantTextPrimitive(message) { Location = new PointF(_columns / 2f, _rows + vOffset), Color = Color.WhiteSmoke, SizeInPoints = 20 }); } }
internal void FlipDirection() { if (Type == LayerType.GPXRoute) { Graphics.Clear(); var route = (Route)_routeOrTrack; route.Flip(); Graphics.Add(_routeOrTrack.StartLocation); Graphics.Add(_routeOrTrack.EndLocation); Graphics.Add(_routeOrTrack.Geometry); SetSymbols(); IsInEditMode = true; if (IsSplitted) { SplitRoute(_splitDistance); } } }
protected virtual void OnGraphicsCreated(GraphicCollection graphics, bool clearGraphics, EventHandler onGraphicsAddComplete) { if (graphics == null) { return; } if (MapSpatialReference == null || MapSpatialReference.Equals(LayerSpatialReference)) { Graphics = graphics; // map spatial reference was unspecified => we assume points match the spatial ref of the match (responsbility is on the developer) OnUpdateCompleted(EventArgs.Empty); UpdateCursorForRenderer(); if (onGraphicsAddComplete != null) { onGraphicsAddComplete(this, EventArgs.Empty); } } else { GeometryServiceOperationHelper projectionHelper = GetProjectionHelper((s, e) => { if (clearGraphics) { Graphics = new GraphicCollection(); } foreach (Graphic g2 in e.Graphics) { Graphics.Add(g2); } OnUpdateCompleted(EventArgs.Empty); UpdateCursorForRenderer(); if (onGraphicsAddComplete != null) { onGraphicsAddComplete(this, EventArgs.Empty); } }); if (projectionHelper != null) { projectionHelper.ProjectGraphics(graphics, MapSpatialReference); } } }
/// <summary> /// Adds a polyline to this map layer. /// </summary> /// <param name="lc"> /// The location collection that defines the polyline. /// </param> /// <param name="br"> /// The brush used to render the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { var pc = new PointCollection(); foreach (var p in lc) { pc.Add(Transform.GeographicToWebMercator(p as MapPoint)); } var polyline = new Polyline(); polyline.Paths.Add(pc); var graphic = new Graphic { Symbol = new SimpleLineSymbol { Color = br }, Geometry = polyline }; Graphics.Add(graphic); }
private void Analyze(bool responsive) { _roi = Subject.GetRoi(); var currentCallout = Callout; var roiCallout = currentCallout as RoiCalloutGraphic; if (roiCallout == null) { if (currentCallout != null) { Graphics.Remove(currentCallout); currentCallout.Dispose(); } roiCallout = new RoiCalloutGraphic { Color = Color }; Graphics.Add(roiCallout); Callout = roiCallout; } roiCallout.Update(_roi, responsive ? RoiAnalysisMode.Responsive : RoiAnalysisMode.Normal); }
/// <summary> /// Initializes a new instance of the <see cref="GpsLayer"/> class. /// </summary> public GpsLayer() { location = new Graphic(); GeoPositionWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); System.Windows.Media.RadialGradientBrush brush = new System.Windows.Media.RadialGradientBrush() { Center = new Point(.25, .25), GradientOrigin = new Point(.25, .25), RadiusX = 1, RadiusY = 1 }; LocationMarkerSymbol = new Gps.GpsSymbol(); accuracyCircle = new Graphic { Geometry = new Circle() }; AccuracyCircleSymbol = new SimpleFillSymbol() { BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(90, 255, 255, 255)), Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(20, 65, 76, 249)), BorderThickness = 3 }; Graphics.Add(accuracyCircle); Graphics.Add(location); location.SetZIndex(1); IsHitTestVisible = false; animationTimerLocation = new DispatcherTimer(); animationTimerLocation.Interval = TimeSpan.FromMilliseconds(33); animationTimerLocation.Tick += animationTimerLocation_Tick; animationTimerAccuracy = new DispatcherTimer(); animationTimerAccuracy.Interval = TimeSpan.FromMilliseconds(33); animationTimerAccuracy.Tick += animationTimerAccuracy_Tick; }
public BikeTouringGISLayer(string fileName, IPath routeOrTrack) : this(fileName) { _routeOrTrack = routeOrTrack; Title = string.IsNullOrEmpty(_routeOrTrack.Name) ? Path.GetFileNameWithoutExtension(fileName) : _routeOrTrack.Name; _originalTitle = Title; _isSplitPrefixStillEqualToOriginal = true; SetSplitPrefix(); Graphics.Add(_routeOrTrack.StartLocation); Graphics.Add(_routeOrTrack.EndLocation); Graphics.Add(_routeOrTrack.Geometry); SetLength(); SelectionColor = Colors.LimeGreen; switch (routeOrTrack.Type) { case PathType.Route: Type = LayerType.GPXRoute; break; case PathType.Track: Type = LayerType.GPXTrack; break; } IsInEditMode = false; }
/// <summary> /// Adds a Graphic to the Entity. /// </summary> /// <param name="g">The Graphic to add.</param> /// <returns>The added Graphic.</returns> public T AddGraphic <T>(T g) where T : Graphic { Graphics.Add(g); return(g); }
/// <summary> /// Sets the graphic to a new graphic, removing all previous graphics. /// </summary> /// <param name="g"></param> public void SetGraphic(Graphic g) { Graphics.Clear(); Graphics.Add(g); }
internal void AddPoIs(IEnumerable <WayPoint> wayPoints) { _wayPoints.AddRange(wayPoints); wayPoints.ForEach(wp => Graphics.Add(wp.Geometry)); }
protected void AddGraphic(Image image, ImageStyle style) { ApplyStyles.Image(image, style); Graphics.Add(new ElementGraphic(image, style)); }