Skip to content

Commit

Permalink
first update stats when opening stats flyout/window
Browse files Browse the repository at this point in the history
  • Loading branch information
Epix37 committed Oct 22, 2015
1 parent 3ee6e5d commit 5c03907
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@
mc:Ignorable="d"
d:DesignHeight="1000" d:DesignWidth="800">
<DockPanel>
<Button Content="Refresh" DockPanel.Dock="Top" Width="80" HorizontalAlignment="Left" Margin="2" Click="Button_Click"/>
<ScrollViewer>
<StackPanel>
<GroupBox Header="Class distribution by wins" Height="400" Width="600">
<GroupBox Header="Note" MaxWidth="600">
<StackPanel Orientation="Horizontal">
<Button Style="{DynamicResource MetroCircleButtonStyle}" Width="36" Height="36" Margin="-5" Click="Button_Click">
<Rectangle Width="14" Height="16">
<Rectangle.Fill>
<VisualBrush Visual="{DynamicResource appbar_refresh}" />
</Rectangle.Fill>
</Rectangle>
</Button>
<Label Content="These charts render a bit slow. Press refresh to update them."/>
</StackPanel>
</GroupBox>
<GroupBox Header="Class distribution by wins" Height="400" MaxWidth="600">
<charts:ChartWinsByClass/>
</GroupBox>
<GroupBox Header="Win/Loss by class" Height="400" Width="600">
<GroupBox Header="Win/Loss by class" Height="400" MaxWidth="600">
<charts:ChartWinsLossByClass/>
</GroupBox>
</StackPanel>
Expand Down
10 changes: 5 additions & 5 deletions Hearthstone Deck Tracker/Controls/Stats/Overview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:stats="clr-namespace:Hearthstone_Deck_Tracker.Controls.Stats"
xmlns:enums="clr-namespace:Hearthstone_Deck_Tracker.Enums"
xmlns:converters="clr-namespace:Hearthstone_Deck_Tracker.Controls.Stats.Converters"
xmlns:utility="clr-namespace:Hearthstone_Deck_Tracker.Utility"
xmlns:utility="clr-namespace:Hearthstone_Deck_Tracker.Utility"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
<UserControl.Resources>
Expand All @@ -18,10 +18,10 @@
<DockPanel>
<GroupBox Header="MENU" DockPanel.Dock="Top">
<TreeView Name="TreeViewStats" Width="150" Height="150" >
<TreeViewItem Name="TreeViewItemArenaRuns" IsExpanded="True" Header="Arena Runs" DataContext="{Binding ArenaOverview, RelativeSource={RelativeSource AncestorType=UserControl}}">
<TreeViewItem Name="TreeViewItemArenaRunsSummary" Header="Summary" IsSelected="True" DataContext="{Binding ArenaStatsSummary, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<TreeViewItem Name="TreeViewItemArenaRunsOverview" Header="Overview" DataContext="{Binding ArenaOverview, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<TreeViewItem Name="TreeViewItemArenaRunsAdvanced" Header="Advanced (slow)" DataContext="{Binding ArenaAdvancedCharts, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<TreeViewItem Name="TreeViewItemArenaRuns" IsExpanded="True" Selected="TreeViewItemArenaRuns_OnSelected" Header="Arena Runs" DataContext="{Binding ArenaOverview, RelativeSource={RelativeSource AncestorType=UserControl}}">
<TreeViewItem Name="TreeViewItemArenaRunsSummary" Selected="TreeViewItemArenaRunsSummary_OnSelected" Header="Summary" IsSelected="True" DataContext="{Binding ArenaStatsSummary, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<TreeViewItem Name="TreeViewItemArenaRunsOverview" Selected="TreeViewItemArenaRunsOverview_OnSelected" Header="Overview" DataContext="{Binding ArenaOverview, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<TreeViewItem Name="TreeViewItemArenaRunsAdvanced" Selected="TreeViewItemArenaRunsAdvanced_OnSelected" Header="Advanced (slow)" DataContext="{Binding ArenaAdvancedCharts, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
</TreeViewItem>
<TreeViewItem Header="Constructed" IsExpanded="True" IsEnabled="False">
<TreeViewItem Header="[coming soon]"/>
Expand Down
30 changes: 29 additions & 1 deletion Hearthstone Deck Tracker/Controls/Stats/Overview.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void CheckBoxArchived_OnUnchecked(object sender, RoutedEventArgs e)
UpdateStats();
}

private void UpdateStats()
public void UpdateStats()
{
if(TreeViewItemArenaRuns.IsSelected || TreeViewItemArenaRunsOverview.IsSelected)
CompiledStats.Instance.UpdateArenaStats();
Expand Down Expand Up @@ -135,6 +135,34 @@ private void ToggleButtonExpandFilters_OnUnchecked(object sender, RoutedEventArg
return;
ExpandChildExpanders(StackPanelFilters, false);
}

private void TreeViewItemArenaRunsSummary_OnSelected(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
UpdateStats();
}

private void TreeViewItemArenaRunsOverview_OnSelected(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
UpdateStats();
}

private void TreeViewItemArenaRunsAdvanced_OnSelected(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
UpdateStats();
}

private void TreeViewItemArenaRuns_OnSelected(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
UpdateStats();
}
}

public class HeroClassStatsFilterWrapper
Expand Down
3 changes: 3 additions & 0 deletions Hearthstone Deck Tracker/Resources/Icons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@
</Path.Data>
</Path>
</Canvas>
<Canvas x:Key="appbar_refresh" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="34.8333" Height="41.1667" Canvas.Left="20.5833" Canvas.Top="17.4167" Stretch="Fill" Fill="{DynamicResource AccentColorBrush}" Data="F1 M 38,20.5833C 42.9908,20.5833 47.4912,22.6825 50.6667,26.046L 50.6667,17.4167L 55.4166,22.1667L 55.4167,34.8333L 42.75,34.8333L 38,30.0833L 46.8512,30.0833C 44.6768,27.6539 41.517,26.125 38,26.125C 31.9785,26.125 27.0037,30.6068 26.2296,36.4167L 20.6543,36.4167C 21.4543,27.5397 28.9148,20.5833 38,20.5833 Z M 38,49.875C 44.0215,49.875 48.9963,45.3932 49.7703,39.5833L 55.3457,39.5833C 54.5457,48.4603 47.0852,55.4167 38,55.4167C 33.0092,55.4167 28.5088,53.3175 25.3333,49.954L 25.3333,58.5833L 20.5833,53.8333L 20.5833,41.1667L 33.25,41.1667L 38,45.9167L 29.1487,45.9167C 31.3231,48.3461 34.483,49.875 38,49.875 Z "/>
</Canvas>
</ResourceDictionary>
7 changes: 6 additions & 1 deletion Hearthstone Deck Tracker/Stats/CompiledStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public static CompiledStats Instance

private IEnumerable<Deck> ArenaDecks
{
get { return DeckList.Instance.Decks.Where(x => x != null && x.IsArenaDeck); }
get
{
if(!Core.Initialized)
return new List<Deck>();
return DeckList.Instance.Decks.Where(x => x != null && x.IsArenaDeck);
}
}

public IEnumerable<ArenaRun> ArenaRuns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,13 @@ private void BtnDeckNewStats_Click(object sender, RoutedEventArgs e)
Core.Windows.NewStatsWindow.WindowState = WindowState.Normal;
Core.Windows.NewStatsWindow.Show();
Core.Windows.NewStatsWindow.Activate();
Core.Windows.NewStatsWindow.Overview.UpdateStats();
}
else
{
FlyoutNewStats.IsOpen = true;
NewStatsFlyout.UpdateStats();
}
}

private void DeckPickerList_OnSelectedDeckChanged(DeckPicker sender, Deck deck)
Expand Down
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/Windows/StatsWindow_New.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
</controls:WindowCommands>
</controls:MetroWindow.RightWindowCommands>
<Grid>
<stats:Overview x:Name="ArenaStats"/>
<stats:Overview x:Name="Overview"/>
</Grid>
</controls:MetroWindow>

0 comments on commit 5c03907

Please sign in to comment.