Beispiel #1
0
 private void LoadMap()
 {
     MapList.Clear();
     if (Map != null)
     {
         this.OldMapWidth = this.Map.Width;
         this.OldMapHeight = this.Map.Height;
         this.WidthHeightBili = (double)this.OldMapWidth / (double)this.OldMapHeight;
     }
     if (Map != null)
         this.MapWidth = this.Width;
     if (Map != null)
         this.MapHeight = Convert.ToInt32((double)this.MapWidth / this.WidthHeightBili);
     this.PicMinBox.Image = MinMap;
     MapList.Clear();
     MapInfo m = new MapInfo(MapX, MapY, this.MapWidth, this.MapHeight);
     MapList.Add(m);
     zoomleft = this.Width / 10;
     zoomtop = this.Height / 10;
     zoomwidth = this.Width * 4 / 5;
     movezoomleft = (float)this.Width / (float)100;
     movezoomtop = (float)this.Height / (float)100;
     movezoomwidth = this.Width * 98 / 100;
 }
Beispiel #2
0
        private void ZzhaMapGis_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                if (!isSetting)
                {
                    #region[非配置操作]
                    if (e.Button == MouseButtons.Left)
                    {
                        if (MoveOrRect == 1)
                        {
                            this.isMouseDown = false;
                            //this.MouseUpX = e.X;
                            //this.MouseUpY = e.Y;
                            //foreach (Mover m in MoverList)
                            //{
                            //    m.LeftLenght =m.LeftLenght + e.X - MouseDownX;
                            //    m.TopLength =m.TopLength + e.Y - MouseDownY;
                            //}
                        }
                        if (MoveOrRect == 2)
                        {
                            rect = new Rectangle();
                            FlashMap();
                            int width = e.X - RectLeft;
                            int height = e.Y - RectTop;
                            if (Math.Abs(height) > Math.Abs(width) && width > 0)
                            {
                                //if (height > 0)
                                //{
                                height = Math.Abs(height);
                                if (this.MapWidth < MaxWidth)
                                {
                                    this.MapWidth = MapWidth * this.Height / height;
                                    this.MapHeight = Convert.ToInt32((double)this.MapWidth / this.WidthHeightBili);
                                    MapX = -((RectLeft < e.X ? RectLeft : e.X) - MapX) * this.Height / height + this.Width / 2 - width * this.Height / height / 2;
                                    MapY = -((RectTop < e.Y ? RectTop : e.Y) - MapY) * this.Height / height;
                                    MapInfo m = new MapInfo(MapX, MapY, MapWidth, MapHeight);
                                    if (MoverList.Count > 0)
                                    {
                                        foreach (Mover mover in MoverList)
                                        {
                                            this.MoveMover(mover);
                                        }
                                    }
                                    FalshStations();
                                    FalshStatics();
                                    CheckDivRount();
                                    FlashMap();
                                    this.MapList.Add(m);
                                }

                                //}
                                //else
                                //{
                                //    if (height < 0)
                                //    {
                                //        if (MapList.Count > 1)
                                //        {
                                //            this.MapList.RemoveAt(MapList.Count - 1);
                                //            MapInfo m = MapList[MapList.Count - 1];
                                //            MapX = m.MapLeft;
                                //            MapY = m.MapTop;
                                //            this.MapWidth = m.MapWidth;
                                //            this.MapHeight = m.MapHeight;
                                //            if (MoverList.Count > 0)
                                //            {
                                //                foreach (Mover mover in MoverList)
                                //                {
                                //                    this.MoveMover(mover);
                                //                }
                                //            }
                                //            FalshStations();
                                //            FalshStatics();
                                //            FlashMap();
                                //        }
                                //    }
                                //}
                            }
                            else
                            {
                                if (width > 0)
                                {
                                    if (this.MapWidth < MaxWidth)
                                    {
                                        this.MapWidth = MapWidth * this.Width / width;
                                        this.MapHeight = Convert.ToInt32((double)this.MapWidth / this.WidthHeightBili);
                                        MapX = -((RectLeft < e.X ? RectLeft : e.X) - MapX) * this.Width / width;
                                        MapY = -((RectTop < e.Y ? RectTop : e.Y) - MapY) * this.Width / width;
                                        //MapX = -(RectLeft - MapX) * this.Width / width;
                                        //MapY = -(RectTop - MapY) * this.Width / width;
                                        MapInfo m = new MapInfo(MapX, MapY, MapWidth, MapHeight);
                                        if (MoverList.Count > 0)
                                        {
                                            foreach (Mover mover in MoverList)
                                            {
                                                this.MoveMover(mover);
                                            }
                                        }
                                        FalshStations();
                                        FalshStatics();
                                        CheckDivRount();
                                        FlashMap();
                                        this.MapList.Add(m);
                                    }
                                }
                                else
                                {
                                    if (width < 0)
                                    {
                                        if (MapList.Count > 1)
                                        {
                                            this.MapList.RemoveAt(MapList.Count - 1);
                                            MapInfo m = MapList[MapList.Count - 1];
                                            MapX = m.MapLeft;
                                            MapY = m.MapTop;
                                            this.MapWidth = m.MapWidth;
                                            this.MapHeight = m.MapHeight;
                                            if (MoverList.Count > 0)
                                            {
                                                foreach (Mover mover in MoverList)
                                                {
                                                    this.MoveMover(mover);
                                                }
                                            }
                                            FalshStations();
                                            FalshStatics();
                                            CheckDivRount();
                                            FlashMap();
                                        }
                                    }
                                }
                            }
                        }

                    }
                    #endregion
                }
                else
                {
                    #region[配置操作]
                    if (e.Button == MouseButtons.Left)
                    {
                        if (MoveOrRect == 1)
                        {
                            this.IsStationLeftMouseDown = false;
                            this.Cursor = Cursors.Default;
                        }
                    }

                    if (e.Button == MouseButtons.Left)
                    {
                        if (MoveOrRect == 1)
                        {
                            this.isMouseDown = false;
                            this.Cursor = Cursors.Default;
                            //this.MouseUpX = e.X;
                            //this.MouseUpY = e.Y;
                            //foreach (Mover m in MoverList)
                            //{
                            //    m.LeftLenght =m.LeftLenght + e.X - MouseDownX;
                            //    m.TopLength =m.TopLength + e.Y - MouseDownY;
                            //}
                        }
                        if (MoveOrRect == 2)
                        {
                            rect = new Rectangle();
                            FlashMap();
                            int width = e.X - RectLeft;
                            int height = e.Y - RectTop;
                            if (Math.Abs(height) > Math.Abs(width) && width > 0)
                            {
                                //if (height > 0)
                                //{
                                height = Math.Abs(height);
                                if (this.MapWidth < MaxWidth)
                                {
                                    this.MapWidth = MapWidth * this.Height / height;
                                    this.MapHeight = MapHeight * this.Height / height;
                                    MapX = -((RectLeft < e.X ? RectLeft : e.X) - MapX) * this.Height / height + this.Width / 2 - width * this.Height / height / 2;
                                    MapY = -((RectTop < e.Y ? RectTop : e.Y) - MapY) * this.Height / height;
                                    MapInfo m = new MapInfo(MapX, MapY, MapWidth, MapHeight);
                                    if (MoverList.Count > 0)
                                    {
                                        foreach (Mover mover in MoverList)
                                        {
                                            this.MoveMover(mover);
                                        }
                                    }
                                    FalshStations();
                                    FalshStatics();
                                    FlashMap();
                                    this.MapList.Add(m);
                                }
                            }
                            else
                            {
                                if (width > 0)
                                {
                                    if (this.MapWidth < MaxWidth)
                                    {
                                        this.MapWidth = MapWidth * this.Width / width;
                                        this.MapHeight = MapHeight * this.Width / width;
                                        MapX = -((RectLeft < e.X ? RectLeft : e.X) - MapX) * this.Width / width;
                                        MapY = -((RectTop < e.Y ? RectTop : e.Y) - MapY) * this.Width / width;
                                        //MapX = -(RectLeft - MapX) * this.Width / width;
                                        //MapY = -(RectTop - MapY) * this.Width / width;
                                        MapInfo m = new MapInfo(MapX, MapY, MapWidth, MapHeight);
                                        if (MoverList.Count > 0)
                                        {
                                            foreach (Mover mover in MoverList)
                                            {
                                                this.MoveMover(mover);
                                            }
                                        }
                                        FalshStations();
                                        FalshStatics();
                                        FlashMap();
                                        this.MapList.Add(m);
                                    }
                                }
                                else
                                {
                                    if (width < 0)
                                    {
                                        if (MapList.Count > 1)
                                        {
                                            this.MapList.RemoveAt(MapList.Count - 1);
                                            MapInfo m = MapList[MapList.Count - 1];
                                            MapX = m.MapLeft;
                                            MapY = m.MapTop;
                                            this.MapWidth = m.MapWidth;
                                            this.MapHeight = m.MapHeight;
                                            if (MoverList.Count > 0)
                                            {
                                                foreach (Mover mover in MoverList)
                                                {
                                                    this.MoveMover(mover);
                                                }
                                            }
                                            FalshStations();
                                            FalshStatics();
                                            FlashMap();
                                        }
                                    }
                                }
                            }
                        }
                        if (MoveOrRect == 3)
                        {
                            this.Cursor = Cursors.Default;
                        }
                    }
                    #endregion
                }
                if (this.Map == null)
                    this.Refresh();
            }
            catch (Exception ex)
            {
                this.Refresh();
            }
        }