Ejemplo n.º 1
0
        private void _drawBox(Graphics graphics, AR_PersectiveBox box, TooltipContainer ttC)
        {
            List <PointF> drawPt = new List <PointF>();

            foreach (var item in box.Points)
            {
                drawPt.Add(_data2screen(item));
            }
            Pen pen = new Pen(Color.SkyBlue); pen.DashStyle = DashStyle.Dot;

            graphics.DrawLine(Pens.LightBlue, drawPt[0], drawPt[1]);
            graphics.DrawLine(Pens.LightBlue, drawPt[2], drawPt[3]);
            graphics.DrawLine(pen, drawPt[1], drawPt[2]);
            graphics.DrawLine(pen, drawPt[0], drawPt[3]);
            if (box.VanishingPoint != null)
            {
                var vp = _data2screen(box.VanishingPoint);
                graphics.DrawLine(pen, vp, drawPt[0]);
                graphics.DrawLine(pen, vp, drawPt[1]);
                graphics.DrawLine(pen, vp, drawPt[2]);
                graphics.DrawLine(pen, vp, drawPt[3]);
            }

            int idx = -1;

            foreach (var item in drawPt)
            {
                idx++;
                RectangleF rect = new RectangleF(item.X - 2, item.Y - 2, 5f, 5f);
                graphics.DrawRectangle(Pens.DodgerBlue, rect);
                rect.Inflate(10, 10);
                ttC.Add(rect, null, idx);
            }
        }
Ejemplo n.º 2
0
        private void _drawPoint(Graphics g, PointD pt, Brush br, TooltipContainer ttc)
        {
            if (pt == null)
            {
                return;
            }
            var        vp0   = _data2screen(pt);
            RectangleF rectA = new RectangleF(vp0.X - 2, vp0.Y - 2, 5f, 5f);

            g.FillRectangle(br, rectA);
            rectA.Inflate(3, 3);
            ttc.Add(rectA, null, pt);
        }
Ejemplo n.º 3
0
        private void generateTest(bool cursorlessTooltip)
        {
            testContainer.Clear();

            CursorContainer cursor = null;

            if (!cursorlessTooltip)
            {
                cursor = new RectangleCursorContainer();
                testContainer.Add(cursor);
            }

            TooltipContainer ttc;

            testContainer.Add(ttc = new TooltipContainer(cursor)
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new Drawable[]
                {
                    new Container
                    {
                        Anchor       = Anchor.Centre,
                        Origin       = Anchor.Centre,
                        AutoSizeAxes = Axes.Both,
                        Children     = new[]
                        {
                            new TooltipBox
                            {
                                TooltipText = "Outer Tooltip",
                                Colour      = Color4.CornflowerBlue,
                                Size        = new Vector2(300, 300),
                                Anchor      = Anchor.Centre,
                                Origin      = Anchor.Centre
                            },
                            new TooltipBox
                            {
                                TooltipText = "Inner Tooltip",
                                Size        = new Vector2(150, 150),
                                Anchor      = Anchor.Centre,
                                Origin      = Anchor.Centre
                            },
                        }
                    },
                    new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Direction        = FillDirection.Vertical,
                        Spacing          = new Vector2(0, 10),
                        Children         = new Drawable[]
                        {
                            new TooltipSpriteText("this text has a tooltip!"),
                            new TooltipSpriteText("this one too!"),
                            new TooltipTextbox
                            {
                                Text = "with real time updates!",
                                Size = new Vector2(400, 30),
                            },
                            new TooltipContainer
                            {
                                AutoSizeAxes = Axes.Both,
                                Child        = new TooltipSpriteText("Nested tooltip; uses no cursor in all cases!"),
                            },
                            new TooltipTooltipContainer("This tooltip container has a tooltip itself!")
                            {
                                AutoSizeAxes = Axes.Both,
                                Child        = new Container
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Child        = new TooltipSpriteText("Nested tooltip; uses no cursor in all cases; parent TooltipContainer has a tooltip"),
                                }
                            },
                            new Container
                            {
                                Child = new FillFlowContainer
                                {
                                    Direction = FillDirection.Vertical,
                                    Spacing   = new Vector2(0, 8),
                                    Children  = new[]
                                    {
                                        new Container
                                        {
                                            Child = new Container
                                            {
                                                Child = new TooltipSpriteText("Tooltip within containers with zero size; i.e. parent is never hovered."),
                                            }
                                        },
                                        new Container
                                        {
                                            Child = new TooltipSpriteText("Other tooltip within containers with zero size; different nesting; overlap."),
                                        }
                                    }
                                }
                            }
                        },
                    }
                }
            });

            ttc.Add(makeBox(Anchor.BottomLeft));
            ttc.Add(makeBox(Anchor.TopRight));
            ttc.Add(makeBox(Anchor.BottomRight));
        }
Ejemplo n.º 4
0
        private void _paintMAP(Graphics g)
        {
            _ttC.Clear();
            _ttC.Active = false;

            if (_screenRad < _worldScreenRadius && _screenRad < _worldScreenRadius)
            {
                g.FillRectangle(_seaBrush, 0, 0, pictureBox1.Width, pictureBox1.Height);
            }
            else
            {
                g.FillEllipse(_seaBrush, _scX - _worldScreenRadius, _scY - _worldScreenRadius, _worldScreenRadius * 2, _worldScreenRadius * 2);
            }

            // settle for fast and dirty draw!
            foreach (WSMCountry cDef in _rwmap.Collection)
            {
                Region reg = _internalBorderRegion(cDef);
                // fill
                if (reg != null)
                {
                    g.FillRegion(cDef.Brush, reg);
                    _ttC.Add(reg, cDef.Name, cDef);
                }
                _drawCountryOutline(g, cDef, Pens.Gold);
            }

            if (cities != null)
            {
                int maxX         = pictureBox1.Width + 20;
                int maxY         = pictureBox1.Height + 20;
                int nCitiesDrawn = 0;
                g.TranslateTransform(-1, -1);
                foreach (NamedCoordinate nC in cities.Collection)
                {
                    if (double.IsNaN(nC.ProjectedX))
                    {
                        continue;
                    }
                    PointF pt = _convertF(nC);

                    if (pt.X < -20)
                    {
                        continue;
                    }
                    if (pt.X > maxX)
                    {
                        continue;
                    }
                    if (pt.Y > maxY)
                    {
                        continue;
                    }
                    if (pt.Y < -20)
                    {
                        continue;
                    }

                    g.FillRectangle(Brushes.Brown, pt.X, pt.Y, 3, 3);

                    _drawStandoutString(g, nC.Name, Brushes.Beige, (int)pt.X + 3, (int)pt.Y);
                    nCitiesDrawn++;
                }
                g.ResetTransform();
                _drawStandoutString(g, "NCITIES:" + nCitiesDrawn, Brushes.White, 10, 60);
            }

            foreach (var mLine in mapLines)
            {
                bool     stat = ((mLine.Name == "Lat:0") || (mLine.Name == "Lon:0"));
                PointF[] line = _getLine(mLine);
                if (line == null)
                {
                    continue;
                }
                for (int i = 1; i < line.Length; i++)
                {
                    PointF p0 = line[i - 1];
                    if (float.IsNaN(p0.X))
                    {
                        continue;
                    }
                    PointF p1 = line[i];
                    if (float.IsNaN(p1.X))
                    {
                        continue;
                    }
                    g.DrawLine(stat ? _mapThickPen : _mapLinePen, p0, p1);
                }
            }
        }