Beispiel #1
0
 public void DevDepReacquireAll(RenderTarget target)
 {
     VizRes.DevDepReacquireAll(target);
 }
Beispiel #2
0
        public void D3DRender(bool updated)
        {
#if (MARKERS)
            var span = Markers.EnterSpan($"{nameof(RC2)} render");
#endif

            Song song = Global.Instance.Song;

            if (resizeNeeded)
            {
                resizeNeeded = false;

                target.Resize(new Size2(Global.Instance.Width, Global.Instance.Height));

                if (song != null)
                {
                    song.DevDepReacquireAll(target);
                    song.ResetPoints();
                }
            }

            target.BeginDraw();
            target.Clear(SharpDX.Color.Black);

            if (initialized)
            {
                if (true) //Global.Instance.Updated)
                {
                    if (song != null)
                    {
                        if (!song.IsDevDepResourcesAcquired)
                        {
                            VizRes.DevDepAcquireAll(target);
                            song.IsDevDepResourcesAcquired = true;
                        }

                        if (song.PlayerMode == PlayerMode.playing)
                        {
                            if (song.Position < song.TrackPx)
                            {
                                song.Position = Math.Min(song.Position + 2, song.TrackPx - 1);
                            }
                            else
                            {
                                song.Position   = 0;
                                song.PlayerMode = PlayerMode.stopped;
                            }
                        }

                        var half = target.PixelSize.Width / 2;
                        if (song.Position < half)
                        {
                            song.LFT = 0;
                        }
                        else if (song.Position > song.TrackPx - half)
                        {
                            song.LFT = song.TrackPx - target.PixelSize.Width;
                        }
                        else
                        {
                            song.LFT = song.Position - half;
                        }

                        song.RIT = song.LFT + target.PixelSize.Width;

                        target.Transform = Matrix3x2.Translation(-song.LFT, 0);

                        bool moving = ((song.LFT != prevLFT) || (song.RIT != prevRIT));
                        if (moving)
                        {
                            prevLFT = song.LFT;
                            prevRIT = song.RIT;
                        }

                        DrawData dd = new DrawData()
                        {
                            target = target,
                            Song   = song,
                            Height = target.PixelSize.Height - Global.Slider_Height,
                            Width  = target.PixelSize.Width,
                            LFT    = prevLFT,
                            RIT    = prevRIT,
                            Offset = song.Position
                        };

                        if (moving)
                        {
                            foreach (var viz in song.Vizs)
                            {
                                viz.DrawMove(dd);
                            }
                        }

                        foreach (var viz in song.Vizs)
                        {
                            if (viz is Slider || viz is Rule || (viz.StartPoint.X < prevRIT && viz.EndPoint.X > prevLFT))
                            {
                                viz.Draw(dd);
                            }
                        }

                        foreach (Viz viz in song.Vizs)
                        {
                            if (viz.StartPoint.X < prevRIT && viz.EndPoint.X > prevLFT)
                            {
                                if ((viz.IsSelectable) && (song.Selected.Contains(viz)))
                                {
                                    viz.DrawSelect(dd, viz == song.Selected[0]);
                                }
                            }
                        }

                        if ((CurrOver != null) && (CurrOver.HasHilites))
                        {
                            CurrOver.DrawHilites(dd);
                        }

                        //if (song.Drag.DragMode == DragMode.Active)
                        //{
                        //    target.DrawRectangle(Pens.AliceBlue, Math.Min(dragBegin.X, dragEnd.X), Math.Min(dragBegin.Y, dragEnd.Y), Math.Abs(dragBegin.X - dragEnd.X), Math.Abs(dragBegin.Y - dragEnd.Y));
                        //}
                    }
                }
            }

            if (mouseOver)
            {
                using (var brush = new SolidColorBrush(target, Color.LightGoldenrodYellow))
                {
                    target.DrawEllipse(new Ellipse(new Vector2(mousex, mousey), 2, 2), brush);
                }
            }

            //end drawing
            target.EndDraw();

#if (MARKERS)
            span.Leave();
#endif

            fpsCounter.Update();

#if (MARKERS)
            span = Markers.EnterSpan($"{nameof(RC2)} progress");
#endif

            string text = $"FPS:{fpsCounter.FPS}:{Global.Instance.RealTime}  Updates:{updateds} W/H:{ClientSize.Width}/{ClientSize.Height} MO:{mouseOver}";
            tsLbl4Prog.Report(text);

            string time = string.Empty;
            if ((song != null) && (prevPosition != (song.Position / (Global.pxpersec / 10))))
            {
                prevPosition = song.Position / (Global.pxpersec / 10);
                time         = $"{(prevPosition / 600):00}:{(prevPosition / 10 % 60):00}.{(prevPosition % 10):0}";
                tsppTimeProg.Report(time);
            }

#if (MARKERS)
            span.Leave();
#endif
        }