private void JeopardyCardDoubleClick(object sender, MouseButtonEventArgs e) { var card = e.Source as JeopardyCard; ClueWindow window = new ClueWindow(); window.MouseDoubleClick += (s, args) => { Mouse.OverrideCursor = Cursors.Arrow; GameCanvas.Children.Remove((UIElement)s); }; Point point = card.TransformToAncestor(Application.Current.MainWindow).Transform(new Point(0, 0)); window.Width = System.Windows.SystemParameters.WorkArea.Width; window.Height = System.Windows.SystemParameters.WorkArea.Height; window.SetValue(Canvas.LeftProperty, point.X + (card.ActualWidth / 2)); window.SetValue(Canvas.TopProperty, point.Y + (card.ActualHeight / 2)); window.ClueText = card.ClueText; Mouse.OverrideCursor = Cursors.None; kb.Reset(); GameCanvas.Children.Add(window); MainGrid.Children.Remove(card); }
/// <summary> /// Handles opening up a clue window from the card that was clicked on /// </summary> /// <param name="cardArgs"></param> private void CardClick(ClickCard cardArgs) { // Get the card that was clicked //var card = e.Source as JeopardyCard; var card = FindName(cardArgs.CardName) as JeopardyCard; // Create the new window to show over the grid ClueWindowBase window; if (IsPresenter) { window = new PresenterClueWindow() { Name = $"Clue{cardArgs.CardName}" } } ; else { window = new ClueWindow() { Name = $"Clue{cardArgs.CardName}" } }; //window.DataContext = kb; // Hook up the event that will close the window when it's double clicked window.MouseDoubleClick += (s, args) => { var clueWindow = s as ClueWindowBase; eventAggregator.GetEvent <PubSubEvent <ClickClue> >().Publish(new ClickClue { ClueName = clueWindow.Name }); }; // Set the width of the overlay window to the actual window window.Width = ActualWidth; window.Height = ActualHeight; // Place the overlay window directly over the actual window Window parentWindow = Window.GetWindow(this); Point point = card.TransformToAncestor(parentWindow).Transform(new Point(0, 0)); window.SetValue(Canvas.LeftProperty, point.X + (card.ActualWidth / 2)); window.SetValue(Canvas.TopProperty, point.Y + (card.ActualHeight / 2)); // Set the text on the overlay window window.ClueText = card.ClueText; window.ClueValue = (int)card.ClueValue; window.ClueAnswer = card.ClueAnswer; //window.TimerLength = // TODO: Add a dependency property? regular property? should be set from the main presenter window somehow? // Add the overlay window to the main window GameCanvas.Children.Add(window); kb.IsLocked = true; kb.SuspendNotifications(false); // Remove the original card so it can't be clicked on again MainGrid.Children.Remove(card); }