示例#1
0
        public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false)
        {
            CTextureRef texture = Texture;
            SRectF      bounds  = Rect.Scale(scale);

            bounds.Z += zModify;
            SRectF rect  = texture == null ? bounds : CHelper.FitInBounds(bounds, texture.OrigAspect, aspect);
            var    color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);

            if (Visible || forceDraw || (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
            {
                if (texture != null)
                {
                    CBase.Drawing.DrawTexture(texture, rect, color, bounds);
                    if (Reflection)
                    {
                        CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight);
                    }
                }
                else
                {
                    CBase.Drawing.DrawRect(color, rect);
                }
            }

            if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
            {
                CBase.Drawing.DrawRect(new SColorF(1f, 1f, 1f, 0.5f), rect);
            }
        }
示例#2
0
        private void _DrawNote(SRectF rect, SColorF color, CTextureRef noteBegin, CTextureRef noteMiddle, CTextureRef noteEnd, float factor)
        {
            if (factor <= 0 || rect.X > Rect.X + Rect.W || rect.X + rect.W < Rect.X)
            {
                return;
            }

            //Width-related variables rounded and then floored to prevent 1px gaps in notes
            rect.X = (float)Math.Round(rect.X);
            rect.W = (float)Math.Round(rect.W);

            int dh = (int)((1f - factor) * rect.H / 2);
            int dw = (int)Math.Min(dh, rect.W / 2);

            var noteRect     = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z);
            var noteBoundary = noteRect;

            if (noteBoundary.X < Rect.X)
            {
                noteBoundary.X  = Rect.X;
                noteBoundary.W -= Rect.X - noteBoundary.X;
            }
            if (noteBoundary.X + noteBoundary.W > Rect.X + Rect.W)
            {
                noteBoundary.W -= (noteBoundary.X + noteBoundary.W) - (Rect.X + Rect.W);
            }

            //Width of each of the ends (round parts)
            //Need 2 of them so use minimum
            int endsW = (int)Math.Min(noteRect.H * noteBegin.OrigAspect, noteRect.W / 2);

            CBase.Drawing.DrawTexture(noteBegin, new SRectF(noteRect.X, noteRect.Y, endsW, noteRect.H, noteRect.Z), color, noteBoundary, false, false);

            SRectF middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z);

            int midW = (int)Math.Round(noteRect.H * noteMiddle.OrigAspect);

            int midCount = (int)middleRect.W / midW;

            for (int i = 0; i < midCount; ++i)
            {
                CBase.Drawing.DrawTexture(noteMiddle, new SRectF(middleRect.X + (i * midW), noteRect.Y, midW, noteRect.H, noteRect.Z), color, noteBoundary, false, false);
            }

            SRectF lastMidRect = new SRectF(middleRect.X + midCount * midW, noteRect.Y, middleRect.W - (midCount * midW), noteRect.H, noteRect.Z);

            if (lastMidRect.X + lastMidRect.W > Rect.X + Rect.W)
            {
                lastMidRect.W -= (lastMidRect.X + lastMidRect.W) - (Rect.X + Rect.W);
            }
            else if (lastMidRect.X < Rect.X)
            {
                lastMidRect.X  = Rect.X;
                lastMidRect.W -= Rect.X - lastMidRect.X;
            }

            CBase.Drawing.DrawTexture(noteMiddle, new SRectF(middleRect.X + (midCount * midW), middleRect.Y, midW, middleRect.H, middleRect.Z), color, lastMidRect, false, false);

            CBase.Drawing.DrawTexture(noteEnd, new SRectF(noteRect.X + noteRect.W - endsW, noteRect.Y, endsW, noteRect.H, noteRect.Z), color, noteBoundary, false, false);
        }
示例#3
0
 public CTextureRef CopyTexture(CTextureRef textureRef)
 {
     // Lock to make sure the texture is not disposed while we are in this method
     lock (_Textures)
     {
         TTextureType texture;
         if (!_GetTexture(textureRef, out texture, false))
         {
             return(null);
         }
         // If bitmap is not yet loaded, wait for it
         if (!String.IsNullOrEmpty(texture.TexturePath))
         {
             Task <Size> loader;
             lock (_BitmapsLoading)
             {
                 _BitmapsLoading.TryGetValue(texture.TexturePath, out loader);
             }
             if (loader != null)
             {
                 textureRef.OrigSize = loader.Result;
             }
         }
         Debug.Assert(textureRef.OrigSize.Width > 0);
         return(_GetTextureReference(textureRef.OrigSize, texture));
     }
 }
