Exemple #1
0
        void AddFileViwe(string[] fileNames)
        {
            var temps = (this.lbFiles.Tag as List <ItemFileInfo>);

            foreach (var itemFile in fileNames)
            {
                string extname = System.IO.Path.GetExtension(itemFile);
                string name    = System.IO.Path.GetFileName(itemFile);

                if (extname.ToLower().Equals(".xls") || extname.ToLower().Equals(".proto") || extname.ToLower().Equals(".xml"))
                {
                    var tifi = temps.FirstOrDefault(l => l.Name == name);
                    if (tifi == null)
                    {
                        var ifi = new ItemFileInfo(itemFile);
                        (this.lbFiles.Tag as List <ItemFileInfo>).Add(ifi);
                        this.lbFiles.Items.Add(ifi);
                    }
                    else
                    {
                        Show("无需添加的文件:" + name);
                    }
                }
            }
            if (this.lbFiles.Items.Count > 0)
            {
                this.lbFiles.SelectedIndex = 0;
            }
        }
Exemple #2
0
        private void btnblock_Click(object sender, EventArgs e)
        {
            try
            {
                object obj = this.lbFiles.SelectedItem;
                if (obj is ItemFileInfo)
                {
                    ItemFileInfo item = (ItemFileInfo)obj;

                    string filename = System.IO.Path.GetFileName(item.Path);

                    MapBlockConfig block = new MapBlockConfig();
                    System.Xml.Serialization.XmlSerializer xml = new System.Xml.Serialization.XmlSerializer(block.GetType());
                    System.IO.FileStream fs = new System.IO.FileStream(item.Path, System.IO.FileMode.Open);
                    block = (MapBlockConfig)xml.Deserialize(fs);
                    fs.Dispose();

                    float x = 0;

                    float z = 0;

                    float.TryParse(this.tbblockx.Text, out x);

                    float.TryParse(this.tbblocky.Text, out z);

                    int ix = seat_X(x);

                    int iz = seat_Y(z);

                    Show("X:" + this.tbblockx.Text + " Z:" + this.tbblocky.Text + " Ix:" + ix + " Ix:" + iz + " 阻挡结果:" + block.Walk.Blockinfo[block.Walk.Rxlen * iz + ix]);

                    Bitmap   bitmap = new Bitmap(block.Walk.Rxlen * 10, block.Walk.Rzlen * 15);
                    Graphics g      = Graphics.FromImage(bitmap);
                    g.FillRectangle(Brushes.Black, 0, 0, bitmap.Width, bitmap.Height);
                    SolidBrush brush     = new SolidBrush(Color.White);
                    SolidBrush brushRead = new SolidBrush(Color.Red);
                    Font       crFont    = crFont = new Font("arial", 11, FontStyle.Regular);

                    for (int z1 = block.Walk.Rzlen - 1; z1 >= 0; z1--)
                    {
                        for (int x1 = 0; x1 < block.Walk.Rxlen; x1++)
                        {
                            char b = block.Walk.Blockinfo[block.Walk.Rxlen * z1 + x1];
                            if (z1 == iz && x1 == ix)
                            {
                                g.DrawString(b + "", crFont, brushRead, x1 * 10, (block.Walk.Rzlen - 1 - z1) * 15);
                            }
                            else
                            {
                                g.DrawString(b + "", crFont, brush, x1 * 10, (block.Walk.Rzlen - 1 - z1) * 15);
                            }
                        }
                    }
                    g.Dispose();

                    bitmap.Save(CreateBase.BasePath + "/" + "blockimg" + "/" + filename + ".jpg");
                    bitmap.Dispose();

                    Show("文件:" + filename + " 阻挡图片已经生成");

                    System.Diagnostics.Process.Start(CreateBase.BasePath + "/" + "blockimg" + "/");
                }
            }
            catch (Exception ex)
            {
                Show("阻挡转化错误" + ex.ToString());
            }
        }