protected override void RegisterRoomElement(RoomElement roomElement) { roomElement.MouseEnter += delegate { roomElement.Cursor = Cursors.Hand; roomElement.RenderTransform = new ScaleTransform { ScaleX = 1.1, ScaleY = 1.1, CenterX = roomElement.ActualWidth / 2, CenterY = roomElement.ActualHeight / 2 }; }; roomElement.MouseLeave += delegate { roomElement.Cursor = Cursors.Arrow; roomElement.RenderTransform = null; }; roomElement.MouseLeftButtonUp += delegate { roomElement.RenderTransform = null; var zoomedElement = new MazeFragmentElement(Game, roomElement.RoomInfo); UIElement rootVisual = Application.Current.RootVisual; Size mainSize = rootVisual.RenderSize; Size size = roomElement.RenderSize; double scaleW = mainSize.Width / size.Width; double scaleH = mainSize.Height / size.Height; double scale = Math.Min(scaleW, scaleH); double endWidth = size.Width * scale; double endHeight = size.Height * scale; Rect startRect = roomElement.GetRect(rootVisual); var endRect = new Rect((mainSize.Width - endWidth) / 2, (mainSize.Height - endHeight) / 2, endWidth, endHeight); // roomElement.Visibility = Visibility.Collapsed; UIManager.Instance.ShowInPopup(zoomedElement, startRect, endRect/*, delegate { roomElement.Visibility = Visibility.Visible; }*/); }; }
public void Update() { Children.Clear(); myRoomElements.Clear(); myRoomLinkElements.Clear(); if (Game == null) return; bool containsEnter = Rooms.Any(info => info.Room is IEnterRoom); foreach(IMazeRoomInfo roomInfo in Rooms) { // ReSharper disable AccessToModifiedClosure var roomElement = new RoomElement(roomInfo, Game.Players.Where(player => player.Location == roomInfo).ToList()); // ReSharper restore AccessToModifiedClosure Children.Add(roomElement); myRoomElements.Add(roomInfo, roomElement); RegisterRoomElement(roomElement); foreach(Direction direction in CoreUtil.EnumerateDirections()) { IRoomLink roomLink = roomInfo.Link(direction); int x = roomInfo.X; int y = roomInfo.Y; RoomLinkLocation location; switch(direction) { case Direction.Left: location = new RoomLinkLocation(x, y, true); break; case Direction.Right: location = new RoomLinkLocation(x + 1, y, true); break; case Direction.Up: location = new RoomLinkLocation(x, y, false); break; case Direction.Down: location = new RoomLinkLocation(x, y + 1, false); break; default: throw new ArgumentOutOfRangeException(); } if (containsEnter) { // skip links for enter room if (location.Vertical) { if (location.Y == 0 && (location.X == 0 || location.X == 1)) continue; } else { if (location.X == 0 && (location.Y == 0 || location.Y == 1)) continue; } } if (!myRoomLinkElements.ContainsKey(location)) { var linkElement = new RoomLinkElement(roomLink, location); Children.Add(linkElement); myRoomLinkElements.Add(location, linkElement); } } } InvalidateArrange(); }
protected virtual void RegisterRoomElement(RoomElement roomElement) { }