Beispiel #1
0
        /// <summary>
        /// 自动拼接图片
        /// </summary>
        /// <param name="dicImage"></param>
        /// <param name="path">保存路径</param>
        public static void CreateImage(Dictionary <string, List <Image> > dicImage, string path, Handlers.ProcessNotifyHandler processNotifyHandler, RowColumns rc)
        {
            try
            {
                //图片列表
                if (dicImage.Count <= 0)
                {
                    return;
                }
                int width  = 0;
                int height = 0;
                //计算总长度
                List <Image> temp = null;
                foreach (var i in dicImage)
                {
                    if (i.Value.Count == 0)
                    {
                        width += 256;
                    }
                    else
                    {
                        width += i.Value[0].Width;
                    }
                    temp = i.Value;
                }
                foreach (Image image in temp)
                {
                    height += image.Height;
                }
                //构造最终的图片白板
                Bitmap   tableChartImage = new Bitmap(width, height);
                Graphics graph           = Graphics.FromImage(tableChartImage);
                //初始化这个大图
                graph.DrawImage(tableChartImage, width, height);

                int currentWidth = 0;
                int k            = 0;
                int count        = (rc.maxRow - rc.minRow + 1) * (rc.maxCol - rc.minCol + 1);
                foreach (var i in dicImage)
                {
                    //拼图
                    Image currentImage  = null;
                    int   currentHeight = 0;
                    foreach (Image image in i.Value)
                    {
                        graph.DrawImage(image, currentWidth, currentHeight);
                        //拼接改图后,当前宽度
                        currentHeight += image.Height;
                        currentImage   = image;
                        k++;
                        string msg = "提示:已处理第" + rc.zoom.ToString() + "级," + k.ToString() + "条,共" + count.ToString() + "条";
                        if (processNotifyHandler != null)
                        {
                            processNotifyHandler(msg, (k * 100) / count);
                        }
                    }
                    currentWidth += currentImage.Width;
                }
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                tableChartImage.Save(path + "\\temp.tif", System.Drawing.Imaging.ImageFormat.Tiff);
                graph.Dispose();
                tableChartImage.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            Thread t = new Thread(this.AddCityNode);

            t.Start();

            mapPanelNew.Controls.Clear();
            mapControl                       = new MapControl();
            mapControl.Dock                  = DockStyle.Fill;
            mapControl.mapMovingHandler     += new MapControl.MapMovingHandler(this.mapMovingHandler);
            mapControl.mapZoomedHandler     += new MapControl.MapZoomedHandler(this.mapZoomedHandler);
            mapControl.overlayEditedHandler += (extent) =>
            {
                this.maxX = extent.maxX;
                this.maxY = extent.maxY;
                this.minX = extent.minX;
                this.minY = extent.minY;
            };
            mapPanelNew.Controls.Add(mapControl);


            cmbMapType.DisplayMember = "Text";
            cmbMapType.Items.Clear();
            cmbMapType.Items.AddRange(
                new ComboxItem[]
            {
                new ComboxItem()
                {
                    Tag = "Google", Value = MapType.Google, Text = "谷歌矢量图"
                },
                new ComboxItem()
                {
                    Tag = "GoogleImage", Value = MapType.GoogleImage, Text = "谷歌影像图"
                },
                new ComboxItem()
                {
                    Tag = "TianDi", Value = MapType.Tiandi, Text = "天地矢量图"
                },
                new ComboxItem()
                {
                    Tag = "TianDiImage", Value = MapType.TiandiImage, Text = "天地影像图"
                },
                new ComboxItem()
                {
                    Tag = "GaoDe", Value = MapType.Gaode, Text = "高德矢量图"
                },
                new ComboxItem()
                {
                    Tag = "GaoDeImage", Value = MapType.GaodeImage, Text = "高德影像图"
                },
                new ComboxItem()
                {
                    Tag = "initOSMMap", Value = MapType.OpenStreetMap, Text = "OpenStreet"
                },
                new ComboxItem()
                {
                    Tag = "BaiduImage", Value = MapType.Baidu, Text = "百度矢量图"
                },
                new ComboxItem()
                {
                    Tag = "BaiduImageTile", Value = MapType.BaiduImageTile, Text = "百度影像图"
                },
                // new ComboxItem(){Tag = "InitQQMap",Value = MapType.QQMap,Text = "腾讯地图"},
            });
            cmbCoverteType.Items.Clear();
            this.cmbCoverteType.DisplayMember = "Text";
            this.cmbCoverteType.Items.AddRange(
                new ComboxItem[]
            {
                new ComboxItem()
                {
                    Text = "WGS84-->GCJ-02", Value = CovertType.WGS2GCJ02
                },
                new ComboxItem()
                {
                    Text = "WGS84-->百度", Value = CovertType.WGS2BAIDU
                },
                new ComboxItem()
                {
                    Text = "GCJ-02-->百度", Value = CovertType.GCJ022BAIDU
                },
                new ComboxItem()
                {
                    Text = "墨卡托平面-->经纬度", Value = CovertType.MOCTOR2LONLAT
                },
                new ComboxItem()
                {
                    Text = "经纬度(火星)-->墨卡托平面", Value = CovertType.LONLAT2MOCTOR
                },
                new ComboxItem()
                {
                    Text = "百度-->GCJ02", Value = CovertType.BAIDU2GCJ02
                },
                new ComboxItem()
                {
                    Text = "WGS84-->墨卡托平面", Value = CovertType.WGS2MOCTOR
                },
            });


            if (this.cmbMapType.Items.Count > 0)
            {
                cmbMapType.SelectedIndex = 2;
            }
            if (this.cmbCoverteType.Items.Count > 0)
            {
                this.cmbCoverteType.SelectedIndex = 0;
            }
            this.OnProcessNotify  += new Handlers.ProcessNotifyHandler(this.ShowMsg);
            this.OnProcessNotify2 += new Handlers.ProcessNotifyHandler(this.ShowMsg2);
            this.OnLog            += new Handlers.LogHandler(this.WriteLog);
            this.DownImage        += new Handlers.DownImageHandler(this.doNewThings);
            this.myTreeView.ExpandAll();
            this.tabControl.SelectedTab = tabItemMap;
            this.WriteLog("启动结束");
            List <WorkInfo> workInfos = WorkConfig.GetInstance().Commandconfig.workInfoList;

            foreach (WorkInfo workInfo in workInfos)
            {
                string x = "未完成下载:" + workInfo.processDownImage.processIndex.ToString() + "/"
                           + workInfo.processDownImage.count.ToString();
                string sta = "停止下载";
                if (workInfo.downStates == DownStates.start)
                {
                    sta = "暂停下载";
                }
                else if (workInfo.downStates == DownStates.pause)
                {
                    sta = "暂停下载";
                }
                else if (workInfo.downStates == DownStates.stop)
                {
                    sta = "停止下载";
                }
                else if (workInfo.downStates == DownStates.ready)
                {
                    sta = "完成下载";
                }
                if (workInfo.processDownImage.processIndex == workInfo.processDownImage.count)
                {
                    x = "已完成下载:" + workInfo.processDownImage.processIndex.ToString() + "/"
                        + workInfo.processDownImage.count.ToString();
                }
                int index = this.dataGridViewWorks.Rows.Add(
                    workInfo.workName,
                    x,
                    workInfo.processDownImage.secess.ToString() + "/" + workInfo.processDownImage.count.ToString(),
                    workInfo.processDownImage.lose.ToString() + "/" + workInfo.processDownImage.count.ToString(),
                    workInfo.processDownImage.lose.ToString() + "/" + workInfo.processDownImage.count.ToString(),
                    workInfo.processDownImage.count.ToString(),
                    sta);
                this.dataGridViewWorks.Rows[index].Tag = workInfo;
            }
            this.WindowState = FormWindowState.Maximized;
        }