Ejemplo n.º 1
0
        private void Init()
        {
            mapCtrl.ClearDoors();
            modelTree.Nodes[0].Nodes.Clear();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_MAP_INFO mapBll = new Maticsoft.BLL.SMT_MAP_INFO();
                    var maps = mapBll.GetModelListWithDoors("1=1");
                    this.Invoke(new Action(() =>
                    {
                        foreach (var item in maps)
                        {
                            AddTree(item);
                        }
                        modelTree.ExpandAll();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载地图列表异常:" + ex.Message);
                    log.Error("加载地图列表异常:", ex);
                }
            });

            waiting.Show(this);
        }
Ejemplo n.º 2
0
        private void biDeleteMap_Click(object sender, EventArgs e)
        {
            var map = GetSelectMap();

            if (map == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择要删除的地图!");
            }
            if (MessageBox.Show("确定删除选择地图?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                CtrlWaiting waiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        Maticsoft.BLL.SMT_MAP_DOOR mdbll = new Maticsoft.BLL.SMT_MAP_DOOR();
                        foreach (var item in map.MAP_DOORS)
                        {
                            mdbll.Delete(item.MAP_ID, item.DOOR_ID, item.DOOR_TYPE);
                        }
                        Maticsoft.BLL.SMT_MAP_INFO mapBll = new Maticsoft.BLL.SMT_MAP_INFO();
                        mapBll.Delete(map.ID);
                        this.Invoke(new Action(() =>
                        {
                            modelTree.SelectedNode.Remove();
                            mapCtrl.LoadMapInfo(null);
                        }));
                    }
                    catch (Exception ex)
                    {
                        WinInfoHelper.ShowInfoWindow(this, "删除地图异常:" + ex.Message);
                        log.Error("删除地图异常:", ex);
                    }
                });
                waiting.Show(this);
            }
        }
Ejemplo n.º 3
0
        private void biSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbMapName.Text))
            {
                WinInfoHelper.ShowInfoWindow(this, "地图名称不能为空!");
                tbMapName.Focus();
                return;
            }
            if (_mapInfo == null)
            {
                _mapInfo             = new Maticsoft.Model.SMT_MAP_INFO();
                _mapInfo.CREATE_TIME = DateTime.Now;
                _mapInfo.ID          = -1;
            }
            if (mapCtrl.MapImage != null)
            {
                MemoryStream ms = new MemoryStream();
                using (Bitmap bitmap = new Bitmap(mapCtrl.MapImage))
                {
                    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                _mapInfo.MAP_IMAGE = ms.GetBuffer();
                ms.Dispose();
            }
            else
            {
                _mapInfo.MAP_IMAGE = new byte[0];
            }
            _mapInfo.MAP_NAME = tbMapName.Text.Trim();
            _mapInfo.GROUP_ID = -1;
            var         doors   = mapCtrl.GetDoors();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_MAP_INFO mapBll       = new Maticsoft.BLL.SMT_MAP_INFO();
                    Maticsoft.BLL.SMT_MAP_DOOR mdBll        = new Maticsoft.BLL.SMT_MAP_DOOR();
                    List <Maticsoft.Model.SMT_MAP_DOOR> mds = new List <Maticsoft.Model.SMT_MAP_DOOR>();
                    foreach (var item in doors)
                    {
                        Maticsoft.Model.SMT_MAP_DOOR md = new Maticsoft.Model.SMT_MAP_DOOR();
                        md.DOOR_ID    = item.Id;
                        md.MAP_ID     = _mapInfo.ID;
                        md.DOOR_TYPE  = item.DoorType;
                        md.LOCATION_X = (decimal)item.RatioX;
                        md.LOCATION_Y = (decimal)item.RatioY;
                        md.WIDTH      = (decimal)item.RatioWidth;
                        md.HEIGHT     = (decimal)item.RatioHeight;
                        mds.Add(md);
                    }
                    if (_mapInfo.ID == -1)
                    {
                        _mapInfo.ID = mapBll.Add(_mapInfo);
                        SmtLog.Info("配置", "添加地图:" + _mapInfo.MAP_NAME);
                    }
                    else
                    {
                        mapBll.Update(_mapInfo);
                        SmtLog.Info("配置", "更新地图:" + _mapInfo.MAP_NAME);
                        var olds = mdBll.GetModelList("MAP_ID=" + _mapInfo.ID);
                        foreach (var old in olds)
                        {
                            mdBll.Delete(old.MAP_ID, old.DOOR_ID, old.DOOR_TYPE);
                        }
                    }
                    foreach (var md in mds)
                    {
                        md.MAP_ID = _mapInfo.ID;
                        mdBll.Add(md);
                        _selectNodes.Find(m =>
                        {
                            if (m.Tag is Maticsoft.Model.SMT_DOOR_INFO)
                            {
                                if (((Maticsoft.Model.SMT_DOOR_INFO)m.Tag).ID == md.DOOR_ID && md.DOOR_TYPE == 1)
                                {
                                    md.DOOR = (Maticsoft.Model.SMT_DOOR_INFO)m.Tag;
                                    return(true);
                                }
                            }
                            else if (m.Tag is Maticsoft.Model.SMT_FACERECG_DEVICE)
                            {
                                if (((Maticsoft.Model.SMT_FACERECG_DEVICE)m.Tag).ID == md.DOOR_ID && md.DOOR_TYPE == 2)
                                {
                                    md.FACE = (Maticsoft.Model.SMT_FACERECG_DEVICE)m.Tag;
                                    return(true);
                                }
                            }
                            return(false);
                        });
                    }
                    _mapInfo.MAP_DOORS = mds;

                    IsChanged = true;
                    this.Invoke(new Action(() =>
                    {
                        this.Text = "修改地图:" + tbMapName.Text;
                    }));
                    WinInfoHelper.ShowInfoWindow(this, "保存地图成功!");
                }
                catch (Exception ex)
                {
                    log.Error("保存地图异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "保存异常!" + ex.Message);
                }
            });

            waiting.Show(this);
        }