public Tool.Point UnitToPanel(iconDB from)
        {
            Tool.Size  ratio   = this.nfo.dbMapSize / this.nfo.dbRefMapSize;
            Tool.Point unitPos = from.pos * ratio + this.nfo.dbMapOffsetUnit;

            return(this.Position + (unitPos * this.SizeCorrected) - (from.icon.Size * 0.5f));
        }
        public void Display(Graphics gfx)
        {
            Tool.Point offset = controls[0] * map.SizeCorrected + map.Position;

            Tool.Size size = (controls[1] - controls[0]) * map.SizeCorrected;

            foreach (PathDef def in paths)
            {
                def.path.Reset();

                Tool.Point last = offset + def.points[0] * size;
                foreach (Tool.Point point in def.points)
                {
                    Tool.Point newpt = offset + point * size;
                    def.path.AddLine(last, newpt);
                    last = newpt;
                }

                gfx.DrawPath(def.pen, def.path);
            }

            int j = 0;

            foreach (Tool.Point point in controls)
            {
                Tool.Point pt = (point * map.SizeCorrected + map.Position).Truncate;

                Brush brush = (isDraggingCtrlPoint == j) ? brushSelected : brushUnselected;
                gfx.FillEllipse(brush, new Rectangle((int)pt.X - 5, (int)pt.Y - 5, 11, 11));
                j++;
            }
        }
Beispiel #3
0
        internal bool Update(VirtualMap map)
        {
            Tool.Point center = (centerUnit * map.SizeCorrected).Truncate;
            Tool.Point newPos;

            double deltaDepth = this.destDepth - this.currDepth;

            if (Math.Abs(deltaDepth) > depthSpeed)
            {
                map.ResizeFromZoom((float)Math.Pow(2, currDepth));

                newPos = (centerUnit * map.SizeCorrected).Truncate;

                map.Position = map.Position - (newPos - center);

                this.currDepth += Math.Sign(deltaDepth) * depthSpeed;

                return(true);
            }

            this.currDepth = this.destDepth;
            map.ResizeFromZoom((float)Math.Pow(2, currDepth));

            newPos = (centerUnit * map.SizeCorrected).Truncate;

            map.Position = map.Position - (newPos - center);

            return(false);
        }
        public Tool.Point UnitToPanel(Tool.Point from)
        {
            //                return Position + from * SizeCorrected;
            Tool.Size  ratio   = this.nfo.dbMapSize / this.nfo.dbRefMapSize;
            Tool.Point unitPos = from * ratio + this.nfo.dbMapOffsetUnit;

            return(this.Position + unitPos * this.SizeCorrected);
        }
        public Tool.Point PanelToUnit(Tool.Point from)
        {
            Tool.Point unitInMap = (Tool.Point)((from - this.Position) / this.SizeCorrected);
            unitInMap = (Tool.Point)(unitInMap - this.nfo.dbMapOffsetUnit);
            Tool.Size ratio = this.nfo.dbRefMapSize / this.nfo.dbMapSize;

            Tool.Point pt = unitInMap * ratio;
            pt.Y = 1.0f - pt.Y;

            return(pt);
        }
Beispiel #6
0
        public void Start(VirtualMap map, Tool.Point center, int depthDir)
        {
            this.centerUnit = center / map.SizeCorrected;

            this.currDepth = Math.Min(Math.Max(this.currDepth, map.nfo.min_depth), map.nfo.mag_depth - 1);
            this.destDepth = Math.Min(Math.Max(this.destDepth, map.nfo.min_depth), map.nfo.mag_depth - 1);

            int newDepth = this.destDepth + depthDir;

            if ((newDepth >= map.nfo.min_depth) && (newDepth <= map.nfo.mag_depth - 1))
            {
                this.destDepth = newDepth;
                this.evtHandle.Set();
            }
        }
        public int IntersectControl(Tool.Point pos, float radius)
        {
            for (int i = 0; i < 4; i++)
            {
                Tool.Point posInMap = controls[i] * map.SizeCorrected;

                float distance = (posInMap - pos).Lenght;

                if (distance <= radius)
                {
                    return(i);
                }
            }

            return(-1);
        }
