private bool _isBusying = false; // 地图运行中(存储/加载中) #endregion Fields #region Constructors public EMap() { InitializeComponent(); //打开双缓冲 SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true); ObjectProperty property = new ObjectProperty(); property.Name = "电子地图"; property.ChildSN = 0; AddMap(property); }
/// <summary> /// 设置属性 /// </summary> /// <param name="temp">设置的属性信息</param> private void SetProperty(ObjectProperty temp) { m_IsInit = true; _property = temp; TBox_Name.Text = _property.Name; TBox_Note.Text = _property.Note; TBox_X.Text = _property.X.ToString(); TBox_Y.Text = _property.Y.ToString(); m_IsInit = false; }
/// <summary> /// 增加地图标识 /// </summary> /// <param name="_type">标识类型</param> /// <param name="_name">名称</param> /// <param name="_status">状态</param> /// <param name="_node">地图标识所对应的设备树节点</param> /// <param name="_pt">标识物所处位置</param> public void AddObject(EMapType _type, string _name, WatchStatue _status, TreeNode _node,Point _pt) { EMapObject obj = new EMapObject(); //linwei 2008-5-28 //初始化右键菜单 ObjectProperty _property = new ObjectProperty(); _property.Type = _type; _property.Name = _name; _property.Status = _status; _property.ParentSN = MapIndex; obj.Property = _property; obj.Node = _node; Map.AddObject(obj); obj.Location = _pt; obj.Property.X = _pt.X; obj.Property.Y = _pt.Y; if (_type == EMapType.ChildMap) { obj.Property.IsArea = true; } obj.LoadPropertyEvnet +=new EventHandler<EventArgs>(obj_LoadPropertyEvnet); obj.NextLevelEvent+=new EventHandler<EventArgs>(obj_NextLevelEvent); obj.WatchEvent += new EventHandler<WatchEvnetArgs>(obj_WatchEvent); InitObjectEvent(obj); objlist.Add(obj); Select(obj); GetTip(obj); m_IsSaved = false; }
/// <summary> /// 增加地图 /// </summary> /// <param name="property">地图标识物属性</param> public void AddMap( ObjectProperty property) { //RenZihao 2008-08-05 增加区域时传进来地图标识物属性,这里面带的名字就直接当作新建的地图的名字 int _index = property.ChildSN; while (isBusying) { Application.DoEvents(); } isBusying = true; MapSelected = false; Clear(); //新建地图 EMapContainer map = new EMapContainer(); map.Property.SN = _index; map.Property.Name = property.Name;//string.Format("电子地图{0}", _index); map.Property.Note = property.Note; map.MapActivedEvent += new EventHandler<EventArgs>(map_MapActivedEvent); map.MapWarningEvent += new EventHandler<EventArgs>(map_MapWarningEvent); Map = map; Map.Property.ParentSN = m_mapindex; m_mapindex = _index; MapSelected = true; m_IsSaved = false; isBusying = false; }