Пример #1
0
        private void OnRendering(object sender, RenderingEventArgs e) {
            if (!_animateTo.HasValue) return;

            var delta = (DateTime.Now - _previous).TotalMilliseconds / AnimationSpeed;
            _previous = DateTime.Now;
            SetPosition(_animateTo.Value < _position ? _position - delta : _position + delta);
        }
Пример #2
0
        public override void Update(object sender, System.Windows.Media.RenderingEventArgs args)
        {
            base.Update(sender, args);

            double delta = Watcher.ElapsedMilliseconds * Speed;

            Vector3D headDirection = Point3 - Point2;


            Watcher.Restart();
        }
        /// <summary>
        /// The rendering event handler.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            if (skipper.IsSkip())
            {
                return;
            }
            var ticks = e.RenderingTime.Ticks;
            var time = 100e-9 * (ticks - this.lastTick);

            if (this.lastTick != 0)
            {
                this.OnTimeStep(time);
            }

            this.lastTick = ticks;
        }
Пример #4
0
        /// <summary>
        /// The rendering event handler.
        /// </summary>
        /// <param name="sender">
        /// The sender. 
        /// </param>
        /// <param name="e">
        /// The event arguments. 
        /// </param>
        private void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            var ticks = e.RenderingTime.Ticks;
            double time = 100e-9 * (ticks - this.lastTick);

            if (this.lastTick != 0)
            {
                this.OnTimeStep(time);
            }

            this.lastTick = ticks;

            this.frameCounter++;
            if (this.ShowFrameRate && this.fpsWatch.ElapsedMilliseconds > 500)
            {
                this.FrameRate = (int)(this.frameCounter / (0.001 * this.fpsWatch.ElapsedMilliseconds));
                this.FrameRateText = this.FrameRate + " FPS";
                this.frameCounter = 0;
                this.fpsWatch.Reset();
                this.fpsWatch.Start();
            }

            // update the info fields every 100 frames
            // (it would be better to update only when the visual model of the Viewport3D changes)
            this.infoFrameCounter++;
            if (this.ShowTriangleCountInfo && this.infoFrameCounter > 100)
            {
                int count = this.GetTotalNumberOfTriangles();
                this.TriangleCountInfo = string.Format("Triangles: {0}", count);
                this.infoFrameCounter = 0;
            }
        }
Пример #5
0
 private void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     double delta = watch.ElapsedMilliseconds * 0.001;
     RotationAngle += 360 * RotationSpeed / 60 * delta;
     watch.Restart();
 }
Пример #6
0
 /// <summary>
 /// The compositiontarget rendering.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The event arguments.
 /// </param>
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     if (this.IsEnabled)
     {
         this.ApplyCuttingPlanes();
     }
 }
Пример #7
0
 void CompositionTargetEx_FrameUpdating(object sender, RenderingEventArgs e)
 {
     renderControl.Invalidate();
 }
Пример #8
0
        /// <summary>
        /// The composition target_ rendering.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            if (this.startTick == 0)
            {
                this.startTick = e.RenderingTime.Ticks;
            }

            double time = 100e-9 * (e.RenderingTime.Ticks - this.startTick);
            if (this.IsSorting && time >= 1.0 / this.SortingFrequency)
            {
                this.startTick = e.RenderingTime.Ticks;
                this.SortChildren();
            }
        }
Пример #9
0
        /// <summary>
        /// Handles the CompositionTarget.Rendering event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="System.Windows.Media.RenderingEventArgs" /> instance containing the event data.</param>
        protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs eventArgs)
        {
            if (this.isRendering && this.IsEnabled)
            {
                if (!this.IsAttachedToViewport3D())
                {
                    return;
                }

                if (this.UpdateTransforms())
                {
                    this.UpdateGeometry();
                }
            }
        }
