public DoorRectangle DoSelectedDoor(Point p) { bool vali = false; DoorRectangle door = null; foreach (var item in this._doors) { RectangleF rect = item.GetRect(_mapRect); if (rect.Contains(p)) { item.IsSelected = true; door = item; vali = true; } else if (item.IsSelected) { item.IsSelected = false; vali = true; } } if (vali) { this.Invalidate(); } return(door); }
private void MapCtrl_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { _lastMouseMoveDown = Cursor.Position; _downSelectDoor = DoSelectedDoor(e.Location); } }
private void UpdateDoorAttri(DoorRectangle door, RectangleF rect) { door.RatioX = (rect.X - _mapRect.X) / _mapRect.Width; door.RatioY = (rect.Y - _mapRect.Y) / _mapRect.Height; door.RatioHeight = rect.Height / _mapRect.Height; door.RatioWidth = rect.Width / _mapRect.Width; this.Invalidate(); }
private void cmsFullMap_Opened(object sender, EventArgs e) { _rightClick = null; Point m = this.PointToClient(Cursor.Position); foreach (var item in this._doors) { if (item != null && item.Door != null) { var rect = item.GetRect(_mapRect); if (rect.Contains(m)) { _rightClick = item; break; } } } tsmiDoorStateCfg.Visible = tsmiRemoteOpen.Visible = _rightClick != null; }
public void LoadMapInfo(Maticsoft.Model.SMT_MAP_INFO mapInfo) { _doors.Clear(); _mapImage = null; if (mapInfo == null) { this.Invalidate(); return; } _mapName = mapInfo.MAP_NAME; if (mapInfo.MAP_IMAGE != null && mapInfo.MAP_IMAGE.Length > 0) { MemoryStream ms = new MemoryStream(mapInfo.MAP_IMAGE); //Image image = Image.FromStream(ms); _mapImage = Image.FromStream(ms); //image.Dispose(); ms.Dispose(); } if (mapInfo.MAP_DOORS != null && mapInfo.MAP_DOORS.Count > 0) { foreach (var item in mapInfo.MAP_DOORS) { DoorRectangle dr = new DoorRectangle(); dr.Id = item.DOOR_ID; dr.DoorType = item.DOOR_TYPE; dr.IsSelected = false; dr.RatioX = (double)item.LOCATION_X; dr.RatioY = (double)item.LOCATION_Y; dr.RatioWidth = (double)item.WIDTH; dr.RatioHeight = (double)item.HEIGHT; if (item.DOOR_TYPE == 1) { dr.Door = item.DOOR; } else if (item.DOOR_TYPE == 2) { dr.Door = item.FACE; } if (item.DOOR_TYPE == 1 && item.DOOR != null) { dr.IsOnline = item.DOOR.OPEN_STATE != 2; if (item.DOOR.CTRL_STYLE == 1) { dr.IsOpen = true; } else if (item.DOOR.CTRL_STYLE == 2) { dr.IsOpen = false; } else { dr.IsOpen = item.DOOR.OPEN_STATE == 1; } dr.DoorName = item.DOOR.DOOR_NAME; } else if (item.FACE != null) { dr.DoorName = item.FACE.FACEDEV_NAME; } _doors.Add(dr); } } this.Invalidate(); }
public void AddDoorInfo(Maticsoft.Model.SMT_DOOR_INFO doorInfo, Maticsoft.Model.SMT_FACERECG_DEVICE faceDevInfo, Point ctrlPoint) { decimal id = 0; int type = 1; string doorname = ""; if (doorInfo != null) { id = doorInfo.ID; type = 1; doorname = doorInfo.DOOR_NAME; } else if (faceDevInfo != null) { id = faceDevInfo.ID; type = 2; doorname = faceDevInfo.FACEDEV_NAME; } else { return; } if (_doors.Exists(m => m.Id == id && m.DoorType == type)) { return; } DoorRectangle dr = new DoorRectangle(); dr.Id = id; dr.DoorType = type; dr.DoorName = doorname; dr.IsOnline = true; dr.IsOpen = false; dr.IsSelected = false; PointF pf = ToExtentPoint(ctrlPoint); dr.RatioX = pf.X; dr.RatioY = pf.Y; dr.RatioWidth = (double)32 / _mapRect.Width; dr.RatioHeight = (double)32 / _mapRect.Height; RectangleF rect = dr.GetRect(_mapRect); if (rect.Left - _mapRect.Left < 0) { dr.RatioX = 0; } if (rect.Top - _mapRect.Top < 0) { dr.RatioY = 0; } if (rect.Right > _mapRect.Right) { dr.RatioX -= (rect.Right - _mapRect.Right) / _mapRect.Width; } if (rect.Bottom > _mapRect.Bottom) { dr.RatioY -= (rect.Bottom - _mapRect.Bottom) / _mapRect.Height; } _doors.Add(dr); this.Invalidate(); }