示例#4
0
 /// <summary>
 ///     Removes a texture from the Vram
 /// </summary>
 /// <param name="textureRef">The texture to be removed</param>
 public void RemoveTexture(ref CTextureRef textureRef)
 {
     if (textureRef == null)
     {
         return;
     }
     if (textureRef.ID > 0)
     {
         if (_MainThreadID != Thread.CurrentThread.ManagedThreadId)
         {
             lock (_TextureQueue)
             {
                 _TextureQueue.Enqueue(new STextureQueue(textureRef, EQueueAction.Delete, null));
             }
             textureRef = null;
             return;
         }
         lock (_Textures)
         {
             TTextureType t;
             if (_Textures.TryGetValue(textureRef.ID, out t))
             {
                 _DisposeTexture(t);
                 _Textures.Remove(textureRef.ID);
             }
             textureRef.SetRemoved();
         }
     }
     textureRef = null;
 }
示例#5
0
        /// <summary>
        ///     Draws a reflection of a texture
        /// </summary>
        /// <param name="textureRef">The texture of which a reflection should be drawn</param>
        /// <param name="rect">A SRectF struct containing the destination coordinates</param>
        /// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
        /// <param name="bounds">A SRectF struct containing which part of the texture should be drawn</param>
        /// <param name="space">The space between the texture and the reflection</param>
        /// <param name="height">The height of the reflection</param>
        public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
        {
            Debug.Assert(height >= 0);

            if (Math.Abs(color.A) < 0.01 || height < 1)
            {
                return;
            }
            SDrawCoords  dc;
            TTextureType texture;

            if (!_GetTexture(textureRef, out texture))
            {
                return;
            }
            if (!_CalcDrawCoords(texture, rect, bounds, out dc, true))
            {
                return;
            }

            if (height > rect.H)
            {
                height = rect.H;
            }

            dc.Wy1 += rect.H + space;             // Move from start of rect to end of rect with spacing
            dc.Wy2 += space + height;             // Move from end of rect
            dc.Ty2 += (rect.H - height) / rect.H; // Adjust so not all of the start of the texture is drawn (mirrored--> Ty1>Ty2)
            if (dc.Ty2 < dc.Ty1)                  // Make sure we actually draw something
            {
                _DrawTexture(texture, dc, color, true);
            }
        }
示例#6
0
        private void _DrawNote(SRectF rect, SColorF color, float factor)
        {
            if (factor <= 0)
            {
                return;
            }

            float dh = (1f - factor) * rect.H / 2;
            float dw = Math.Min(dh, rect.W / 2);

            var noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z);

            CTextureRef noteBegin  = CBase.Themes.GetSkinTexture(_Theme.SkinLeft, _PartyModeID);
            CTextureRef noteMiddle = CBase.Themes.GetSkinTexture(_Theme.SkinMiddle, _PartyModeID);
            CTextureRef noteEnd    = CBase.Themes.GetSkinTexture(_Theme.SkinRight, _PartyModeID);

            //Width of each of the ends (round parts)
            //Need 2 of them so use minimum
            float endsW = Math.Min(noteRect.H * noteBegin.OrigAspect, noteRect.W / 2);

            CBase.Drawing.DrawTexture(noteBegin, new SRectF(noteRect.X, noteRect.Y, endsW, noteRect.H, noteRect.Z), color);

            var middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z);

            if (noteRect.W >= 4 * endsW)
            {
                CBase.Drawing.DrawTexture(noteMiddle, middleRect, color);
            }
            else
            {
                CBase.Drawing.DrawTexture(noteMiddle, new SRectF(middleRect.X, middleRect.Y, 2 * endsW, middleRect.H, middleRect.Z), color, middleRect);
            }

            CBase.Drawing.DrawTexture(noteEnd, new SRectF(noteRect.X + noteRect.W - endsW, noteRect.Y, endsW, noteRect.H, noteRect.Z), color);
        }
