Fix code issues (naming, unused stuff)

This commit is contained in:
Flamefire committed 2014-03-12 09:41:34 +01:00
1 parent 424cb826ed
commit 898819fcf5
34 files changed
+128 -141

No files matched your search

+4 -4
View File
@@ -60,10 +60,10 @@ namespace Vocaluxe.Base
public static int ScreenW = 1024;
public static int ScreenH = 576;
public static int BorderLeft = 0;
public static int BorderRight = 0;
public static int BorderTop = 0;
public static int BorderBottom = 0;
public static int BorderLeft;
public static int BorderRight;
public static int BorderTop;
public static int BorderBottom;
public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0;
+9 -14
View File
@@ -208,7 +208,7 @@ namespace Vocaluxe.Base
public static void UpdatePoints(float time)
{
bool DEBUG_HIT = false;
const bool DEBUG_HIT = false;
CSong song = _SongQueue.GetSong();
@@ -274,8 +274,6 @@ namespace Vocaluxe.Base
{
int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p);
if (DEBUG_HIT)
tonePlayer = tone;
while (tonePlayer - tone > 6)
tonePlayer -= 12;
@@ -362,7 +360,7 @@ namespace Vocaluxe.Base
public static void ResetToLastLine(int soundStream, int vidStream)
{
float[] time = GetLastSungLineStart();
float[] time = _GetLastSungLineStart();
ResetToTime(time[0], time[1], soundStream, vidStream);
}
@@ -416,15 +414,15 @@ namespace Vocaluxe.Base
CVideo.Skip(vidStream, time, GetSong().VideoGap);
}
private static float[] GetLastSungLineStart()
private static float[] _GetLastSungLineStart()
{
return GetNoteTimeBeforeBeat(CurrentBeat);
return _GetNoteTimeBeforeBeat(CurrentBeat);
}
private static float[] GetNoteTimeBeforeBeat(int beat)
private static float[] _GetNoteTimeBeforeBeat(int beat)
{
CSong song = GetSong();
int StartBeat = (int)Math.Floor(beat - GetBeatFromTime(CSettings.PauseResetTime, song.BPM, 0f));
int startBeat = (int)Math.Floor(beat - GetBeatFromTime(CSettings.PauseResetTime, song.BPM, 0f));
int lastStart = 0;
int nextStart = 0;
foreach (CVoice voice in song.Notes.Voices)
@@ -436,16 +434,13 @@ namespace Vocaluxe.Base
{
foreach (CSongNote note in line.Notes)
{
if (note.StartBeat > StartBeat)
if (note.StartBeat > startBeat)
{
nextStartNote = note.StartBeat;
break;
}
else
{
voiceStart = note.StartBeat;
lastEnd = note.EndBeat;
}
voiceStart = note.StartBeat;
lastEnd = note.EndBeat;
}
if (nextStartNote > 0)
break;
-3
View File
@@ -404,9 +404,6 @@ namespace Vocaluxe.Base
CConfig.BorderTop = 0;
CConfig.BorderBottom = 0;
break;
default:
break;
}
CConfig.SaveConfig();
break;
+1 -1
View File
@@ -104,7 +104,7 @@ namespace Vocaluxe.Base
#endif
Path.Combine(DataPath, FolderProfiles)
};
public static string FolderPhotos = "Photos";
public const string FolderPhotos = "Photos";
public const string FolderSongs = "Songs";
public const string FolderSounds = "Sounds";
public const string FolderLanguages = "Languages";
+1 -3
View File
@@ -221,9 +221,7 @@ namespace Vocaluxe.Base
return;
//Calc avarage sing-count
int totalCounts = 0;
foreach (CSong song in VisibleSongs)
totalCounts += song.NumPlayedSession;
int totalCounts = VisibleSongs.Sum(song => song.NumPlayedSession);
int averageCount = totalCounts / NumSongsVisible;
foreach (CSong song in VisibleSongs)
-1
View File
@@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Vocaluxe.Base.Fonts;
+1 -2
View File
@@ -96,9 +96,8 @@ namespace Vocaluxe.Base.Server
var stream = new MemoryStream();
stream.Write(cmd, 0, cmd.Length);
byte[] data;
string json = JsonConvert.SerializeObject(obj);
data = _Encoder.GetBytes(json);
byte[] data = _Encoder.GetBytes(json);
stream.Write(data, 0, data.Length);
return stream.ToArray();
}
+7 -8
View File
@@ -26,7 +26,6 @@ using ServerLib;
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Playlist;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
using VocaluxeLib.Songs;
@@ -314,7 +313,7 @@ namespace Vocaluxe.Base.Server
#endregion
#region photo
private static List<string> photosOfThisRound = new List<string>();
private static readonly List<string> _PhotosOfThisRound = new List<string>();
private static bool _SendPhoto(SPhotoData photoData)
{
@@ -325,17 +324,17 @@ namespace Vocaluxe.Base.Server
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
if (!string.IsNullOrEmpty(filePath))
{
photosOfThisRound.Add(filePath);
_PhotosOfThisRound.Add(filePath);
return true;
}
return false;
}
internal static string[] getPhotosOfThisRound()
internal static string[] GetPhotosOfThisRound()
{
string[] result = photosOfThisRound.ToArray();
photosOfThisRound.Clear();
string[] result = _PhotosOfThisRound.ToArray();
_PhotosOfThisRound.Clear();
return result;
}
#endregion
@@ -583,11 +582,11 @@ namespace Vocaluxe.Base.Server
return false;
}
byte[] salt = profile.PasswordSalt;
//byte[] salt = profile.PasswordSalt;
return hashedPassword.SequenceEqual(profile.PasswordHash);
}
private static byte[] _GetPassowordSalt(int profileId)
private static byte[] _GetPasswordSalt(int profileId)
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
-4
View File
@@ -16,12 +16,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Security;
using System.Text;
using Microsoft.Win32;
using Vocaluxe.Base;
-1
View File
@@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using Vocaluxe.Base;
using VocaluxeLib;
+1 -3
View File
@@ -665,7 +665,7 @@ namespace Vocaluxe.Lib.Sound
return -1;
}
public bool Skip(float time)
public void Skip(float time)
{
lock (_LockSyncSignals)
{
@@ -673,8 +673,6 @@ namespace Vocaluxe.Lib.Sound
_SetSkip = true;
_Waiting = true;
}
return true;
}
#region Threading
-6
View File
@@ -15,7 +15,6 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using ServerLib;
using Vocaluxe.Base;
using Vocaluxe.Base.Server;
using VocaluxeLib;
@@ -56,11 +55,6 @@ namespace Vocaluxe.Screens
_ThemeTexts = new string[] {_TextServerAddress, _TextServerNotRunning};
}
public override void LoadTheme(string xmlPath)
{
base.LoadTheme(xmlPath);
}
public override void OnShow()
{
base.OnShow();
@@ -15,12 +15,10 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.Draw;
namespace Vocaluxe.Screens
{
+3 -3
View File
@@ -187,8 +187,8 @@ namespace Vocaluxe.Screens
if (_SlideShowBGAvailable)
_SlideShowBG.Draw();
else
base._DrawBG();
base._DrawFG();
_DrawBG();
_DrawFG();
return true;
}
@@ -428,7 +428,7 @@ namespace Vocaluxe.Screens
private bool _UpdateBackground()
{
string[] photos = CVocaluxeServer.getPhotosOfThisRound();
string[] photos = CVocaluxeServer.GetPhotosOfThisRound();
_SlideShowBG.RemoveSlideShowTextures();
foreach (string photo in photos)
_SlideShowBG.AddSlideShowTexture(photo);
+2
View File
@@ -22,6 +22,7 @@
position: relative;
height: 100%;
width: 100%;
background-color: #000000;
background-color: rgba(0,0,0,0.7);
}
@@ -30,6 +31,7 @@
height: 100%;
top: 0;
margin: 0;
background: #000000;
background: rgba(0, 0, 0, 0.3);
display: none;
position: fixed;
+2
View File
@@ -355,6 +355,7 @@ namespace VocaluxeLib
[Flags]
public enum EUserRole
{
// ReSharper disable InconsistentNaming
TR_USERROLE_GUEST = 0,
TR_USERROLE_NORMAL = 1,
TR_USERROLE_ADMIN = 2,
@@ -362,5 +363,6 @@ namespace VocaluxeLib
TR_USERROLE_ADDSONGSUSER = 8,
TR_USERROLE_PLAYLISTEDITOR = 16,
TR_USERROLE_PROFILEEDITOR = 32
// ReSharper restore InconsistentNaming
}
}
+1 -2
View File
@@ -19,11 +19,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace VocaluxeLib
{
public static class Extensions
public static class CExtensions
{
/// <summary>
/// Resizes the given list to the given size. Removes elements or adds default values
+4 -5
View File
@@ -54,8 +54,8 @@ namespace VocaluxeLib.Menu
private bool _ThemeLoaded;
private int _SlideShowCurrent;
private Stopwatch _SlideShowTimer = new Stopwatch();
private List<CTexture> _SlideShowTextures = new List<CTexture>();
private readonly Stopwatch _SlideShowTimer = new Stopwatch();
private readonly List<CTexture> _SlideShowTextures = new List<CTexture>();
public SColorF Color;
@@ -69,8 +69,7 @@ namespace VocaluxeLib.Menu
{
_PartyModeID = partyModeID;
_ThemeLoaded = false;
_Theme = new SThemeBackground();
_Theme.SlideShowTextures = new List<string>();
_Theme = new SThemeBackground {SlideShowTextures = new List<string>()};
Color = new SColorF(0f, 0f, 0f, 1f);
}
@@ -102,11 +101,11 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= success;
}
string slideShow = "";
int i = 1;
while (xmlReader.ItemExists(item + "/SlideShow" + i))
{
string slideShow;
xmlReader.GetValue(item + "/SlideShow" + i, out slideShow, String.Empty);
if (slideShow != "")
_Theme.SlideShowTextures.Add(slideShow);
-2
View File
@@ -16,8 +16,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml;
using VocaluxeLib.Songs;
-1
View File
@@ -19,7 +19,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using VocaluxeLib.Draw;
+56 -19
View File
@@ -15,11 +15,8 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Draw;
using VocaluxeLib.Profile;
@@ -94,10 +91,7 @@ namespace VocaluxeLib.Menu
_NumPlayer = numPlayer;
_NumPlayerTeams = numPlayerTeams;
if (_NumTeams > 0)
_TeamList = new List<int>[_NumTeams];
else
_TeamList = new List<int>[1];
_TeamList = new List<int>[_NumTeams > 0 ? _NumTeams : 1];
if (_NumTeams != _NumPlayerTeams.Length)
_NumPlayerTeams = new int[_NumTeams];
@@ -126,7 +120,7 @@ namespace VocaluxeLib.Menu
{
//Handle left/right/up/down
_NameSelections[_NameSelection].HandleInput(keyEvent);
int numberPressed = -1;
int numPressed = -1;
bool resetSelection = false;
switch (keyEvent.Key)
{
@@ -157,20 +151,65 @@ namespace VocaluxeLib.Menu
case Keys.Back:
resetSelection = true;
break;
case Keys.D1:
case Keys.NumPad1:
numPressed = 1;
break;
case Keys.D2:
case Keys.NumPad2:
numPressed = 2;
break;
case Keys.D3:
case Keys.NumPad3:
numPressed = 3;
break;
case Keys.D4:
case Keys.NumPad4:
numPressed = 4;
break;
case Keys.D5:
case Keys.NumPad5:
numPressed = 5;
break;
case Keys.D6:
case Keys.NumPad6:
numPressed = 6;
break;
case Keys.D7:
case Keys.NumPad7:
numPressed = 7;
break;
case Keys.D8:
case Keys.NumPad8:
numPressed = 8;
break;
case Keys.D9:
case Keys.NumPad9:
numPressed = 9;
break;
}
if (numberPressed > 0 || resetSelection)
if (numPressed > 0 || resetSelection)
{
if (numberPressed == _SelectingFastPlayerNr || resetSelection)
if (numPressed == _SelectingFastPlayerNr || resetSelection)
{
//Reset all values
_SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false;
_NameSelections[_NameSelection].FastSelection(false, -1);
}
else if (numberPressed <= _NumPlayerTeams[_CurrentTeam])
else if (numPressed <= _NumPlayerTeams[_CurrentTeam])
{
_SelectingFastPlayerNr = numberPressed;
_NameSelections[_NameSelection].FastSelection(true, numberPressed);
_SelectingFastPlayerNr = numPressed;
_NameSelections[_NameSelection].FastSelection(true, numPressed);
}
_SelectingFast = false;
}
@@ -530,9 +569,7 @@ namespace VocaluxeLib.Menu
public SPartyNameOptions GetData()
{
SPartyNameOptions option = new SPartyNameOptions();
option.NumPlayerTeams = _NumPlayerTeams;
option.TeamList = _TeamList;
SPartyNameOptions option = new SPartyNameOptions {NumPlayerTeams = _NumPlayerTeams, TeamList = _TeamList};
return option;
}
@@ -692,7 +729,7 @@ namespace VocaluxeLib.Menu
{
if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic)
return;
else if (_NumPlayerTeams[team] == _PartyMode.GetMaxPlayerPerTeam())
if (_NumPlayerTeams[team] == _PartyMode.GetMaxPlayerPerTeam())
return;
_NameSelections[_NameSelection].UseProfile(profileID);
@@ -707,8 +744,8 @@ namespace VocaluxeLib.Menu
{
List<int> ids = new List<int>();
ids.AddRange(_TeamList[t]);
for (int p = 0; p < ids.Count; p++)
_RemovePlayer(t, ids[p]);
foreach (int id in ids)
_RemovePlayer(t, id);
}
}
+1 -2
View File
@@ -94,7 +94,7 @@ namespace VocaluxeLib.Menu
private int _Player = -1;
private readonly List<int> _VisibleProfiles;
private List<int> _UsedProfiles;
private readonly List<int> _UsedProfiles;
private CStatic _PlayerSelector;
@@ -416,7 +416,6 @@ namespace VocaluxeLib.Menu
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Tiles.Count]);
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
_Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Tiles.Count]);
;
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
}
else
+2 -3
View File
@@ -214,7 +214,8 @@ namespace VocaluxeLib.Menu.SongMenu
if (_SongMenu != null)
_SongMenu.OnHide();
switch (CBase.Config.GetSongMenuType())
_Type = CBase.Config.GetSongMenuType();
switch (_Type)
{
//case ESongMenu.TR_CONFIG_LIST:
// _SongMenu = new CSongMenuList();
@@ -231,8 +232,6 @@ namespace VocaluxeLib.Menu.SongMenu
// _SongMenu = new CSongMenuBook();
// break;
}
_Type = CBase.Config.GetSongMenuType();
}
}
}
+20 -21
View File
@@ -67,11 +67,11 @@ namespace VocaluxeLib.Menu.SongMenu
{
set
{
base._PlaySong(value);
base._PreviewIdInternal = value;
_PlaySong(value);
_PreviewIdInternal = value;
_UpdatePreview();
}
get { return base._PreviewIdInternal; }
get { return _PreviewIdInternal; }
}
public override int GetActualSelection()
@@ -138,7 +138,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
if (_Length < 0 && CBase.Sound.GetLength(_PreviewSongStream) > 0 && CBase.Songs.IsInCategory())
UpdateLength(CBase.Songs.GetVisibleSong(_PreviewId));
_UpdateLength(CBase.Songs.GetVisibleSong(_PreviewId));
}
private void _UpdatePreview()
@@ -181,7 +181,7 @@ namespace VocaluxeLib.Menu.SongMenu
_MedleyCalcIcon.Visible = song.Medley.Source == EDataSource.Calculated;
_MedleyTagIcon.Visible = song.Medley.Source == EDataSource.Tag;
UpdateLength(song);
_UpdateLength(song);
}
else
{
@@ -198,23 +198,22 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
private void UpdateLength(CSong song)
private void _UpdateLength(CSong song)
{
if (song != null)
{
float time = CBase.Sound.GetLength(_PreviewSongStream);
if (Math.Abs(song.Finish) > 0.001)
time = song.Finish;
if (song == null)
return;
float time = CBase.Sound.GetLength(_PreviewSongStream);
if (Math.Abs(song.Finish) > 0.001)
time = song.Finish;
// The audiobackend is not yet ready to return the length
if (time > 0)
{
time -= song.Start;
var min = (int)Math.Floor(time / 60f);
var sec = (int)(time - min * 60f);
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
_Length = time;
}
// The audiobackend is ready to return the length
if (time > 0)
{
time -= song.Start;
var min = (int)Math.Floor(time / 60f);
var sec = (int)(time - min * 60f);
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
_Length = time;
}
}
@@ -556,7 +555,7 @@ namespace VocaluxeLib.Menu.SongMenu
public override void SetSelectedSong(int visibleSongNr)
{
base._PlaySong(visibleSongNr);
_PlaySong(visibleSongNr);
base.SetSelectedSong(visibleSongNr);
if (visibleSongNr >= 0 && visibleSongNr < CBase.Songs.GetNumSongsVisible())
+1 -1
View File
@@ -49,7 +49,7 @@ namespace VocaluxeLib.Profile
CBase.Drawing.RemoveTexture(ref Texture);
}
public string getFileName()
public string GetFileName()
{
return FileName;
}
+6 -5
View File
@@ -17,7 +17,6 @@
using System;
using System.IO;
using System.Text;
using System.Xml;
namespace VocaluxeLib.Profile
@@ -71,9 +70,11 @@ namespace VocaluxeLib.Profile
FileName = String.Empty;
}
public bool LoadProfile()
public bool LoadProfile(string pathName, string fileName)
{
return LoadProfile(FilePath, FileName);
FilePath = pathName;
FileName = fileName;
return LoadProfile();
}
public bool LoadProfile(string file)
@@ -81,10 +82,10 @@ namespace VocaluxeLib.Profile
FileName = Path.GetFileName(file);
FilePath = Path.GetDirectoryName(file);
return LoadProfile(FilePath, FileName);
return LoadProfile();
}
public bool LoadProfile(string pathName, string fileName)
public bool LoadProfile()
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(FilePath, FileName));
if (xmlReader == null)
+1 -2
View File
@@ -135,11 +135,10 @@ namespace VocaluxeLib.Songs
return false;
}
public bool IncLastNoteLength()
public void IncLastNoteLength()
{
if (_Notes.Count > 0)
_Notes[NoteCount - 1].Duration++;
return false;
}
public void DeleteAllNotes()
+1 -1
View File
@@ -97,7 +97,7 @@ namespace VocaluxeLib.Songs
public string MP3FileName = String.Empty;
public string CoverFileName = String.Empty;
public List<string> BackgroundFileNames = new List<string>();
public readonly List<string> BackgroundFileNames = new List<string>();
public string VideoFileName = String.Empty;
public EAspect VideoAspect = EAspect.Crop;
+1
View File
@@ -41,6 +41,7 @@ namespace VocaluxeLib.Songs
/// <param name="duration"></param>
/// <param name="tone"></param>
/// <param name="hitNote"></param>
/// <param name="points"></param>
public CSungNote(int startBeat, int duration, int tone, CSongNote hitNote, double points) : this(startBeat, duration, tone)
{
HitNote = hitNote;
+1 -3
View File
@@ -205,15 +205,13 @@ namespace VocaluxeLib.Songs
public void UpdateTimings()
{
CSongNote lastNote;
if (_Lines.Count == 0)
return;
_Lines[0].StartBeat = -10000;
for (int i = 1; i < _Lines.Count; i++)
{
lastNote = _Lines[i - 1].LastNote;
CSongNote lastNote = _Lines[i - 1].LastNote;
CSongNote firstNote = _Lines[i].FirstNote;
if ((lastNote != null) && (firstNote != null))
+2 -13
View File
@@ -15,7 +15,6 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System.Diagnostics;
using System.Security.Authentication;
using System.Security.Principal;
using Security.Cryptography;
@@ -166,12 +165,7 @@ namespace WebserverInitalConfig
{
if (!profile.FirewallEnabled)
return true;
foreach (INetFwAuthorizedApplication a in profile.AuthorizedApplications)
{
if (a.ProcessImageFileName == _ExePath)
return true;
}
return false;
return profile.AuthorizedApplications.Cast<INetFwAuthorizedApplication>().Any(a => a.ProcessImageFileName == _ExePath);
}
private bool _IsPortOpen(INetFwProfile profile)
@@ -180,12 +174,7 @@ namespace WebserverInitalConfig
if (!profile.FirewallEnabled)
return true;
foreach (INetFwOpenPort p in profile.GloballyOpenPorts)
{
if (p.Protocol == protocol && p.Port == _Port)
return true;
}
return false;
return profile.GloballyOpenPorts.Cast<INetFwOpenPort>().Any(p => p.Protocol == protocol && p.Port == _Port);
}
private NET_FW_IP_PROTOCOL_ _GetProtocol()
-3
View File
@@ -18,13 +18,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace WebserverInitalConfig
{
-2
View File
@@ -19,9 +19,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Mime;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
namespace WebserverInitalConfig
{
@@ -16,7 +16,6 @@
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden