private void PlayTimeListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var listView = (ListView)sender; var item = listView.ContainerFromElement((DependencyObject)e.OriginalSource) as ListViewItem; if (item != null) { TimeSummary g = (TimeSummary)PlayTimeListView.SelectedItem; if (g.time != 0) { List <GameTimeSummary> glist = new List <GameTimeSummary>(); using (SQLiteCommand command = conn.CreateCommand()) { conn.Open(); command.CommandText = @"SELECT g.title, p.playtime FROM games g,playtime p WHERE g.uid=p.game AND p.datetime=date('" + g.d.ToString("yyyy-MM-dd") + @"') "; using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { glist.Add(new GameTimeSummary(reader["title"].ToString(), Convert.ToInt32(reader["playtime"].ToString()))); } } } conn.Close(); Dialog.GameTimeGraph gtg = new GameTimeGraph(glist, g.d.ToString("yyyy-MM-dd")); gtg.Owner = Window.GetWindow(this); if (gtg.ShowDialog() == true) { } } } }
private void PlayTimeListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var listView = (ListView)sender; var item = listView.ContainerFromElement((DependencyObject)e.OriginalSource) as ListViewItem; if (item != null) { TimeSummary g = (TimeSummary)PlayTimeListView.SelectedItem; if (g.time != 0) { List <GameTimeSummary> glist = new List <GameTimeSummary>(); using (SQLiteCommand command = conn.CreateCommand()) { string hideNukige = ""; if (Settings.Default.hideNukige) { hideNukige = @" AND g.nukige = 0 "; } conn.Open(); command.CommandText = @"SELECT g.title,SUM(p.playtime) playtime FROM games g,playtime p WHERE g.uid=p.game " + hideNukige + @" AND p.datetime BETWEEN date('" + g.d.ToString("yyyy-MM-dd") + @"') AND date('" + g.d.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") + @"') GROUP BY g.uid" ; using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { glist.Add(new GameTimeSummary(reader["title"].ToString(), Convert.ToInt32(reader["playtime"].ToString()))); } } } conn.Close(); Dialog.GameTimeGraph gtg = new GameTimeGraph(glist, g.d.ToString("yyyy-MM-dd") + "~" + g.d.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"), GraphType.Monthly); gtg.Owner = Window.GetWindow(this); if (gtg.ShowDialog() == true) { } } } }
private void PlayTimeListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var listView = (ListView)sender; var item = listView.ContainerFromElement((DependencyObject)e.OriginalSource) as ListViewItem; if (item != null) { TimeSummary g = (TimeSummary)PlayTimeListView.SelectedItem; if (g.time != 0) { int othersNum = 0; List <GameTimeSummary> otherTitles = new List <GameTimeSummary>(); List <GameTimeSummary> glist = new List <GameTimeSummary>(); using (SQLiteCommand command = conn.CreateCommand()) { string hideNukige = ""; if (Settings.Default.hideNukige) { hideNukige = @" AND g.nukige = 0 "; } conn.Open(); command.CommandText = @"SELECT g.title,SUM(p.playtime) playtime FROM games g,playtime p WHERE g.uid=p.game AND p.datetime BETWEEN date('" + g.d.ToString("yyyy-01-01 00:00:00") + @"') AND date('" + g.d.ToString("yyyy-12-31 23:59:59") + @"') " + hideNukige + @" GROUP BY g.uid ORDER BY SUM(p.playtime) DESC " ; using (SQLiteDataReader reader = command.ExecuteReader()) { List <GameTimeSummary> innerList = new List <GameTimeSummary>(); while (reader.Read()) { int playTime = Convert.ToInt32(reader["playtime"].ToString()); innerList.Add(new GameTimeSummary(reader["title"].ToString(), playTime, GraphType.Yearly)); } if (innerList.Count <= 20 || Settings.Default.showAllGameInYearGraph) { // if count <= 20, show them all glist = innerList; } else { int othersTime = 0; int count = 0; innerList.ForEach(it => { if (count++ < 20) { glist.Add(it); } else if (it.t > 5 * 3600) { glist.Add(it); } else { othersTime += it.t; othersNum++; otherTitles.Add(it); } }); if (othersNum != 0) { glist.Add(new GameTimeSummary($"その他{othersNum}本", othersTime, GraphType.Yearly)); } } } } conn.Close(); Dialog.GameTimeBarGraph2 gtbg = new GameTimeBarGraph2(glist, g.d.ToString("yyyy-01-01") + "~" + g.d.ToString("yyyy-12-31"), GraphType.Yearly, otherTitles.Count == 0 ? null : otherTitles); gtbg.Owner = Window.GetWindow(this); if (gtbg.ShowDialog() == true) { } } } }