protected virtual void DrawElements(Graphics g, IScreenToCoordinateMapper mapper) { foreach (var e in elements) { e.Draw(g, mapper); } }
protected virtual void DrawLayer(uint key, Graphics g, IScreenToCoordinateMapper mapper) { foreach (var e in layers[key]) { e?.Draw(g, mapper); } }
public sealed override void Draw(Graphics g, IScreenToCoordinateMapper mapper) { lock (Locker) { DoDraw(g, mapper); } }
public void Update(PointF screenLocation, IScreenToCoordinateMapper mapper) { var rCoo = mapper.GetCoordinateLocation(screenLocation.X, screenLocation.Y); rLoc = new RectangularCoordinate(rCoo.X, rCoo.Y, 0); pLoc = rLoc.Polar; this.screenLocation = screenLocation; }
public static PolarRotateDecorator GetInstance(string instanceName, IScreenToCoordinateMapper mapper) { if (!instances.ContainsKey(instanceName)) { PolarRotateDecorator p = new PolarRotateDecorator(mapper); instances.Add(instanceName, p); } return(instances[instanceName]); }
private void Mapper_MapperStateChanged(IScreenToCoordinateMapper obj) { ScreenOriginalPoint = Mapper.GetScreenLocation(0, 0); ScreenLeft = Mapper.GetScreenX(Left); ScreenRight = Mapper.GetScreenX(Right); ScreenTop = Mapper.GetScreenX(Top); ScreenBottom = Mapper.GetScreenX(Bottom); ScreenHeight = Math.Abs(ScreenTop - ScreenBottom); ScreenWidth = Math.Abs(ScreenRight - ScreenLeft); }
public ZoomAnimation(Area targetArea, IScreenToCoordinateMapper mapper) { this.targetArea = targetArea; this.mapper = mapper; frames = animationTime / updateInterval; xLeftStep = (targetArea.Left - mapper.CoordinateLeft) / frames; xRightStep = (targetArea.Right - mapper.CoordinateRight) / frames; yTopStep = (targetArea.Top - mapper.CoordinateTop) / frames; yBottomStep = (targetArea.Bottom - mapper.CoordinateBottom) / frames; }
protected override void DoDraw(Graphics g, IScreenToCoordinateMapper mapper) { var keys = (from k in layers.Keys select k).ToList(); keys.Sort(); foreach (var key in keys) { DrawLayer(key, g, mapper); } }
protected virtual void SetMapperCoordinate(IScreenToCoordinateMapper mapper) { if (mapper.CoordinateLeft != XLeft || mapper.CoordinateRight != XRight) { mapper.SetCoordinateXRange(XLeft, XRight); } if (mapper.CoordinateTop != YTop || mapper.CoordinateBottom != YBottom) { mapper.SetCoordinateYRange(YTop, YBottom); } }
protected override void DoDraw(Graphics g, IScreenToCoordinateMapper mapper) { base.Draw(g, mapper); if (HasChanged()) { bmp?.Dispose(); bmp = new Bitmap((int)mapper.ScreenWidth, (int)mapper.ScreenHeight); var graphics = Graphics.FromImage(bmp); DrawElements(graphics, mapper); } g.DrawImage(bmp, new Point(0, 0)); return; }
public Displayer(Panel p, IScreenToCoordinateMapper mapper, ReferenceSystem referenceSystem) { Panel = p; Panel.SizeChanged += Pb_SizeChanged; Mapper = mapper; referenceSystem.SetMapper(mapper); ReferenceSystem = referenceSystem; mapper.SetScreenArea(0, p.Size.Width, 0, p.Size.Height); mapper.MapperStateChanged += Mapper_MapperStateChanged; Elements = new LayerManager(); Elements.SetDisplayer(this); InitializeDisplayerState(); }
public virtual bool IsRectBigEnough(Rectangle r, IScreenToCoordinateMapper mapper) { if (Math.Abs(r.Right - r.Left) < 20 || Math.Abs(r.Bottom - r.Top) < 20) { return(false); } var xLeft = mapper.GetCoordinateX(r.Left); var xRight = mapper.GetCoordinateX(r.Right); var yTop = mapper.GetCoordinateY(r.Top); var yBottom = mapper.GetCoordinateY(r.Bottom); if (ValueMapper.IsIntervalTooSmall(xLeft, xRight) || ValueMapper.IsIntervalTooSmall(yTop, yBottom)) { return(false); } return(true); }
protected override void DoDraw(Graphics graphics, IScreenToCoordinateMapper mapper) { Pen p = new Pen(Color.Red, 1f); var point = mapper.GetScreenLocation(rLoc.X, rLoc.Y); var center = mapper.ScreenCenter; var xPoint = new PointF(point.X, center.Y); var yPoint = new PointF(center.X, point.Y); var xmPoint = new PointF(point.X, center.Y - (center.Y - point.Y) / 2); var ymPoint = new PointF(center.X + (point.X - center.X) / 2, point.Y); var dmPoint = new PointF(center.X + (point.X - center.X) / 2, center.Y - (center.Y - point.Y) / 2); graphics.DrawLine(p, point, center); graphics.DrawLine(p, point, xPoint); graphics.DrawLine(p, point, yPoint); Font font = new Font("宋体", 12); SolidBrush brush = new SolidBrush(Color.Yellow); graphics.DrawString(rLoc.X.ToString("0"), font, brush, ymPoint); graphics.DrawString((rLoc.Y).ToString("0"), font, brush, xmPoint); graphics.DrawString(pLoc.Dis.ToString("0"), font, brush, dmPoint); graphics.FillEllipse(new SolidBrush(Color.Red), new RectangleF(point.X - 4, point.Y - 4, 8, 8)); #region 画弧线 var arcR = Math.Min(Math.Abs(point.X - center.X), Math.Abs(point.Y - center.Y)) / 3; var angle = pLoc.Az; var left = center.X - arcR; var top = center.Y - arcR; Rectangle arcRect = new Rectangle((int)left, (int)top, (int)arcR * 2, ((int)arcR * 2)); var centerAngle = Functions.DegreeToRadian(angle / 2); var centerPoint = new PointF((float)(arcR * Math.Sin(centerAngle) + center.X), (float)(center.Y - arcR * Math.Cos(centerAngle)) - 5); if (arcR > 0 && arcRect.Width > 0 && arcRect.Height > 0) { graphics.DrawArc(p, arcRect, -90, (float)angle); graphics.DrawString($"{angle:0.0}°", font, brush, centerPoint); } #endregion }
public ControlPanel(ITacanController controller) { InitializeComponent(); //controller.Write(0x54000, 0xAA); mapper = new SquaredScreenRectDecorator(new ScreenToCoordinateMapper()); display = new PPIDisplay(ppi_pb, mapper); display.DmeStateChanged += Display_DmeStateChanged; this.controller = controller; UpdateForm(controller.Model); validation = new InputValidation { CueControl = hint_lab }; validation.AddValidation(channel_tb, new IntStrInRange(126, 1)); validation.AddValidation(randomPulse_tb, new IntStrInRange(10000, 0)); validation.AddValidation(modulation15_tb, new DoubleStrInRange(100, 0)); validation.AddValidation(modulation135_tb, new DoubleStrInRange(100, 0)); validation.AddValidation(responseRate_tb, new DoubleStrInRange(100, 0)); validation.AddValidation(responsePower_tb, new DoubleStrInRange(10, -100)); validation.AddValidation(identifyCode_tb, new LetterLengthRule(4, 3)); }
public ZoomRectDecorator(IScreenToCoordinateMapper mapper, double percentage) : base(mapper) { this.percentage = percentage; }
//public override double ScreenWidth => Mapper.ScreenRight - Mapper.ScreenLeft; //public override double ScreenHeight => Mapper.ScreenBottom - Mapper.ScreenTop; public SquaredScreenRectDecorator(IScreenToCoordinateMapper mapper) : base(mapper) { }
protected abstract void DoDraw(Graphics g, IScreenToCoordinateMapper mapper);
public MapperDecorator(IScreenToCoordinateMapper mapper) { Mapper = mapper; }
public virtual void Draw(Graphics g, IScreenToCoordinateMapper mapper) { Changed = false; }
public void SetMapper(IScreenToCoordinateMapper mapper) { Mapper = mapper; Mapper.SetCoordinateArea(Left, Right, Top, Bottom); Mapper.MapperStateChanged += Mapper_MapperStateChanged; }
private void Mapper_MapperStateChanged(IScreenToCoordinateMapper obj) => Redraw = true;
protected override void DoDraw(Graphics graphics, IScreenToCoordinateMapper mapper) { SetMapperCoordinate(mapper); graphics.Clear(BackgroundColor); }
public void SizeChanged(Size s, IScreenToCoordinateMapper mapper) => mapper.SetScreenArea(0, s.Width, 0, s.Height);
private void Mapper_MapperStateChanged(IScreenToCoordinateMapper obj) => UpdateView();