Ejemplo n.º 1
0
 protected virtual void DrawElements(Graphics g, IScreenToCoordinateMapper mapper)
 {
     foreach (var e in elements)
     {
         e.Draw(g, mapper);
     }
 }
Ejemplo n.º 2
0
 protected virtual void DrawLayer(uint key, Graphics g, IScreenToCoordinateMapper mapper)
 {
     foreach (var e in layers[key])
     {
         e?.Draw(g, mapper);
     }
 }
Ejemplo n.º 3
0
 public sealed override void Draw(Graphics g, IScreenToCoordinateMapper mapper)
 {
     lock (Locker)
     {
         DoDraw(g, mapper);
     }
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
 public static PolarRotateDecorator GetInstance(string instanceName, IScreenToCoordinateMapper mapper)
 {
     if (!instances.ContainsKey(instanceName))
     {
         PolarRotateDecorator p = new PolarRotateDecorator(mapper);
         instances.Add(instanceName, p);
     }
     return(instances[instanceName]);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
 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);
     }
 }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
 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)
 {
 }
Ejemplo n.º 17
0
 protected abstract void DoDraw(Graphics g, IScreenToCoordinateMapper mapper);
Ejemplo n.º 18
0
 public MapperDecorator(IScreenToCoordinateMapper mapper)
 {
     Mapper = mapper;
 }
Ejemplo n.º 19
0
 public virtual void Draw(Graphics g, IScreenToCoordinateMapper mapper)
 {
     Changed = false;
 }
Ejemplo n.º 20
0
 public void SetMapper(IScreenToCoordinateMapper mapper)
 {
     Mapper = mapper;
     Mapper.SetCoordinateArea(Left, Right, Top, Bottom);
     Mapper.MapperStateChanged += Mapper_MapperStateChanged;
 }
Ejemplo n.º 21
0
 private void Mapper_MapperStateChanged(IScreenToCoordinateMapper obj) => Redraw = true;
Ejemplo n.º 22
0
 protected override void DoDraw(Graphics graphics, IScreenToCoordinateMapper mapper)
 {
     SetMapperCoordinate(mapper);
     graphics.Clear(BackgroundColor);
 }
Ejemplo n.º 23
0
 public void SizeChanged(Size s, IScreenToCoordinateMapper mapper) => mapper.SetScreenArea(0, s.Width, 0, s.Height);
Ejemplo n.º 24
0
 private void Mapper_MapperStateChanged(IScreenToCoordinateMapper obj) => UpdateView();