예제 #1
0
        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));
        }
예제 #2
0
        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++;
            }
        }
예제 #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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #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();
            }
        }
예제 #7
0
        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);
        }
예제 #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);
         }
     }
 }
예제 #9
0
        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;
        }
예제 #10
0
 public Tool.Point UnitToMap(Tool.Point from)
 {
     Tool.Point pt = from;
     pt.Y = 1.0f - pt.Y;
     return(pt * this.nfo.dbRefMapSize);
 }
예제 #11
0
 public Tool.Point UnitToDB(Tool.Point from)
 {
     return(from * this.nfo.dbRefMapSize);
 }
예제 #12
0
 public Rectangle TileRectangleEx(Tool.Point p, Tool.Size sz)
 {
     return(new Rectangle(Position + p * _tileSize, sz));
 }
예제 #13
0
 public Rectangle TileRectangle(Tool.Point p)
 {
     return(new Rectangle(Position + p * _tileSize, _tileSize));
 }
예제 #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);
        }