Esempio n. 1
0
        private void PictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            PictureBox pb = ((PictureBox)sender);

            string[] pos = pb.Name.Split(':');
            Int64    x   = Convert.ToInt64(pos[0]);
            Int64    y   = Convert.ToInt64(pos[1]);

            if (_ImageList != null && _ImageIndex < _ImageList.Images.Count)
            {
                if (_ImageIndex >= 0)
                {
                    pb.Image = _ImageList.Images[_ImageIndex];
                    stImage       curImage = _GetImageByID(Convert.ToInt32(_CurImage.Image_ID), Convert.ToInt32(_CurImage.Image_State));
                    ImageProperty imgPro   = new ImageProperty();
                    imgPro.Image_ID    = _CurImage.Image_ID;
                    imgPro.Image_State = curImage.Image_State;
                    imgPro.Image_Index = _ImageIndex;
                    int img_level = Convert.ToInt32(curImage.Image_Level);
                    if (!_ImageArray[x, y].ContainsKey(img_level))
                    {
                        _ImageArray[x, y].Add(img_level, imgPro);
                    }
                    else
                    {
                        _ImageArray[x, y][img_level] = imgPro;
                    }
                    UpdateJsonStr();
                }
                _OnClickPB((int)x, (int)y, _ImageArray[(int)x, (int)y]);
            }
        }
Esempio n. 2
0
        void ResetByConfig(string config)
        {
            try
            {
                //解析每个元素
                SortedDictionary <int, ImageProperty>[,] imageArray = new SortedDictionary <int, ImageProperty> [9, 9];
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        imageArray[i, j] = new SortedDictionary <int, ImageProperty>();
                    }
                }
                string[] xCfgArray = config.Substring(7).Replace("]]", "@").Split('@');
                int      x         = 0;
                for (int n = 0; n < xCfgArray.Length; n++)
                {
                    if (n == 9)
                    {
                        break;
                    }
                    int      y            = 0;
                    string[] subXcfgArray = xCfgArray[n].Replace(",[", "@").Split('@');
                    for (int k = 0; k < subXcfgArray.Length; k++)
                    {
                        if (subXcfgArray[k] == "")
                        {
                            continue;
                        }
                        string content = "";
                        int    offset  = 0;
                        if (k == 0 && n == 0)
                        {
                            offset = 7;
                        }
                        if (k == 0 && n != 0)
                        {
                            offset = 5;
                        }
                        string tempXCfg = subXcfgArray[k].Substring(offset);
                        content = tempXCfg.IndexOf(']') >= 0 ? tempXCfg.Remove(tempXCfg.IndexOf(']')) : tempXCfg;
                        string[] levelList = content.Split(',');
                        for (int m = 0; m < levelList.Length; m++)
                        {
                            string[] info = levelList[m].Split(':');
                            if (info.Length == 1 && (info[0] == "-1\"" || info[0] == "\"-1\""))
                            {
                                break;
                            }
                            int offset2 = 0;
                            if (info.Length >= 2)
                            {
                                offset2 = 1;
                            }
                            ImageProperty ip = new ImageProperty();
                            ip.Image_ID    = info.Length == 2 ? Convert.ToInt64(info[0].Substring(offset2)) : Convert.ToInt64(info[0].Substring(1).Remove(info[0].Substring(1).IndexOf('"')));
                            ip.Image_State = info.Length == 2 ? Convert.ToInt64(info[1].Remove(info[1].IndexOf('"'))) : Convert.ToInt64(Const.NoState);
                            ip.Image_Index = GetImageIndexByImgId(ip.Image_ID, ip.Image_State);
                            stImage imgInfo = DB_GetImageByImageID((int)ip.Image_ID, ip.Image_State);
                            imageArray[x, y].Add((int)imgInfo.Image_Level, ip);
                        }
                        y++;
                    }
                    x++;
                }

                mapControl1.LoadConfig(imageArray);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }