这是一张图片。
每个小房子都带有一个编号。
我想点这个编号,调出这家的信息。
但是我怎么能把程序和编号关联起来呢?
我要脱机使用。

解决方案 »

  1.   

    先做一个数据源,数据库,xml等等都可以;
    你可以把图片作为背景,在上面加一个透明的“Panel”加Tag值,然后使用鼠标点击事件,然后读取对应的数据显示出来!
    还有要怎么显示?弹出窗口,还是冒个泡泡(可以使用用户控件,动态添加)
      

  2.   

    做一个掩码图
    虽然 我没有做过 不过我的朋友做过 具体咋回事 我也不怎么说的清楚
    不过 说道这个 我倒是有一个思路
    用ps把这个图片 再做一下 把房子部分的图像全部用存的黑色填充 然后 比如1号房间的地方用红色 2号房间用蓝色........
    然后 这样你就得到了一张除了房间其他地方都是黑色的图片(假如名字叫:imgBack 原图:imgSrc)
    然后程序运行的时候 用一个pictureBox加载imgSrc 然后鼠标在上面点击的时候 把鼠标的坐标记录下来 
    然后根据鼠标坐标作为获取小数点的坐标 到imgBack的图像的响应坐标去获取像素点
    如果是黑色的表示没有点中 如果是红色表示1号 蓝色表示2号
    好吧这个只是我的一个思路 
      

  3.   


    一楼的可行,但是这只是一张图片上面,,应该有很多吧,,加panel不适合,,,
      

  4.   

    private void pbxMap_Click(object sender, EventArgs e)
            {
                  MouseEventArgs mea = (MouseEventArgs)e;
                //MessageBox.Show(mea.X.ToString() + "    " + mea.Y.ToString());
                  if (mea.Y <= 155 && mea.Y >= 145)
                {
                    if (mea.X <= 655 && mea.X >= 645)
                    {
                         MessageBox.Show("点击位置信息");
                    }
                }
    }
      

  5.   

    private void pbxMap_MouseMove(object sender, MouseEventArgs e)
            {
                  MouseEventArgs mea = (MouseEventArgs)e;
                //MessageBox.Show(mea.X.ToString() + "    " + mea.Y.ToString());
                  if (mea.Y <= 155 && mea.Y >= 140)
                {
                    if (mea.X <= 655 && mea.X >= 645)
                    {
                        pbxMap.Cursor = System.Windows.Forms.Cursors.Hand;
                    }
                    else
                    {
                        pbxMap.Cursor = System.Windows.Forms.Cursors.Default;
                    }
                }
    }
      

  6.   


    我这个图片很大,现在是PSD的,生成JPG大约30M。
    做成背景会不会卡呀?
    我这个图片有1500个房子,我加载1500个控件会不会卡死?
      

  7.   

    写了一个不知道能不能满足你的要求,不是很完善你参考一下。Bitmap bitmp = new Bitmap(Application.StartupPath + @"\default.jpg"); //原始大图片
            private bool isMove = false; //是否开始移动
            int oldX; //移动的原始X
            int oldY; //移动的原始Y
            float imageLocationX = 0; //图片显示的左上角
            float imageLocationY = 0;  //图片显示的右上角        private void Form2_Load(object sender, EventArgs e)
            {
                //双缓冲不闪
                this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);            float width = this.pictureBox1.Width;
                float hegiht = this.pictureBox1.Height;
                //如果图片大于桌面分辨率,可以不用这项
                if (width > bitmp.Width)
                {
                    width = bitmp.Width;
                }
                if (hegiht > bitmp.Height)
                {
                    hegiht = bitmp.Height;
                }
                //拷贝一个副本,没测试大图片,不知会不会有性能问题
                Bitmap bitmp2 = bitmp.Clone(new RectangleF(imageLocationX, imageLocationY, width, hegiht), bitmp.PixelFormat);
                this.pictureBox1.Image = bitmp2;
            }        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    isMove = true;
                    oldX = e.X;
                    oldY = e.Y;
                }
            }        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMove)
                {
                    //以下只是演示,没考虑其它因素,如果到图片到顶点、底点等等
                    float width = this.pictureBox1.Width;
                    float hegiht = this.pictureBox1.Height;                imageLocationX = Math.Abs(imageLocationX + oldX - e.X);
                    imageLocationY = Math.Abs(imageLocationY + oldY - e.Y);                if (width > bitmp.Width)
                    {
                        width = bitmp.Width;
                    }
                    if (hegiht > bitmp.Height)
                    {
                        hegiht = bitmp.Height;
                    }
                    this.pictureBox1.Image.Dispose();
                    Bitmap bitmp2 = bitmp.Clone(
                        new RectangleF(imageLocationX, imageLocationY, width, hegiht), bitmp.PixelFormat);
                    this.pictureBox1.Image = bitmp2;
                    oldX = e.X;
                    oldY = e.Y;
                }
            }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
                isMove = false;
            }        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
            {
                //保读取数据源中的数据,图上坐标点如:155,300,只是演示,自己考虑怎么定义这个区域
                int sx = 155 - (int)imageLocationX;
                int sy = 300 - (int)imageLocationY;
                //得到20*20的区域
                Rectangle rct = new Rectangle(sx - 10, sy - 10, 20, 20);
                if (rct.Contains(new Point(e.X, e.Y)))
                {
                    MessageBox.Show("信息155,300");
                }
            }
      

  8.   

    http://download.csdn.net/detail/crystal_lz/4390616
    自己做了一个     连接
      

  9.   

    LZ不好意思,这几天放假了,没上CSDN!
    DreamWeaver工具就可以设置图片热区,和每个热区的连接!或者用photoshop就可以切图!以上二选一即可!