예제 #1
0
 /// <summary>
 /// Called when this view gets disposed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void OnDisposed(object sender, EventArgs e)
 {
     if (!this.DesignMode)
     {
         m_renderLoop.Dispose();
         m_renderLoop = null;
     }
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SeeingSharpRendererControl"/> class.
        /// </summary>
        public SeeingSharpRendererControl()
        {
            //Set style parameters for this control
            base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            base.SetStyle(ControlStyles.ResizeRedraw, true);
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            base.SetStyle(ControlStyles.Opaque, true);
            base.SetStyle(ControlStyles.Selectable, true);
            base.DoubleBuffered = false;

            //Create the render loop
            GraphicsCore.Touch();
            m_renderLoop = new RenderLoop(SynchronizationContext.Current, this, this.DesignMode);
            m_renderLoop.ManipulateFilterList += OnRenderLoopManipulateFilterList;
            m_renderLoop.ClearColor            = new Color4(this.BackColor);
            m_renderLoop.DiscardRendering      = true;
            this.Disposed += (sender, eArgs) =>
            {
                m_renderLoop.Dispose();
            };

            // Perform default initialization logic (if not called before)
            if (SeeingSharpApplication.IsInitialized)
            {
                m_renderLoop.SetScene(new Scene());
                m_renderLoop.Camera = new PerspectiveCamera3D();

                //Observe resize event and throttle them
                this.HandleCreateDisposeOnControl(
                    () => Observable.FromEventPattern(this, "Resize")
                    .Merge(Observable.FromEventPattern(m_renderLoop.ViewConfiguration, "ConfigurationChanged"))
                    .Throttle(TimeSpan.FromSeconds(0.5))
                    .ObserveOn(SynchronizationContext.Current)
                    .Subscribe((eArgs) => OnThrottledViewRecreation()));

                //Initialize background brush
                UpdateDrawingResourcesForFailoverRendering();

                // Observe mouse click event
                this.HandleCreateDisposeOnControl(() =>
                {
                    var mouseDownEvent = Observable.FromEventPattern <MouseEventArgs>(this, "MouseDown");
                    var mouseUpEvent   = Observable.FromEventPattern <MouseEventArgs>(this, "MouseUp");
                    var mouseClick     = from down in mouseDownEvent
                                         let timeStampDown = DateTime.UtcNow
                                                             from up in mouseUpEvent
                                                             where up.EventArgs.Button == down.EventArgs.Button
                                                             let timeStampUp = DateTime.UtcNow
                                                                               where timeStampUp - timeStampDown < TimeSpan.FromMilliseconds(200.0)
                                                                               select new { Down = down, Up = up };
                    return(mouseClick.Subscribe((givenItem) =>
                    {
                        MouseClickEx.Raise(this, givenItem.Up.EventArgs);
                    }));
                });
            }

            this.Disposed += OnDisposed;

            UpdateDrawingResourcesForFailoverRendering();
        }
예제 #3
0
 public void Dispose()
 {
     looper.Dispose();
 }
예제 #4
0
 /// <summary>
 /// Führt anwendungsspezifische Aufgaben aus, die mit dem Freigeben, Zurückgeben oder Zurücksetzen von nicht verwalteten Ressourcen zusammenhängen.
 /// </summary>
 public void Dispose()
 {
     m_renderLoop.Dispose();
 }
예제 #5
0
 public void Dispose()
 {
     _renderLoop.Dispose();
     Form.Dispose();
 }