Little Tweaks

This commit is contained in:
Flamefire committed 2013-02-25 23:22:01 +01:00
1 parent 78870ae26d
commit d5cb43a09f
11 files changed
+87 -44

No files matched your search

+11 -2
View File
@@ -284,7 +284,10 @@ namespace Vocaluxe.Base
public static bool SaveConfig() public static bool SaveConfig()
{ {
XmlWriter writer = XmlWriter.Create(CSettings.sFileConfig, _settings); XmlWriter writer = null;
try
{
writer = XmlWriter.Create(CSettings.sFileConfig, _settings);
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("root"); writer.WriteStartElement("root");
@@ -545,9 +548,15 @@ namespace Vocaluxe.Base
// End of File // End of File
writer.WriteEndElement(); //end of root writer.WriteEndElement(); //end of root
writer.WriteEndDocument(); writer.WriteEndDocument();
writer.Flush(); writer.Flush();
writer.Close(); writer.Close();
}
catch (Exception)
{
writer = null;
return false;
}
writer = null;
return true; return true;
} }
+7 -17
View File
@@ -1439,9 +1439,9 @@ namespace Vocaluxe.Base
if (File.Exists(ImagePath)) if (File.Exists(ImagePath))
{ {
SQLiteConnection connection = new SQLiteConnection(); using (SQLiteConnection connection = new SQLiteConnection())
{
connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath;
SQLiteCommand command;
try try
{ {
connection.Open(); connection.Open();
@@ -1450,12 +1450,8 @@ namespace Vocaluxe.Base
{ {
return false; return false;
} }
command = new SQLiteCommand(connection); using (SQLiteCommand command = new SQLiteCommand(connection))
{
SQLiteDataReader reader = null;
if (reader != null)
reader.Close();
Bitmap origin; Bitmap origin;
try try
@@ -1467,14 +1463,7 @@ namespace Vocaluxe.Base
CLog.LogError("Error loading Texture: " + ImagePath); CLog.LogError("Error loading Texture: " + ImagePath);
tex = new STexture(-1); tex = new STexture(-1);
if (reader != null)
{
reader.Close();
reader.Dispose();
}
command.Dispose();
connection.Close(); connection.Close();
connection.Dispose();
return false; return false;
} }
@@ -1486,7 +1475,6 @@ namespace Vocaluxe.Base
Graphics g = Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
g.DrawImage(origin, new Rectangle(0, 0, w, h)); g.DrawImage(origin, new Rectangle(0, 0, w, h));
g.Dispose(); g.Dispose();
if (origin != null)
origin.Dispose(); origin.Dispose();
tex = CDraw.AddTexture(bmp); tex = CDraw.AddTexture(bmp);
byte[] data = new byte[w * h * 4]; byte[] data = new byte[w * h * 4];
@@ -1503,7 +1491,7 @@ namespace Vocaluxe.Base
command.CommandText = "SELECT id FROM Images WHERE [Path] = @path"; command.CommandText = "SELECT id FROM Images WHERE [Path] = @path";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = Path.GetFileName(ImagePath); command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = Path.GetFileName(ImagePath);
reader = null; SQLiteDataReader reader = null;
try try
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
@@ -1525,6 +1513,8 @@ namespace Vocaluxe.Base
result = true; result = true;
} }
} }
}
}
return result; return result;
} }
+12 -2
View File
@@ -135,11 +135,11 @@ namespace Vocaluxe.Base
} }
} }
class CFont class CFont:IDisposable
{ {
private List<CGlyph> _Glyphs; private List<CGlyph> _Glyphs;
private Hashtable _htGlyphs; private Hashtable _htGlyphs;
private PrivateFontCollection fonts; private PrivateFontCollection fonts = null;
private FontFamily family; private FontFamily family;
private float SIZEh; private float SIZEh;
@@ -268,6 +268,16 @@ namespace Vocaluxe.Base
} }
_Glyphs.Clear(); _Glyphs.Clear();
} }
public void Dispose()
{
if (fonts != null)
{
fonts.Dispose();
fonts = null;
}
GC.SuppressFinalize(this);
}
} }
struct SFont struct SFont
+12 -2
View File
@@ -6,11 +6,11 @@ using System.Text;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
class Log class Log:IDisposable
{ {
private string _LogFileName; private string _LogFileName;
private string _LogName; private string _LogName;
private StreamWriter _LogFile; private StreamWriter _LogFile = null;
public Log(string FileName, string LogName) public Log(string FileName, string LogName)
{ {
@@ -56,6 +56,16 @@ namespace Vocaluxe.Base
_LogFile.WriteLine("----------------------------------------"); _LogFile.WriteLine("----------------------------------------");
_LogFile.WriteLine(); _LogFile.WriteLine();
} }
public void Dispose()
{
if (_LogFile != null)
{
_LogFile.Dispose();
_LogFile = null;
}
GC.SuppressFinalize(this);
}
} }
static class CLog static class CLog
+1 -13
View File
@@ -605,23 +605,11 @@ namespace Vocaluxe.Base
public CSong GetVisibleSong(int VisibleIndex) public CSong GetVisibleSong(int VisibleIndex)
{ {
if (VisibleIndex >= CSongs.NumVisibleSongs) return CSongs.GetVisibleSongByIndex(VisibleIndex);
return null;
CSong song = CSongs.VisibleSongs[VisibleIndex];
//Flamefire: Why copy the song-instance??? Cover and stuff will be loaded twice!
//And for unknown reason causes no-big-cover bug if covers are not loaded on startup
return song;
//if (song == null)
// return null;
//return new CSong(song);
} }
public CSong GetSongByID(int SongID) public CSong GetSongByID(int SongID)
{ {
//Flamefire: Why copy?
//return new CSong(CSongs.GetSong(SongID));
return CSongs.GetSong(SongID); return CSongs.GetSong(SongID);
} }
+17
View File
@@ -381,6 +381,23 @@ namespace Vocaluxe.Base
get { return _Categories.ToArray(); } get { return _Categories.ToArray(); }
} }
public static CSong GetVisibleSongByIndex(int index)
{
if (index < 0)
return null;
foreach (SongPointer sp in _SongsSortList)
{
if (sp.Visible)
{
if (index == 0)
return _Songs[sp.SongID];
index--;
}
}
return null;
}
private static void _FilterSongs(String SearchFilter, bool ShowDuetSongs) private static void _FilterSongs(String SearchFilter, bool ShowDuetSongs)
{ {
if (_Init && _SearchFilter == SearchFilter && _ShowDuetSongs == ShowDuetSongs) if (_Init && _SearchFilter == SearchFilter && _ShowDuetSongs == ShowDuetSongs)
+12 -2
View File
@@ -300,7 +300,7 @@ namespace Vocaluxe.Base
#endregion Record #endregion Record
} }
class CBuffer class CBuffer : IDisposable
{ {
private const double _BaseToneFreq = 65.4064; private const double _BaseToneFreq = 65.4064;
private const int _NumHalfTones = 47; private const int _NumHalfTones = 47;
@@ -315,7 +315,7 @@ namespace Vocaluxe.Base
private double _MaxVolume = 0.0; private double _MaxVolume = 0.0;
private bool _NewSamples; private bool _NewSamples;
private MemoryStream _Stream; // full buffer private MemoryStream _Stream = null; // full buffer
public CBuffer() public CBuffer()
{ {
@@ -554,6 +554,16 @@ namespace Vocaluxe.Base
return 1 - AccumDist / _AnalysisBuffer.Length; return 1 - AccumDist / _AnalysisBuffer.Length;
} }
public void Dispose()
{
if (_Stream != null)
{
_Stream.Dispose();
_Stream = null;
}
GC.SuppressFinalize(this);
}
} }
class CSyncTimer class CSyncTimer
+1 -3
View File
@@ -1,6 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Menu; using Vocaluxe.Menu;
+12 -2
View File
@@ -11,9 +11,9 @@ using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Input.WiiMote namespace Vocaluxe.Lib.Input.WiiMote
{ {
class CWiiMote : IInput class CWiiMote : IInput, IDisposable
{ {
WiiMoteLib _WiiMote; WiiMoteLib _WiiMote = null;
private List<KeyEvent> _KeysPool; private List<KeyEvent> _KeysPool;
private List<KeyEvent> _CurrentKeysPool; private List<KeyEvent> _CurrentKeysPool;
@@ -324,5 +324,15 @@ namespace Vocaluxe.Lib.Input.WiiMote
_MousePool.Clear(); _MousePool.Clear();
} }
} }
public void Dispose()
{
if (_WiiMote != null)
{
_WiiMote.Dispose();
_WiiMote = null;
}
GC.SuppressFinalize(this);
}
} }
} }
+1 -1
View File
@@ -104,7 +104,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
public struct TAc_decoder public struct TAc_decoder
{ {
//Pointer on the Acinerella instance //Pointer on the Acinerella instance
public IntPtr pAcInstance; private IntPtr pAcInstance;
//Contains the type of the decoder. //Contains the type of the decoder.
public TAc_decoder_type dec_type; public TAc_decoder_type dec_type;
+1
View File
@@ -229,6 +229,7 @@
<Compile Include="Program.cs"> <Compile Include="Program.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Screens\CPopupScreenPlayerControl.cs" /> <Compile Include="Screens\CPopupScreenPlayerControl.cs" />
<Compile Include="Screens\CPopupScreenVolumeControl.cs" /> <Compile Include="Screens\CPopupScreenVolumeControl.cs" />
<Compile Include="Screens\CScreenCredits.cs" /> <Compile Include="Screens\CScreenCredits.cs" />