示例#7
0
        public void DrawTexture(CTextureRef textureRef, SRectF rect, SColorF color, bool mirrored = false, bool allMonitors = true)
        {
            if (Math.Abs(color.A) < 0.01)
            {
                return;
            }
            SDrawCoords  dc;
            TTextureType texture;

            if (!_GetTexture(textureRef, out texture))
            {
                return;
            }
            if (allMonitors)
            {
                for (int i = 0; i < CConfig.Config.Graphics.NumScreens; i++)
                {
                    SRectF newrect = rect;
                    newrect.X += CSettings.RenderW * i;
                    if (!_CalcDrawCoords(texture, newrect, out dc, mirrored))
                    {
                        return;
                    }
                    _DrawTexture(texture, dc, color);
                }
            }
            else
            {
                if (!_CalcDrawCoords(texture, rect, out dc, mirrored))
                {
                    return;
                }
                _DrawTexture(texture, dc, color);
            }
        }
示例#8
0
        public bool Reload()
        {
            Unload();
            _Texture = CBase.Drawing.AddTexture(_FileName);

            return(_Texture != null);
        }
示例#9
0
        private bool _DrawSlideShow()
        {
            if (_SlideShowTextures.Count > 0)
            {
                if (!_SlideShowTimer.IsRunning)
                {
                    _SlideShowTimer.Start();
                    _SlideShowCurrent = 0;
                }

                if (_SlideShowTimer.ElapsedMilliseconds >= (CBase.Settings.GetSlideShowFadeTime() + CBase.Settings.GetSlideShowImageTime()))
                {
                    _SlideShowTimer.Restart();
                    if (_SlideShowCurrent + 1 < _SlideShowTextures.Count)
                    {
                        _SlideShowCurrent++;
                    }
                    else
                    {
                        _SlideShowCurrent = 0;
                    }
                }

                CTextureRef texture = _SlideShowTextures[_SlideShowCurrent];

                if (texture == null)
                {
                    return(false);
                }

                CBase.Drawing.DrawTexture(texture, Rect, EAspect.Crop);

                if (_SlideShowTimer.ElapsedMilliseconds >= CBase.Settings.GetSlideShowImageTime())
                {
                    if (_SlideShowCurrent + 1 < _SlideShowTextures.Count)
                    {
                        texture = _SlideShowTextures[_SlideShowCurrent + 1];
                    }
                    else if (_SlideShowCurrent != 0)
                    {
                        texture = _SlideShowTextures[0];
                    }
                    else
                    {
                        texture = null;
                    }

                    if (texture != null)
                    {
                        SColorF color = texture.Color;
                        color.A = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
                        CBase.Drawing.DrawTexture(texture, Rect, EAspect.Crop, color);
                    }
                }

                return(true);
            }
            return(false);
        }
示例#10
0
        private void _InitTiles()
        {
            MaxRect = _Theme.SongMenuDetails.TileAreaRect;

            _ListTextWidth = MaxRect.W - _ListTextWidth;

            _CoverBGTexture    = CBase.Themes.GetSkinTexture(_Theme.CoverBackground, _PartyModeID);
            _VideoBGBGTexture  = CBase.Themes.GetSkinTexture(_Theme.CoverBigBackground, _PartyModeID);
            _BigCoverBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBigBackground, _PartyModeID);
            _TileBGTexture     = CBase.Themes.GetSkinTexture(_Theme.TileBackground, _PartyModeID);

            //Create cover tiles
            _Covers  = new List <CStatic>();
            _Tiles   = new List <CStatic>();
            _Artists = new List <CText>();
            _Titles  = new List <CText>();

            _ListLength = (int)(MaxRect.H / (_Tile.H + (_TileSpacing / 2)));
            _TileCoverH = _Tile.H;
            _TileCoverW = _TileCoverH;

            float TileTextWidth        = _Tile.W - _TileCoverW - (_TileTextIndent * 2);
            float TileTextArtistHeight = 22;
            float TileTextTitleHeight  = 24;

            for (int i = 0; i < _ListLength; i++)
            {
                //Create Cover
                var rect  = new SRectF(Rect.X, Rect.Y + (i * (_TileCoverH + _TileSpacing)), _TileCoverW, _TileCoverH, Rect.Z);
                var cover = new CStatic(_PartyModeID, _CoverBGTexture, _Color, rect);
                _Covers.Add(cover);

                //Create Tile
                var BGrect = new SRectF(MaxRect.X, MaxRect.Y + i * (_Tile.H + _TileSpacing), MaxRect.W, _Tile.H, Rect.Z + 0.5f);
                var tilebg = new CStatic(_PartyModeID, _TileBGTexture, new SColorF(0, 0, 0, 0.6f), BGrect);
                _Tiles.Add(tilebg);

                //Create text
                var   artistRect = new SRectF(MaxRect.X + _TileCoverW + _TileTextIndent, Rect.Y + (_TileSpacing / 2) + i * (_Tile.H + _TileSpacing) + (_TileTextIndent / 2) + TileTextTitleHeight, TileTextWidth, TileTextArtistHeight, Rect.Z - 1);
                CText artist     = new CText(artistRect.X, artistRect.Y, artistRect.Z,
                                             artistRect.H, artistRect.W, EAlignment.Left, EStyle.Bold,
                                             "Outline", _Artist.Color, "");
                artist.MaxRect     = new SRectF(artist.MaxRect.X, artist.MaxRect.Y, MaxRect.W + MaxRect.X - artist.Rect.X - 5f, artist.MaxRect.H, artist.MaxRect.Z);
                artist.ResizeAlign = EHAlignment.Center;

                _Artists.Add(artist);

                var   titleRect = new SRectF(MaxRect.X + _TileCoverW + _TileTextIndent, (Rect.Y + (_TileSpacing / 2) + i * (_Tile.H + _TileSpacing)) + (_TileTextIndent / 2), TileTextWidth, TileTextTitleHeight, Rect.Z - 1);
                CText title     = new CText(titleRect.X, titleRect.Y, titleRect.Z,
                                            titleRect.H, titleRect.W, EAlignment.Left, EStyle.Normal,
                                            "Outline", _Artist.Color, "");
                title.MaxRect     = new SRectF(title.MaxRect.X, title.MaxRect.Y, MaxRect.W + MaxRect.X - title.Rect.X - 5f, title.MaxRect.H, title.MaxRect.Z);
                title.ResizeAlign = EHAlignment.Center;

                _Titles.Add(title);
            }

            _ScrollRect = MaxRect;
        }