Beispiel #8
0
 public void AddPoint(Tool.Point pos)
 {
     if ((paths.Count == 0) || (pos == InvalidPos))
     {
         paths.Add(new PathDef(pen));
     }
     if (pos != InvalidPos)
     {
         if ((paths.Last().points.Count == 0) || (Tool.Point.Distance(pos, paths.Last().points.Last()) > 0.0002614f))
         {
             paths.Last().points.Add(pos);
         }
         else
         {
             paths.Last().points.RemoveAt(paths.Last().points.Count - 1);
             paths.Last().points.Add(pos);
         }
     }
 }
        public void ControlPointUpdated(int idx)
        {
            if (idx < 2)
            {
                // Update 2 & 3
                controls[2] = new Tool.Point(controls[1].X, controls[0].Y);
                controls[3] = new Tool.Point(controls[0].X, controls[1].Y);
            }
            else
            {
                // Update 1 & 2
                controls[0] = new Tool.Point(controls[3].X, controls[2].Y);
                controls[1] = new Tool.Point(controls[2].X, controls[3].Y);
            }

            Tool.Size size = (controls[1] - controls[0]);

            boundaries[0] = controls[0] + defBoundaries[0] * size;
            boundaries[1] = controls[0] + defBoundaries[1] * size;
        }
 public Tool.Point UnitToMap(Tool.Point from)
 {
     Tool.Point pt = from;
     pt.Y = 1.0f - pt.Y;
     return(pt * this.nfo.dbRefMapSize);
 }
 public Tool.Point UnitToDB(Tool.Point from)
 {
     return(from * this.nfo.dbRefMapSize);
 }
 public Rectangle TileRectangleEx(Tool.Point p, Tool.Size sz)
 {
     return(new Rectangle(Position + p * _tileSize, sz));
 }
 public Rectangle TileRectangle(Tool.Point p)
 {
     return(new Rectangle(Position + p * _tileSize, _tileSize));
 }
Beispiel #14
0
        public MapHelper(VirtualMap map, string worldId)
        {
            this.map = map;

            foreach (Tool.Point[] arr in Tool.mapHelperDefs[worldId])
            {
                AddPathDef(arr);
            }

            Tool.Point min = new Tool.Point(9999999, 9999999);
            Tool.Point max = new Tool.Point(-9999999, -9999999);
            foreach (PathDef _def in paths)
            {
                foreach (Tool.Point pt in _def.points)
                {
                    min = Tool.Point.Min(min, pt);
                    max = Tool.Point.Max(max, pt);
                }
            }
            Tool.Size size = (max - min);

            //  DB Map boundaries
            {
                Tool.Point[] points = new Tool.Point[]
                {
                    new Tool.Point(0, map.nfo.dbRefMapSize.Height),
                    new Tool.Point(map.nfo.dbRefMapSize.Width, map.nfo.dbRefMapSize.Height),
                    new Tool.Point(map.nfo.dbRefMapSize.Width, 0),
                    new Tool.Point(0, 0),
                    new Tool.Point(0, map.nfo.dbRefMapSize.Height)
                };
                AddPathDef(points, new Pen(Color.Red, 2));
            }

            foreach (PathDef _def in paths)
            {
                for (int i = 0; i < _def.points.Count; i++)
                {
                    Tool.Point pt = _def.points[i];
                    pt             = (Tool.Point)((pt - min) / size);
                    _def.points[i] = pt;
                }
            }

            defBoundaries[0] = (Tool.Point)((new Tool.Point(0, map.nfo.dbRefMapSize.Height) - min) / size);
            defBoundaries[1] = (Tool.Point)((new Tool.Point(map.nfo.dbRefMapSize.Width, 0) - min) / size);

            //  DB bounding box
            {
                Tool.Point[] points = new Tool.Point[]
                {
                    new Tool.Point(0, 0),
                    new Tool.Point(0, 1),
                    new Tool.Point(1, 1),
                    new Tool.Point(1, 0),
                    new Tool.Point(0, 0)
                };
                AddPathDef(points, new Pen(Color.Green, 1));
            }

            // DB map boundaries
            boundaries[0] = map.nfo.dbMapOffsetUnit;
            boundaries[1] = boundaries[0] + map.nfo.dbMapSize / map.nfo.dbRefMapSize;

            // Control points
            Tool.Size Csize = (boundaries[1] - boundaries[0]) / (defBoundaries[1] - defBoundaries[0]);

            controls[0] = (Tool.Point)(boundaries[0] - defBoundaries[0] * Csize);
            controls[1] = controls[0] + Csize;

            controls[2] = new Tool.Point(controls[1].X, controls[0].Y);
            controls[3] = new Tool.Point(controls[0].X, controls[1].Y);
        }