public void DrawDialog(DialogGroup dialogControl) { this.CurrentDialog = dialogControl; Grid container = (Grid)LogicalTreeHelper.FindLogicalNode(WindowController.Get<MainWindow>(), "grid_View"); Game.Instance.Player.Location.BlurBackground(); this.Dialog = null; container.Children.RemoveRange(1, container.Children.Count); MediaElement pb = new MediaElement(); if (this.CurrentDialog.Current().Image != null) { pb.Stretch = System.Windows.Media.Stretch.Uniform; pb.Name = "pb_Action"; pb.StretchDirection = StretchDirection.Both; pb.Source = new Uri(this.CurrentDialog.Current().Image); pb.VerticalAlignment = VerticalAlignment.Center; pb.HorizontalAlignment = HorizontalAlignment.Center; container.Children.Add(pb); } container.PreviewMouseRightButtonUp += ToggleDialog; this.CurrentDialog.Current().PrepareBeginEffects(container); this.AddDialogControl(); this.CurrentDialog.Current().StartBeginEffects(); }
private void AddDialogControl() { Grid container = (Grid)LogicalTreeHelper.FindLogicalNode(WindowController.Get<MainWindow>(), "grid_View"); this.Dialog = new GUI.Controls.Dialog(); this.Dialog.Name = "dialog"; this.Dialog.Width = container.Width; this.Dialog.Height = 150; this.Dialog.Margin = new Thickness(10); this.Dialog.Background = Brushes.Transparent; this.Dialog.VerticalAlignment = VerticalAlignment.Bottom; this.Dialog.HorizontalAlignment = HorizontalAlignment.Stretch; container.Children.Add(this.Dialog); ((Button)this.Dialog.FindName("btn_Next")).Click += NextDialog; ((Button)this.Dialog.FindName("btn_Prev")).Click += PrevDialog; TextBlock lbl = (TextBlock)LogicalTreeHelper.FindLogicalNode(container, "text_Message"); lbl.Text = ""; lbl.Foreground = Brushes.LightGray; lbl.Background = new SolidColorBrush(Brushes.Black.Color); lbl.Background.Opacity = 0.8; lbl.FontFamily = ResourceController.GetFont("Montserrat"); Label pageCounter = (Label)LogicalTreeHelper.FindLogicalNode(container, "lbl_Page"); pageCounter.Content = (this.CurrentDialog.Index + 1) + " / " + this.CurrentDialog.Entries.Count; pageCounter.Foreground = Brushes.LightGray; pageCounter.Background = new SolidColorBrush(Brushes.Black.Color); pageCounter.Background.Opacity = 0.8; pageCounter.FontFamily = ResourceController.GetFont("Montserrat"); StackPanel panel = new StackPanel(); panel.HorizontalAlignment = HorizontalAlignment.Right; panel.VerticalAlignment = VerticalAlignment.Center; foreach (DialogChoice choice in this.CurrentDialog.Current().Choices) { Button btn = new Button(); btn.Content = choice.Text; btn.Tag = choice; btn.Padding = new Thickness(5); btn.Click += ChoiceClick; panel.Children.Add(btn); ((Button)this.Dialog.FindName("btn_Next")).IsEnabled = false; } container.Children.Add(panel); if (this.CurrentDialog.Index <= 0) { ((Button)this.Dialog.FindName("btn_Prev")).IsEnabled = false; } Game.Instance.WindowController.Update(); this.TypingTicks = 0; this.TypingTimer.Elapsed -= TypeIncremental; this.TypingTimer.Elapsed += TypeIncremental; this.TypingTimer.Interval = 30; this.TypingTimer.Start(); }