示例#11
0
        private void _DrawNoteFill(SRectF rect, SColorF color, float factor)
        {
            CTextureRef noteBegin  = CBase.Themes.GetSkinTexture(_Theme.SkinFillLeft, _PartyModeID);
            CTextureRef noteMiddle = CBase.Themes.GetSkinTexture(_Theme.SkinFillMiddle, _PartyModeID);
            CTextureRef noteEnd    = CBase.Themes.GetSkinTexture(_Theme.SkinFillRight, _PartyModeID);

            _DrawNote(rect, color, noteBegin, noteMiddle, noteEnd, factor);
        }
示例#12
0
文件: CDraw.cs 项目: da-ka/Vocaluxe
 /// <summary>
 ///     Removes a texture from the VRAM and sets it to null to avoid accidential usage <br />
 ///     Note: You can also use its Dispose method to do the same as this gets automaticly called from the Dispose method and destructor of a texture reference
 /// </summary>
 /// <param name="texture"></param>
 public static void RemoveTexture(ref CTextureRef texture)
 {
     // Disposed textures call this, possibly at program end!
     if (_Draw != null)
     {
         _Draw.RemoveTexture(ref texture);
     }
 }
示例#13
0
        private void _GenerateQRs()
        {
            QRCodeGenerator qr = new QRCodeGenerator();

            //ServerAddress
            QRCodeGenerator.QRCode qrcode = qr.CreateQrCode(CVocaluxeServer.GetServerAddress(), QRCodeGenerator.ECCLevel.H);
            _QRServerAddress = CDraw.AddTexture(qrcode.GetGraphic(20));
        }
示例#14
0
        public CTextureRef EnqueueTexture(Bitmap bmp)
        {
            TTextureType texture    = _CreateTexture(new Size(-1, -1));
            CTextureRef  textureRef = _GetTextureReference(bmp.GetSize(), texture);

            _EnqueueTextureAddOrUpdate(texture, bmp, EQueueAction.Add, true);

            return(textureRef);
        }
示例#15
0
 public void RemoveSlideShowTextures()
 {
     foreach (CTextureRef tex in _SlideShowTextures)
     {
         CTextureRef texture = tex;
         CBase.Drawing.RemoveTexture(ref texture);
     }
     _SlideShowTextures.Clear();
 }
示例#16
0
 public CTextureRef EnqueueTexture(int w, int h, byte[] data)
 {
     lock (_TextureQueue)
     {
         TTextureType texture    = _CreateTexture(new Size(-1, -1));
         CTextureRef  textureRef = _GetTextureReference(w, h, texture);
         _TextureQueue.Enqueue(new STextureQueue(texture, EQueueAction.Add, new Size(w, h), data));
         return(textureRef);
     }
 }