Пример #10
0
        private void CalcFrameRate(RenderingEventArgs renderArgs)
        {
            TimeSpan dt = (renderArgs.RenderingTime - _lastRender);
            var framrate = (int)(1000 / dt.TotalMilliseconds);

            if (framrate > 0)
            {
                _frameTimesIndex = (_frameTimesIndex + 1) % _frameTimes.Length;
                _frameTimes[_frameTimesIndex] = framrate;
                FrameRate = (int)_frameTimes.Average();
            }
            // About to render...
            _lastRender = renderArgs.RenderingTime;
        }
        /// <summary>
        /// Handles the CompositionTarget.Rendering event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="System.Windows.Media.RenderingEventArgs"/> instance containing the event data.</param>
        protected void OnCompositionTargetRendering(object sender, RenderingEventArgs eventArgs)
        {
            if (this._IsRendering) {
            if (!Visual3DHelper.IsAttachedToViewport3D(this)) {
               return;
            }

            if (lastRenderTime == eventArgs.RenderingTime) {
               return;
            }

            lastRenderTime = eventArgs.RenderingTime;

            this.UpdateModel();
             }
        }
Пример #12
0
 /// <summary>
 /// Handles the CompositionTarget.Rendering event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The <see cref="System.Windows.Media.RenderingEventArgs" /> instance containing the event data.</param>
 protected virtual void OnCompositionTargetRendering(object sender, RenderingEventArgs eventArgs)
 {
 }
Пример #13
0
 private void Tick(Object source, RenderingEventArgs e)
 {
     DateTime time = DateTime.Now;
     double tick = (time - lastTick_).TotalMilliseconds;
     if (running_)
     {
         TimeSpan elapsed = time - startPoint_;
         TimeSpan total = endPoint_ - startPoint_;
         if (this.WindowState == WindowState.Minimized)
             DrawIcon(elapsed.TotalMilliseconds, total.TotalMilliseconds, !working_, cycle_);
         else
         {
             if (elapsed.TotalMilliseconds >= nextSecond_)
             {
                 nextSecond_ += 1000.0;
                 ArcTo(nextSecond_ / (endPoint_ - startPoint_).TotalMilliseconds);
             }
             DrawCurrentClock();
         }
         // Tell the main thread to update the arc soonish.
         if (time >= endPoint_)
         {
             if (settings_.Sound)
             {
                 if (settings_.PauseMusic)
                     MediaControl.Pause();
                 resumePlay_ = time + new TimeSpan(0, 0, 0, 0, 500);
                 mediaPlayer_.Play();
                 mediaPlayer_.Position = new TimeSpan(0);
             }
             minimise_.ShowBaloon("Time's up!");
             this.NextCycle(endPoint_);
         }
         if (time >= resumePlay_)
         {
             if (settings_.PauseMusic)
                 MediaControl.Play();
             resumePlay_ = DateTime.MaxValue;
         }
     }
     else
     {
         Text_Cycle.Content = "(Paused)";
     }
     if (!working_ && currentPlugin_ != null)
     {
         if (currentPlugin_.Update(tick) || windowDirty_)
             currentPlugin_.Render(Canvas_Clock);
     }
     clockParent_.Children.Clear();
     customRenders_.Tick(clockParent_.Children, tick);
     lastTick_ = time;
     windowDirty_ = false;
 }
