Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
epix37 committed May 3, 2015
1 parent 0f88a23 commit 9931e38
Show file tree
Hide file tree
Showing 67 changed files with 3,239 additions and 3,402 deletions.
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/API/ActionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Add(Action<T> action)
internal void Execute(T arg)
{
var remove = new List<Tuple<object, Action<T>>>();
foreach(var action in _actions)
foreach(var action in _actions)
{
var sw = Stopwatch.StartNew();
var plugin = action.Item1 as PluginWrapper;
Expand Down
4 changes: 4 additions & 0 deletions Hearthstone Deck Tracker/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#region

#region

// ReSharper disable RedundantUsingDirective
using System;
using System.IO;
Expand All @@ -8,6 +10,8 @@

#endregion

#endregion

namespace Hearthstone_Deck_Tracker
{
/// <summary>
Expand Down
278 changes: 138 additions & 140 deletions Hearthstone Deck Tracker/Controls/DeckPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,145 +21,6 @@ namespace Hearthstone_Deck_Tracker
/// </summary>
public partial class DeckPicker
{
#region HsClass

public class HsClass
{
public List<Deck> Decks;
public string Name;
public List<string> SelectedTags;
public TagFilerOperation TagOperation;

public HsClass(string name)
{
Name = name;
Decks = new List<Deck>();
SelectedTags = new List<string>();
}

public string TagList
{
get { return ""; }
}

public string GetName
{
get
{
return (Name == "Back" || Name == "All")
? Name
: Name + " ("
+ Decks.Count(
d =>
SelectedTags.Any(t => t == "All")
|| (TagOperation == TagFilerOperation.Or
? SelectedTags.Any(t => d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0)
: SelectedTags.All(t => d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0))) + ")";
}
}

public string WinPercentString
{
get
{
if(Name == "Back" || Name == "All")
return "win%";
var filteredDecks =
Decks.Where(d => Config.Instance.SelectedTags.Any(t => t == "All" || d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0))
.ToList();
var total = filteredDecks.Sum(d => d.DeckStats.Games.Count);
if(total == 0)
return "-%";
return Math.Round(100.0 * filteredDecks.Sum(d => d.DeckStats.Games.Count(g => g.Result == GameResult.Win)) / total, 0) + "%";
}
}

// ReSharper disable PossibleNullReferenceException
public Color ClassColor
{
get
{
switch(Name)
{
case "Druid":
return (Color)ColorConverter.ConvertFromString("#FF7D0A");
case "Death Knight":
return (Color)ColorConverter.ConvertFromString("#C41F3B");
case "Hunter":
return (Color)ColorConverter.ConvertFromString("#ABD473");
case "Mage":
return (Color)ColorConverter.ConvertFromString("#69CCF0");
case "Monk":
return (Color)ColorConverter.ConvertFromString("#00FF96");
case "Paladin":
return (Color)ColorConverter.ConvertFromString("#F58CBA");
case "Priest":
return (Color)ColorConverter.ConvertFromString("#FFFFFF");
case "Rogue":
return (Color)ColorConverter.ConvertFromString("#FFF569");
case "Shaman":
return (Color)ColorConverter.ConvertFromString("#0070DE");
case "Warlock":
return (Color)ColorConverter.ConvertFromString("#9482C9");
case "Warrior":
return (Color)ColorConverter.ConvertFromString("#C79C6E");
default:
return Colors.Gray;
}
}
}

// ReSharper restore PossibleNullReferenceException

public FontWeight GetFontWeight
{
get { return FontWeights.Bold; }
}
}

#endregion

#region Properties

public delegate void DoubleClickHandler(DeckPicker sender, Deck deck);

public delegate void SelectedDeckHandler(DeckPicker sender, Deck deck);


private readonly List<string> _classNames = new List<string>
{
"Druid",
"Hunter",
"Mage",
"Paladin",
"Priest",
"Rogue",
"Shaman",
"Warlock",
"Warrior"
};

private readonly List<HsClass> _hsClasses;
private readonly bool _initialized;
public Deck SelectedDeck;
public List<string> SelectedTags;
public bool ShowAll;
public TagFilerOperation TagOperation;
private bool _inClassSelect;
private HsClass _selectedClass;

public string GetSelectedClass
{
get { return _selectedClass != null ? _selectedClass.Name : "None"; }
}

public bool ChangedSelection { get; set; }

public event SelectedDeckHandler OnSelectedDeckChanged;
public event DoubleClickHandler OnDoubleClick;

#endregion

private bool _wasClicked;
private bool _wasDoubleClicked;

Expand Down Expand Up @@ -384,7 +245,6 @@ public void SetTagOperation(TagFilerOperation o)
hsClass.TagOperation = o;
}


public void SortDecks()
{
if(_inClassSelect)
Expand Down Expand Up @@ -455,5 +315,143 @@ private void Control_OnPreviewMouseDoubleClick(object sender, MouseButtonEventAr
if(OnDoubleClick != null)
OnDoubleClick(this, SelectedDeck);
}

#region HsClass

public class HsClass
{
public List<Deck> Decks;
public string Name;
public List<string> SelectedTags;
public TagFilerOperation TagOperation;

public HsClass(string name)
{
Name = name;
Decks = new List<Deck>();
SelectedTags = new List<string>();
}

public string TagList
{
get { return ""; }
}

public string GetName
{
get
{
return (Name == "Back" || Name == "All")
? Name
: Name + " ("
+ Decks.Count(
d =>
SelectedTags.Any(t => t == "All")
|| (TagOperation == TagFilerOperation.Or
? SelectedTags.Any(t => d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0)
: SelectedTags.All(t => d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0))) + ")";
}
}

public string WinPercentString
{
get
{
if(Name == "Back" || Name == "All")
return "win%";
var filteredDecks =
Decks.Where(d => Config.Instance.SelectedTags.Any(t => t == "All" || d.Tags.Contains(t) || t == "None" && d.Tags.Count == 0))
.ToList();
var total = filteredDecks.Sum(d => d.DeckStats.Games.Count);
if(total == 0)
return "-%";
return Math.Round(100.0 * filteredDecks.Sum(d => d.DeckStats.Games.Count(g => g.Result == GameResult.Win)) / total, 0) + "%";
}
}

// ReSharper disable PossibleNullReferenceException
public Color ClassColor
{
get
{
switch(Name)
{
case "Druid":
return (Color)ColorConverter.ConvertFromString("#FF7D0A");
case "Death Knight":
return (Color)ColorConverter.ConvertFromString("#C41F3B");
case "Hunter":
return (Color)ColorConverter.ConvertFromString("#ABD473");
case "Mage":
return (Color)ColorConverter.ConvertFromString("#69CCF0");
case "Monk":
return (Color)ColorConverter.ConvertFromString("#00FF96");
case "Paladin":
return (Color)ColorConverter.ConvertFromString("#F58CBA");
case "Priest":
return (Color)ColorConverter.ConvertFromString("#FFFFFF");
case "Rogue":
return (Color)ColorConverter.ConvertFromString("#FFF569");
case "Shaman":
return (Color)ColorConverter.ConvertFromString("#0070DE");
case "Warlock":
return (Color)ColorConverter.ConvertFromString("#9482C9");
case "Warrior":
return (Color)ColorConverter.ConvertFromString("#C79C6E");
default:
return Colors.Gray;
}
}
}

// ReSharper restore PossibleNullReferenceException
public FontWeight GetFontWeight
{
get { return FontWeights.Bold; }
}
}

#endregion

#region Properties

public delegate void DoubleClickHandler(DeckPicker sender, Deck deck);

public delegate void SelectedDeckHandler(DeckPicker sender, Deck deck);


private readonly List<string> _classNames = new List<string>
{
"Druid",
"Hunter",
"Mage",
"Paladin",
"Priest",
"Rogue",
"Shaman",
"Warlock",
"Warrior"
};

private readonly List<HsClass> _hsClasses;
private readonly bool _initialized;
public Deck SelectedDeck;
public List<string> SelectedTags;
public bool ShowAll;
public TagFilerOperation TagOperation;
private bool _inClassSelect;
private HsClass _selectedClass;

public string GetSelectedClass
{
get { return _selectedClass != null ? _selectedClass.Name : "None"; }
}

public bool ChangedSelection { get; set; }

public event SelectedDeckHandler OnSelectedDeckChanged;
public event DoubleClickHandler OnDoubleClick;

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ namespace Hearthstone_Deck_Tracker
/// </summary>
public partial class ElementSorterItem
{
public readonly string ItemName;
private readonly bool _initialized;
private readonly bool _isPlayerList;
private readonly Action<bool> _setConfigValue;
public readonly string ItemName;

public ElementSorterItem(string name, bool isChecked, Action<bool> setConfigValue, bool isPlayerList)
{
Expand Down
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/Controls/ManaCurve.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#region

using System.Windows.Controls;
using Hearthstone_Deck_Tracker.Enums;
using Hearthstone_Deck_Tracker.Hearthstone;
Expand Down Expand Up @@ -148,7 +149,6 @@ public void UpdateValues()

private void ListViewStatType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{

if(e.AddedItems.Count == 0)
{
if(e.RemovedItems.Count > 0)
Expand Down
Loading

0 comments on commit 9931e38

Please sign in to comment.