示例#1
0
        private static RectangleF GetSourceRect(D2DImageStrip imageStrip, int index)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            float x, y, w, h;

            switch (imageStrip.Orientation)
            {
            case ImageStripOrientation.Horizontal:
                w = imageStrip.UnitWidth;
                h = imageStrip.UnitHeight;
                x = index * w;
                y = 0;
                break;

            case ImageStripOrientation.Vertical:
                w = imageStrip.UnitWidth;
                h = imageStrip.UnitHeight;
                x = 0;
                y = index * h;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(new RectangleF(x, y, w, h));
        }
示例#2
0
        protected override void OnGotContext(RenderContext context)
        {
            base.OnGotContext(context);

            var settings     = Program.Settings;
            var theaterDays  = Game.AsTheaterDays();
            var debugOverlay = theaterDays.FindSingleElement <DebugOverlay>();

            var gamingArea = theaterDays.FindSingleElement <GamingArea>();

            if (gamingArea == null)
            {
                throw new InvalidOperationException();
            }

            if (settings.Images.Notes == null || settings.Images.Notes.Length == 0)
            {
                if (debugOverlay != null)
                {
                    debugOverlay.AddLine("WARNING: default notes image strip is not specified.");
                }
            }
            else
            {
                _noteImages = new D2DImageStrip[settings.Images.Notes.Length];

                for (var i = 0; i < settings.Images.Notes.Length; ++i)
                {
                    var notesImageEntry = settings.Images.Notes[i];
                    if (notesImageEntry == null)
                    {
                        continue;
                    }

                    if (notesImageEntry.File == null || !File.Exists(notesImageEntry.File))
                    {
                        if (i == 0)
                        {
                            if (debugOverlay != null)
                            {
                                debugOverlay.AddLine($"WARNING: default notes image strip <{notesImageEntry.File ?? string.Empty}> is not found.");
                            }
                        }
                        else
                        {
                            if (debugOverlay != null)
                            {
                                debugOverlay.AddLine($"WARNING: notes image strip <{notesImageEntry.File ?? string.Empty}> is not found, falling back to default.");
                            }
                        }
                        continue;
                    }

                    var imageStrip = Direct2DHelper.LoadImageStrip(context, notesImageEntry.File, notesImageEntry.Count, notesImageEntry.Orientation);
                    _noteImages[i] = imageStrip;
                }
            }

            _tapPointImage = Direct2DHelper.LoadBitmap(context, settings.Images.TapPoint.FileName);
        }
示例#3
0
        public static void DrawImageStripUnit(this RenderContext context, D2DImageStrip imageStrip, int index, float destX, float destY, float destWidth, float destHeight, float opacity)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, null);
            }
            var srcRect = GetSourceRect(imageStrip, index);

            context.DrawBitmap(imageStrip, destX, destY, destWidth, destHeight, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, opacity);
        }
示例#4
0
        public static void DrawImageStripUnit(this RenderContext context, D2DImageStrip imageStrip, int index, float destX, float destY, InterpolationMode interpolationMode, CompositeMode compositeMode)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, null);
            }
            var srcRect = GetSourceRect(imageStrip, index);

            context.DrawImage(imageStrip, destX, destY, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, interpolationMode, compositeMode);
        }
示例#5
0
        public static void DrawImageStripUnit(this RenderContext context, D2DImageStrip imageStrip, int index, float destX, float destY, float destFullWidth, float destFullHeight, float blankLeft, float blankTop, float blankRight, float blankBottom)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, null);
            }
            var blankEdge = RectangleF.FromLTRB(blankLeft, blankTop, blankRight, blankBottom);
            var srcRect   = GetSourceRect(imageStrip, index, blankEdge);

            context.DrawBitmap(imageStrip, destX, destY, destFullWidth, destFullHeight, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height);
        }
示例#6
0
        private static RectangleF GetSourceRect(D2DImageStrip imageStrip, int index, RectangleF blankEdge)
        {
            var rect = GetSourceRect(imageStrip, index);

            return(new RectangleF(rect.Left + blankEdge.Left, rect.Top + blankEdge.Top, rect.Width - (blankEdge.Left + blankEdge.Right), rect.Height - (blankEdge.Top + blankEdge.Bottom)));
        }