private void OpenPresenterWindow() { presenterWindow = new PresenterWindow(); presenterWindow.DataContext = this; presenterWindow.Closing += (s, e) => { var result = MessageBox.Show("Na pewno zamknąć okno i wyłączyć aplikację?", "Uwaga", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Environment.Exit(0); } else { e.Cancel = true; } }; presenterWindow.Show(); MoveWindow.MaximizeToSecondaryMonitor(presenterWindow); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // configurate opengl var openglInit = new InitializeOpenGl(); openglInit.Execute(); // preform a load and init of all the scene's and components //ServiceLocator.Current.GetAllInstances<FrameworkElement>().ToArray(); _presenterWindow = ServiceLocator.Current.GetInstance<PresenterWindow>(); var refreshRate = DisplayDevice.Default.RefreshRate; Timeline.DesiredFrameRateProperty.OverrideMetadata( typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = Convert.ToInt32(refreshRate) } ); _framebuffer = new Framebuffer(Configuration.InternalResolution.Width, Configuration.InternalResolution.Height) {Name = "Framebuffer"}; // by default the presenter window stands in WPF rendering mode. // this meens there is a layout root (canvas) that has the aspect correction // render transform applied to it and contains a transition presenter. // The WPF engine takes care of framebuffers and all the interal stuff. // In the opengl rendering we need to manage this. // first we clean the transition presenter from the rendering queue // The transition presenter is passed as a seperate instance toafter we've pushed // the rendering framebuffer. _presenterWindow.LayoutRoot.Children.Clear(); // we replace the transition presenter with the framebuffer object _presenterWindow.LayoutRoot.Children.Add(_framebuffer); }