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); } }
public override void Draw() { foreach (CStatic tile in _Tiles) { if (tile.Selected) { tile.Draw(EAspect.Crop, SelectedTileZoomFactor, -0.1f); } else { EAspect aspect = (tile.Texture != _CoverBGTexture) ? EAspect.Crop : EAspect.Stretch; tile.Draw(aspect); } } //highlight the text of the selected song int i = 0; foreach (CText text in _Texts) { if (i < _Tiles.Count && _Tiles[i].Selected) { text.Font.Style = EStyle.BoldItalic; } else if (i < _Tiles.Count) { text.Font.Style = EStyle.Normal; } else { text.Text = ""; } text.Draw(); i++; } _TextBG.Draw(); CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; if (vidtex != null) { if (vidtex.Color.A < 1) { _CoverBig.Draw(EAspect.Crop); } SRectF rect = CHelper.FitInBounds(_CoverBig.Rect, vidtex.OrigAspect, EAspect.Crop); CBase.Drawing.DrawTexture(vidtex, rect, vidtex.Color, _CoverBig.Rect); CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.Rect, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } else { _CoverBig.Draw(EAspect.Crop); } foreach (IMenuElement element in _SubElements) { element.Draw(); } }
public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false) { CTextureRef texture = Texture; SRectF bounds = Rect.Scale(scale); //Change bounds if rect size should be modified without adjusting texture if (ModH != -1) { bounds.H = ModH * scale; } if (ModW != -1) { bounds.W = ModW * scale; } bounds.Z += zModify; SRectF rect = texture == null ? bounds : CHelper.FitInBounds(bounds, texture.OrigAspect, aspect); //Use original rect if (ModH != -1 || ModW != -1) { rect = Rect.Scale(scale); } 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, false, AllMonitors); if (Reflection) { CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight, AllMonitors); } } else { CBase.Drawing.DrawRect(color, rect); } } if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme)) { CBase.Drawing.DrawRect(new SColorF(1f, 1f, 1f, 0.5f), rect); } }
public override void Draw() { foreach (CStatic tile in _Tiles) { if (tile.Selected) { tile.Draw(EAspect.Crop, SelectedTileZoomFactor, -0.1f); } else { EAspect aspect = (tile.Texture != _CoverBGTexture) ? EAspect.Crop : EAspect.Stretch; tile.Draw(aspect); } } _TextBG.Draw(); CTextureRef vidtex = null; if (CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON) { vidtex = (CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null); } if (vidtex != null) { if (vidtex.Color.A < 1) { _CoverBig.Draw(EAspect.Crop); } SRectF rect = CHelper.FitInBounds(_CoverBig.Rect, vidtex.OrigAspect, EAspect.Crop); CBase.Drawing.DrawTexture(vidtex, rect, vidtex.Color, _CoverBig.Rect); CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.Rect, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } else { _CoverBig.Draw(EAspect.Crop); } foreach (IMenuElement element in _SubElements) { element.Draw(); } }
private void _DrawVideoPreview() { CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; if (vidtex != null) { if (vidtex.Color.A < 1) { _VideoBG.Draw(EAspect.Crop); } SRectF rect = CHelper.FitInBounds(_VideoBG.Rect, vidtex.OrigAspect, EAspect.Crop); rect.Z = _VideoBG.Z; CBase.Drawing.DrawTexture(vidtex, rect, vidtex.Color, _VideoBG.Rect); CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _VideoBG.Rect, _VideoBG.ReflectionSpace, _VideoBG.ReflectionHeight); } else { _VideoBG.Draw(EAspect.Crop); } }
public bool GetCover(string coverPath, ref CTextureRef tex, int maxSize) { if (_Connection == null) { return(false); } if (!File.Exists(coverPath)) { CLog.LogError("Can't find File: " + coverPath); return(false); } lock (_Mutex) { //Double check here because we may have just closed our connection if (_Connection == null) { return(false); } using (var command = new SQLiteCommand(_Connection)) { command.CommandText = "SELECT id, width, height FROM Cover WHERE [Path] = @path"; command.Parameters.Add("@path", DbType.String).Value = coverPath; SQLiteDataReader reader = command.ExecuteReader(); if (reader != null && reader.HasRows) { reader.Read(); int id = reader.GetInt32(0); int w = reader.GetInt32(1); int h = reader.GetInt32(2); reader.Close(); command.CommandText = "SELECT Data FROM CoverData WHERE CoverID = @id"; command.Parameters.Add("@id", DbType.Int32).Value = id; reader = command.ExecuteReader(); if (reader.HasRows) { reader.Read(); byte[] data2 = _GetBytes(reader); reader.Dispose(); tex = CDraw.EnqueueTexture(w, h, data2); return(true); } command.CommandText = "DELETE FROM Cover WHERE id = @id"; command.Parameters.Add("@id", DbType.Int32).Value = id; command.ExecuteNonQuery(); } if (reader != null) { reader.Close(); } } } // At this point we do not have a mathing entry in the CoverDB (either no Data found and deleted or nothing at all) // We break out of the lock to do the bitmap loading and resizing here to allow multithreaded loading Bitmap origin = CHelper.LoadBitmap(coverPath); if (origin == null) { return(false); } Size size = origin.GetSize(); if (size.Width > maxSize || size.Height > maxSize) { size = CHelper.FitInBounds(new SRectF(0, 0, maxSize, maxSize, 0), (float)size.Width / size.Height, EAspect.LetterBox).SizeI; Bitmap tmp = origin.Resize(size); origin.Dispose(); origin = tmp; } byte[] data; try { data = new byte[size.Width * size.Height * 4]; BitmapData bmpData = origin.LockBits(origin.GetRect(), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Marshal.Copy(bmpData.Scan0, data, 0, data.Length); origin.UnlockBits(bmpData); } finally { origin.Dispose(); } tex = CDraw.EnqueueTexture(size.Width, size.Height, data); lock (_Mutex) { //Double check here because we may have just closed our connection if (_Connection == null) { return(false); } if (_TransactionCover == null) { _TransactionCover = _Connection.BeginTransaction(); } using (var command = new SQLiteCommand(_Connection)) { command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)"; command.Parameters.Add("@w", DbType.Int32).Value = size.Width; command.Parameters.Add("@h", DbType.Int32).Value = size.Height; command.Parameters.Add("@path", DbType.String).Value = coverPath; command.ExecuteNonQuery(); command.CommandText = "SELECT id FROM Cover WHERE [Path] = @path"; command.Parameters.Add("@path", DbType.String).Value = coverPath; SQLiteDataReader reader = command.ExecuteReader(); if (reader != null) { reader.Read(); int id = reader.GetInt32(0); reader.Dispose(); command.CommandText = "INSERT INTO CoverData (CoverID, Data) VALUES (@id, @data)"; command.Parameters.Add("@id", DbType.Int32).Value = id; command.Parameters.Add("@data", DbType.Binary).Value = data; command.ExecuteNonQuery(); return(true); } } } return(false); }