Пример #14
0
        void CompositionTargetEx_FrameUpdating(object sender, RenderingEventArgs e)
        {
            if(update)
             {
            _frameCounterUpdate++;
            update = false;

            #region -- add image --
            for(int x = 0; x < TilesSize.Width; x++)
            {
               for(int y = 0; y < TilesSize.Height; y++)
               {
                  var rawTile = new RawTile(MapType.GoogleHybrid, new GMap.NET.Point(x, y), ZoomStep);
                  var rectTilePx = new Rect(x*Projection.TileSize.Width, y*Projection.TileSize.Height, Projection.TileSize.Width, Projection.TileSize.Height);

                  TileVisual image = null;
                  if(!images.TryGetValue(rawTile, out image))
                  {
                     var layers = GMaps.Instance.GetAllLayersOfType(rawTile.Type);

                     ImageSource[] imgs = new ImageSource[layers.Length];

                     // get tiles
                     for(int i = 0; i < layers.Length; i++)
                     {
                        Exception ex;
                        var res = GMaps.Instance.GetImageFrom(layers[i], rawTile.Pos, rawTile.Zoom, out ex) as WindowsPresentationImage;
                        if(res != null)
                        {
                           imgs[i] = res.Img;
                        }
                     }

                     // combine visual
                     image = new TileVisual(imgs, rawTile);
                     images.Add(rawTile, image);

                     Canvas.SetZIndex(image, -1);
                  }

                  bool ri = (region.IntersectsWith(new GMap.NET.Rectangle((int) (rectTilePx.X + renderOffset.X), (int) (rectTilePx.Y + renderOffset.Y), (int) rectTilePx.Width, (int) rectTilePx.Height)));
                  if(TilesLayer.Children.Contains(image))
                  {
                     if(ri)
                     {
                        image.MoveTo(Math.Round(rectTilePx.X) + 0.6 + renderOffset.X, Math.Round(rectTilePx.Y) + 0.6 + renderOffset.Y);
                     }
                     else
                     {
                        TilesLayer.Children.Remove(image);
                     }
                  }
                  else
                  {
                     if(ri)
                     {
                        image.MoveTo(Math.Round(rectTilePx.X) + 0.6 + renderOffset.X, Math.Round(rectTilePx.Y) + 0.6 + renderOffset.Y);
                        BeginAnimateOpacity(image);
                        {
                           TilesLayer.Children.Add(image);
                        }
                     }
                  }
                  //break;
               }
               //break;
            }

            count = TilesLayer.Children.Count;

            #endregion
             }

             if(_stopwatch.ElapsedMilliseconds >= 1000)
             {
            _stopwatch.Stop();

            perfInfo.Text = "FPS: " + (ushort) (_frameCounter/_stopwatch.Elapsed.TotalSeconds) + " | " + (ushort) (_frameCounterUpdate/_stopwatch.Elapsed.TotalSeconds) + " | " + count + " tiles";

            _frameCounter = 0;
            _frameCounterUpdate = 0;
            _stopwatch.Reset();
            _stopwatch.Start();
             }
             else
             {
            _frameCounter++;
             }
        }
Пример #15
0
 /// <summary>
 /// Called when the composition target rendering event is raised.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="RenderingEventArgs"/> instance containing the event data.</param>
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     // TODO: Find a better way to handle this...
     if (this.IsEnabled)
     {
         this.ApplyCuttingGeometries();
     }
 }
 /// <summary>
 /// Handles the CompositionTarget.Rendering event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The <see cref="System.Windows.Media.RenderingEventArgs"/> instance containing the event data.</param>
 protected abstract void OnCompositionTargetRendering(object sender, RenderingEventArgs eventArgs);
Пример #17
0
        /// <summary>
        /// The rendering event handler.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            var ticks = e.RenderingTime.Ticks;
            double time = 100e-9 * (ticks - this.lastTick);

            if (this.lastTick != 0)
            {
                this.OnTimeStep(time);
            }

            this.lastTick = ticks;
        }
Пример #18
0
        /// <summary>
        /// The composition target_ rendering.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            if (this.isRendering)
            {
                if (!Visual3DHelper.IsAttachedToViewport3D(this))
                {
                    return;
                }

                if (this.UpdateTransforms())
                {
                    this.UpdateClipping();
                    this.UpdateGeometry();
                }
            }
        }
Пример #19
0
 /// <summary>
 /// Handles the CompositionTarget.Rendering event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The <see cref="System.Windows.Media.RenderingEventArgs"/> instance containing the event data.</param>
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs eventArgs)
 {
     // TODO: get rid of this?
     this.HandleStackedManipulationEvents();
 }