Commit 3c0c1077 by liulongfei

排序更新

parent f84f786d
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Golf.Domain
{
/// <summary>
/// 分组临时模型顶部排序比较器
/// </summary>
public class GroupTempModelTopComparer : IComparer<GroupTempModel>
{
/// <summary>
/// 分组临时模型顶部排序比较器
/// </summary>
/// <param name="playerRealModels">球员真实模型</param>
/// <param name="round">轮次</param>
public GroupTempModelTopComparer(List<PlayerRealModel> playerRealModels, int round)
{
this.PlayerRealModels = playerRealModels;
this.Round = round;
}
/// <summary>
/// 轮次
/// </summary>
public int Round { get; private set; }
/// <summary>
/// 球员真实模型
/// </summary>
public List<PlayerRealModel> PlayerRealModels { get; private set; }
/// <summary>
/// 比较
/// </summary>
public int Compare(GroupTempModel x, GroupTempModel y)
{
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfo && p.PlayerInfoModel.Group == x.Group);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfo && p.PlayerInfoModel.Group == y.Group);
// 1. 杆数少 排名靠前
int total_x = real_players_X.Sum(p => p.Score);
int total_y = real_players_Y.Sum(p => p.Score);
if (total_x != total_y)
return total_x < total_y ? -1 : 1;
// 2. 比较后9洞总成绩
int last_x = 0;
foreach (var real_player in real_players_X)
{
var real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.Round);
if (real_round == null)
continue;
last_x += real_round.Scores.Skip(9).Sum(p => p.Strokes - p.Par);
}
int last_y = 0;
foreach (var real_player in real_players_Y)
{
var real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.Round);
if (real_round == null)
continue;
last_y += real_round.Scores.Skip(9).Sum(p => p.Strokes - p.Par);
}
if (last_x != last_y)
return last_x < last_y ? -1 : 1;
// 3. 逐个比较第二轮每一洞成绩
for (int i = 18; i >= 1; --i)
{
int hole_result = this.CompareWithHole(x, y, 2, i);
if (hole_result != 0)
{
return hole_result;
}
}
return 0;
}
/// <summary>
/// 比较大小
/// </summary>
/// <param name="round">轮次</param>
private int CompareWithHole(GroupTempModel x, GroupTempModel y, int round, int hole)
{
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfo && p.PlayerInfoModel.Group == x.Group);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfo && p.PlayerInfoModel.Group == y.Group);
int total_x = 0;
foreach (var real_player in real_players_X)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round == null)
continue;
ScoreRealModel real_score = real_round.Scores.FirstOrDefault(p => p.Hole == hole);
if (real_score == null)
continue;
total_x += real_score.Strokes - real_score.Par;
}
int total_y = 0;
foreach (var real_player in real_players_Y)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round == null)
continue;
ScoreRealModel real_score = real_round.Scores.FirstOrDefault(p => p.Hole == hole);
if (real_score == null)
continue;
total_y += real_score.Strokes - real_score.Par;
}
if (total_x == total_y)
return 0;
else
return total_x < total_y ? -1 : 1;
}
}
}
...@@ -40,11 +40,16 @@ namespace VIZ.TVP.Golf.Domain ...@@ -40,11 +40,16 @@ namespace VIZ.TVP.Golf.Domain
public const string TeamInfo = "TeamInfo"; public const string TeamInfo = "TeamInfo";
/// <summary> /// <summary>
/// 组信息 /// 组信息
/// </summary> /// </summary>
public const string GroupInfo = "GroupInfo"; public const string GroupInfo = "GroupInfo";
/// <summary> /// <summary>
/// 分组具体洞信息
/// </summary>
public const string GroupInfoWithHole = "GroupInfoWithHole";
/// <summary>
/// 冠军版 /// 冠军版
/// </summary> /// </summary>
public const string Champion = "Champion"; public const string Champion = "Champion";
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -77,11 +78,12 @@ namespace VIZ.TVP.Golf.Domain ...@@ -77,11 +78,12 @@ namespace VIZ.TVP.Golf.Domain
#region Score -- 得分 #region Score -- 得分
private int score; private int? score;
/// <summary> /// <summary>
/// 得分 /// 得分
/// </summary> /// </summary>
public int Score [Obsolete]
public int? Score
{ {
get { return score; } get { return score; }
set { score = value; this.RaisePropertyChanged(nameof(Score)); } set { score = value; this.RaisePropertyChanged(nameof(Score)); }
...@@ -91,11 +93,12 @@ namespace VIZ.TVP.Golf.Domain ...@@ -91,11 +93,12 @@ namespace VIZ.TVP.Golf.Domain
#region Strokes -- 总杆数 #region Strokes -- 总杆数
private int strokes; private int? strokes;
/// <summary> /// <summary>
/// 总杆数 /// 总杆数
/// </summary> /// </summary>
public int Strokes [Obsolete]
public int? Strokes
{ {
get { return strokes; } get { return strokes; }
set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); } set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); }
......
...@@ -35,11 +35,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -35,11 +35,11 @@ namespace VIZ.TVP.Golf.Domain
#region TeeTime -- 开球时间 #region TeeTime -- 开球时间
private TimeSpan teeTime; private TimeSpan? teeTime;
/// <summary> /// <summary>
/// 开球时间 /// 开球时间
/// </summary> /// </summary>
public TimeSpan TeeTime public TimeSpan? TeeTime
{ {
get { return teeTime; } get { return teeTime; }
set { teeTime = value; this.RaisePropertyChanged(nameof(TeeTime)); } set { teeTime = value; this.RaisePropertyChanged(nameof(TeeTime)); }
...@@ -77,11 +77,12 @@ namespace VIZ.TVP.Golf.Domain ...@@ -77,11 +77,12 @@ namespace VIZ.TVP.Golf.Domain
#region Today -- 本轮(今日)杆数与标准杆的差值 #region Today -- 本轮(今日)杆数与标准杆的差值
private int today; private int? today;
/// <summary> /// <summary>
/// 本轮(今日)杆数与标准杆的差值 /// 本轮(今日)杆数与标准杆的差值
/// </summary> /// </summary>
public int Today [Obsolete]
public int? Today
{ {
get { return today; } get { return today; }
set { today = value; this.RaisePropertyChanged(nameof(Today)); } set { today = value; this.RaisePropertyChanged(nameof(Today)); }
...@@ -95,6 +96,7 @@ namespace VIZ.TVP.Golf.Domain ...@@ -95,6 +96,7 @@ namespace VIZ.TVP.Golf.Domain
/// <summary> /// <summary>
/// 本轮(进入)总杆数 /// 本轮(进入)总杆数
/// </summary> /// </summary>
[Obsolete]
public int Total public int Total
{ {
get { return total; } get { return total; }
......
...@@ -34,11 +34,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -34,11 +34,11 @@ namespace VIZ.TVP.Golf.Domain
#region Strokes -- 杆数 #region Strokes -- 杆数
private int strokes; private int? strokes;
/// <summary> /// <summary>
/// 杆数 /// 杆数
/// </summary> /// </summary>
public int Strokes public int? Strokes
{ {
get { return strokes; } get { return strokes; }
set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); } set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); }
...@@ -48,11 +48,12 @@ namespace VIZ.TVP.Golf.Domain ...@@ -48,11 +48,12 @@ namespace VIZ.TVP.Golf.Domain
#region Par -- 标准杆 #region Par -- 标准杆
private int par; private int? par;
/// <summary> /// <summary>
/// 标准杆 /// 标准杆
/// </summary> /// </summary>
public int Par [Obsolete]
public int? Par
{ {
get { return par; } get { return par; }
set { par = value; this.RaisePropertyChanged(nameof(Par)); } set { par = value; this.RaisePropertyChanged(nameof(Par)); }
...@@ -62,11 +63,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -62,11 +63,11 @@ namespace VIZ.TVP.Golf.Domain
#region Bunkers -- 沙滩救球数 #region Bunkers -- 沙滩救球数
private int bunkers; private int? bunkers;
/// <summary> /// <summary>
/// 沙滩救球数 /// 沙滩救球数
/// </summary> /// </summary>
public int Bunkers public int? Bunkers
{ {
get { return bunkers; } get { return bunkers; }
set { bunkers = value; this.RaisePropertyChanged(nameof(Bunkers)); } set { bunkers = value; this.RaisePropertyChanged(nameof(Bunkers)); }
...@@ -76,11 +77,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -76,11 +77,11 @@ namespace VIZ.TVP.Golf.Domain
#region Putts -- 推杆数 #region Putts -- 推杆数
private int putts; private int? putts;
/// <summary> /// <summary>
/// 推杆数 /// 推杆数
/// </summary> /// </summary>
public int Putts public int? Putts
{ {
get { return putts; } get { return putts; }
set { putts = value; this.RaisePropertyChanged(nameof(Putts)); } set { putts = value; this.RaisePropertyChanged(nameof(Putts)); }
...@@ -90,11 +91,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -90,11 +91,11 @@ namespace VIZ.TVP.Golf.Domain
#region Drive -- 开球距离 #region Drive -- 开球距离
private double drive; private double? drive;
/// <summary> /// <summary>
/// 开球距离 /// 开球距离
/// </summary> /// </summary>
public double Drive public double? Drive
{ {
get { return drive; } get { return drive; }
set { drive = value; this.RaisePropertyChanged(nameof(Drive)); } set { drive = value; this.RaisePropertyChanged(nameof(Drive)); }
...@@ -104,11 +105,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -104,11 +105,11 @@ namespace VIZ.TVP.Golf.Domain
#region Fairway -- 是否发球上球道 1: | 0: | : 未记录 #region Fairway -- 是否发球上球道 1: | 0: | : 未记录
private int fairway; private int? fairway;
/// <summary> /// <summary>
/// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录 /// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录
/// </summary> /// </summary>
public int Fairway public int? Fairway
{ {
get { return fairway; } get { return fairway; }
set { fairway = value; this.RaisePropertyChanged(nameof(Fairway)); } set { fairway = value; this.RaisePropertyChanged(nameof(Fairway)); }
......
...@@ -54,6 +54,20 @@ namespace VIZ.TVP.Golf.Domain ...@@ -54,6 +54,20 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region TotalScore -- 总得分
private string totalScore;
/// <summary>
/// 总得分
/// </summary>
public string TotalScore
{
get { return totalScore; }
set { totalScore = value; this.RaisePropertyChanged(nameof(TotalScore)); }
}
#endregion
#region TotalStrokesDetail -- 总杆数描述 #region TotalStrokesDetail -- 总杆数描述
private string totalStrokesDetail; private string totalStrokesDetail;
......
...@@ -55,16 +55,30 @@ namespace VIZ.TVP.Golf.Domain ...@@ -55,16 +55,30 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region Players -- 球员信息 #region Player1 -- 球员1
private ObservableCollection<PlayerInfoModel> players = new ObservableCollection<PlayerInfoModel>(); private PlayerInfoModel player1;
/// <summary> /// <summary>
/// 球员信息 /// 球员1
/// </summary> /// </summary>
public ObservableCollection<PlayerInfoModel> Players public PlayerInfoModel Player1
{ {
get { return players; } get { return player1; }
set { players = value; this.RaisePropertyChanged(nameof(Players)); } set { player1 = value; this.RaisePropertyChanged(nameof(Player1)); }
}
#endregion
#region Player2 -- 球员2
private PlayerInfoModel player2;
/// <summary>
/// 球员2
/// </summary>
public PlayerInfoModel Player2
{
get { return player2; }
set { player2 = value; this.RaisePropertyChanged(nameof(Player2)); }
} }
#endregion #endregion
......
...@@ -68,20 +68,6 @@ namespace VIZ.TVP.Golf.Domain ...@@ -68,20 +68,6 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region Score -- 得分
private int score;
/// <summary>
/// 得分
/// </summary>
public int Score
{
get { return score; }
set { score = value; this.RaisePropertyChanged(nameof(Score)); }
}
#endregion
/// <summary> /// <summary>
/// 从球员信息模型中获取数据 /// 从球员信息模型中获取数据
/// </summary> /// </summary>
......
...@@ -84,11 +84,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -84,11 +84,11 @@ namespace VIZ.TVP.Golf.Domain
#region TotalScoreValue -- 总得分值 #region TotalScoreValue -- 总得分值
private int totalScoreValue; private int? totalScoreValue;
/// <summary> /// <summary>
/// 总得分值 /// 总得分值
/// </summary> /// </summary>
public int TotalScoreValue public int? TotalScoreValue
{ {
get { return totalScoreValue; } get { return totalScoreValue; }
set { totalScoreValue = value; this.RaisePropertyChanged(nameof(TotalScoreValue)); } set { totalScoreValue = value; this.RaisePropertyChanged(nameof(TotalScoreValue)); }
...@@ -110,6 +110,48 @@ namespace VIZ.TVP.Golf.Domain ...@@ -110,6 +110,48 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region PositionOldIndex -- 排名之前的索引
private int positionOldIndex;
/// <summary>
/// 排名之前的索引
/// </summary>
public int PositionOldIndex
{
get { return positionOldIndex; }
set { positionOldIndex = value; this.RaisePropertyChanged(nameof(PositionOldIndex)); }
}
#endregion
#region PositionNewIndex -- 排名之后的索引
private int positionNewIndex;
/// <summary>
/// 排名之后的索引
/// </summary>
public int PositionNewIndex
{
get { return positionNewIndex; }
set { positionNewIndex = value; this.RaisePropertyChanged(nameof(PositionNewIndex)); }
}
#endregion
#region PositionChangedDesc -- 排名变化说明
private string positionChangedDesc;
/// <summary>
/// 排名变化说明
/// </summary>
public string PositionChangedDesc
{
get { return positionChangedDesc; }
set { positionChangedDesc = value; this.RaisePropertyChanged(nameof(PositionChangedDesc)); }
}
#endregion
/// <summary> /// <summary>
/// 从信息源初始化 /// 从信息源初始化
/// </summary> /// </summary>
......
...@@ -34,6 +34,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -34,6 +34,11 @@ namespace VIZ.TVP.Golf.Domain
public static ObservableCollection<string> Groups { get; set; } = new ObservableCollection<string>(); public static ObservableCollection<string> Groups { get; set; } = new ObservableCollection<string>();
/// <summary> /// <summary>
/// 包含空的分组
/// </summary>
public static ObservableCollection<string> GroupsWithNone { get; set; } = new ObservableCollection<string>();
/// <summary>
/// 轮次集合 /// 轮次集合
/// </summary> /// </summary>
public static ObservableCollection<int> Rounds { get; set; } = new ObservableCollection<int>(); public static ObservableCollection<int> Rounds { get; set; } = new ObservableCollection<int>();
...@@ -47,6 +52,21 @@ namespace VIZ.TVP.Golf.Domain ...@@ -47,6 +52,21 @@ namespace VIZ.TVP.Golf.Domain
/// 描述信息结合 /// 描述信息结合
/// </summary> /// </summary>
public static ObservableCollection<string> Details { get; set; } = new ObservableCollection<string>(); public static ObservableCollection<string> Details { get; set; } = new ObservableCollection<string>();
/// <summary>
/// 默认轮次
/// </summary>
public static int DEFAULT_ROUND = 2;
/// <summary>
/// 取前5组比赛成绩得分
/// </summary>
public static int DEFALUT_TOP_GROUP = 5;
/// <summary>
/// 队伍短板排名显示数量
/// </summary>
public static int DEFALUT_SHORT_TEAM_RANKING = 5;
} }
} }
...@@ -65,9 +65,6 @@ ...@@ -65,9 +65,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApplicationDomainEx.cs" /> <Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Comparer\GroupTempModelTopComparer.cs" />
<Compile Include="Comparer\GroupTempModelComparer.cs" />
<Compile Include="Comparer\TeamTempModelComparer.cs" />
<Compile Include="Enum\ViewKeys.cs" /> <Compile Include="Enum\ViewKeys.cs" />
<Compile Include="Model\EntityModel\HoleInfoModel.cs" /> <Compile Include="Model\EntityModel\HoleInfoModel.cs" />
<Compile Include="Model\EntityModel\PlayerInfoModel.cs" /> <Compile Include="Model\EntityModel\PlayerInfoModel.cs" />
......
...@@ -185,5 +185,8 @@ ...@@ -185,5 +185,8 @@
<ItemGroup> <ItemGroup>
<Resource Include="Icons\refresh_green_16x16.png" /> <Resource Include="Icons\refresh_green_16x16.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\contrast_16x16.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
ItemsSource="{Binding Source={x:Static domain:ApplicationDomainEx.TeamInfos}}" ItemsSource="{Binding Source={x:Static domain:ApplicationDomainEx.TeamInfos}}"
SelectedValueBinding="{Binding Path=TeamInfoModel}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=TeamInfoModel}"></DataGridComboBoxColumn>
<DataGridComboBoxColumn Header="分组" Width="60" <DataGridComboBoxColumn Header="分组" Width="60"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Groups}}" ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.GroupsWithNone}}"
SelectedValueBinding="{Binding Path=Group}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=Group}"></DataGridComboBoxColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
......
...@@ -58,6 +58,8 @@ ...@@ -58,6 +58,8 @@
Content="队伍信息"></RadioButton> Content="队伍信息"></RadioButton>
<RadioButton x:Name="rb_GroupInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_GroupInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="小组信息"></RadioButton> Content="小组信息"></RadioButton>
<RadioButton x:Name="rb_GroupInfoWithHole" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="赛中小组数据"></RadioButton>
<RadioButton x:Name="rb_Champion" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_Champion" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="冠军版"></RadioButton> Content="冠军版"></RadioButton>
<RadioButton x:Name="rb_GroupHoleInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_GroupHoleInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
...@@ -106,6 +108,8 @@ ...@@ -106,6 +108,8 @@
IsSelected="{Binding ElementName=rb_TeamInfo,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl> IsSelected="{Binding ElementName=rb_TeamInfo,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.GroupInfo}" ViewType="{x:Type local:GroupInfoView}" <fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.GroupInfo}" ViewType="{x:Type local:GroupInfoView}"
IsSelected="{Binding ElementName=rb_GroupInfo,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl> IsSelected="{Binding ElementName=rb_GroupInfo,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.GroupInfoWithHole}" ViewType="{x:Type local:GroupInfoWithHoleView}"
IsSelected="{Binding ElementName=rb_GroupInfoWithHole,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.Champion}" ViewType="{x:Type local:ChampionView}" <fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.Champion}" ViewType="{x:Type local:ChampionView}"
IsSelected="{Binding ElementName=rb_Champion,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl> IsSelected="{Binding ElementName=rb_Champion,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.GroupHoleInfo}" ViewType="{x:Type local:GroupHoleInfoView}" <fcommon:NavigationItemControl Key="{x:Static Member=domain:ViewKeys.GroupHoleInfo}" ViewType="{x:Type local:GroupHoleInfoView}"
......
...@@ -94,18 +94,19 @@ ...@@ -94,18 +94,19 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" <DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=GroupHoleTempModels}"> ItemsSource="{Binding Path=GroupHoleTempModels}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="编号" Width="100" Binding="{Binding Path=HoleID}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="编号(*)" Width="100" Binding="{Binding Path=HoleID}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="标准杆" Width="100" Binding="{Binding Path=Par}"></DataGridTextColumn> <DataGridTextColumn Header="标准杆(*)" Width="100" Binding="{Binding Path=Par}"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数" Width="100" Binding="{Binding Path=TotalStrokes}"></DataGridTextColumn> <DataGridTextColumn Header="总杆数(*)" Width="100" Binding="{Binding Path=TotalStrokes}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数描述" Width="200" Binding="{Binding Path=TotalStrokesDetail}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="总杆数描述" Width="200" Binding="{Binding Path=TotalStrokesDetail}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>
</GroupBox> </GroupBox>
<!-- 汇总 --> <!-- 总杆数汇总 -->
<GroupBox Padding="10" Grid.Row="3"> <GroupBox Padding="10" Grid.Row="3">
<GroupBox.Header> <GroupBox.Header>
<TextBlock Text="汇总" FontSize="18" FontWeight="Bold"></TextBlock> <TextBlock Text="总杆数汇总" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header> </GroupBox.Header>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
......
...@@ -6,8 +6,10 @@ using System.Text; ...@@ -6,8 +6,10 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media.Media3D;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
...@@ -45,7 +47,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -45,7 +47,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次 #region SelectedRound -- 选中的轮次
private int selectedRound; private int selectedRound = TvpStaticResource.DEFAULT_ROUND;
/// <summary> /// <summary>
/// 选中的轮次 /// 选中的轮次
/// </summary> /// </summary>
...@@ -237,8 +239,6 @@ namespace VIZ.TVP.Golf.Module ...@@ -237,8 +239,6 @@ namespace VIZ.TVP.Golf.Module
/// <param name="list">真实球员模型</param> /// <param name="list">真实球员模型</param>
private void UpdateGroupHoleTempModels(List<PlayerRealModel> list) private void UpdateGroupHoleTempModels(List<PlayerRealModel> list)
{ {
var players = ApplicationDomainEx.PlayerInfos.Where(p => p.Group == this.GroupPickerPanelModel.SelectedGroupInfo.Group && p.TeamID == this.GroupPickerPanelModel.SelectedGroupInfo.TeamInfo.TeamID);
ObservableCollection<GroupHoleTempModel> groupHoleTempModels = new ObservableCollection<GroupHoleTempModel>(); ObservableCollection<GroupHoleTempModel> groupHoleTempModels = new ObservableCollection<GroupHoleTempModel>();
if (this.SelectedRound == 0) if (this.SelectedRound == 0)
...@@ -249,32 +249,24 @@ namespace VIZ.TVP.Golf.Module ...@@ -249,32 +249,24 @@ namespace VIZ.TVP.Golf.Module
return; return;
} }
PlayerRealModel player1 = list.FirstOrDefault(p => this.GroupPickerPanelModel.SelectedGroupInfo.Player1.PlayerID == p.PlayerID);
PlayerRealModel player2 = list.FirstOrDefault(p => this.GroupPickerPanelModel.SelectedGroupInfo.Player2.PlayerID == p.PlayerID);
var dic = this.realDataService.GetGroupHoleStatisticsDataDic(this.GroupPickerPanelModel.SelectedGroupInfo.Group, player1, player2, this.SelectedRound);
foreach (HoleInfoModel holeInfo in ApplicationDomainEx.HoleInfos) foreach (HoleInfoModel holeInfo in ApplicationDomainEx.HoleInfos)
{ {
GroupHoleTempModel model = new GroupHoleTempModel(); GroupHoleTempModel model = new GroupHoleTempModel();
model.HoleID = holeInfo.HoleID.ToString(); model.HoleID = holeInfo.HoleID.ToString();
model.Par = holeInfo.Par; model.Par = holeInfo.Par;
int total = 0; if (!dic.TryGetValue(holeInfo.HoleID, out GroupHoleStatisticsData data))
foreach (PlayerInfoModel player in players)
{
PlayerRealModel player_real = list.FirstOrDefault(p => p.PlayerID == player.PlayerID);
if (player_real == null)
continue;
RoundRealModel round_real = player_real.Rounds.FirstOrDefault(p => p.No == this.SelectedRound);
if (round_real == null)
continue;
ScoreRealModel score_real = round_real.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
if (score_real == null)
continue; continue;
total += score_real.Strokes; model.TotalStrokes = data.Strokes.ToString();
model.TotalStrokesDetail += $"{player.Name}: {score_real.Strokes} | "; model.TotalScore = this.realDataService.GetScoreString(data.Score);
} model.TotalStrokesDetail = $"{data.Player1.Name}: {data.PlayerStrokes1} | {data.Player2.Name} : {data.PlayerStrokes2}";
model.TotalStrokes = total.ToString();
groupHoleTempModels.Add(model); groupHoleTempModels.Add(model);
} }
...@@ -285,8 +277,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -285,8 +277,7 @@ namespace VIZ.TVP.Golf.Module
this.Summary(); this.Summary();
// 更新其他信息 // 更新其他信息
this.GroupPickerPanelModel.UpdatePlayersScore(list, this.SelectedRound);
this.GroupPickerPanelModel.UpdatePlayersProperty();
} }
} }
} }
...@@ -46,23 +46,26 @@ ...@@ -46,23 +46,26 @@
<Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5"> <Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition> <RowDefinition Height="90"></RowDefinition>
<RowDefinition Height="80"></RowDefinition> <RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="220"></RowDefinition> <RowDefinition Height="220"></RowDefinition>
<RowDefinition Height="220"></RowDefinition> <RowDefinition Height="220"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 轮次 --> <!-- 轮次与洞号 -->
<GroupBox Padding="10" Grid.Row="0"> <GroupBox Padding="10" Grid.Row="0">
<GroupBox.Header> <GroupBox.Header>
<TextBlock Text="轮次信息" FontSize="18" FontWeight="Bold"></TextBlock> <TextBlock Text="轮次与洞号" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header> </GroupBox.Header>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="60"></ColumnDefinition> <ColumnDefinition Width="60"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="轮次:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="1"></TextBlock> <Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<!-- 轮次 -->
<TextBlock Text="轮次:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"></TextBlock>
<StackPanel Grid.Column="1" Margin="5,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel Grid.Column="1" Margin="5,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Width="240" VerticalContentAlignment="Center" <ComboBox Height="30" Width="240" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}" SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
...@@ -89,7 +92,7 @@ ...@@ -89,7 +92,7 @@
</ComboBox> </ComboBox>
<fcommon:IconButton Style="{StaticResource IconButton_Green}" VerticalAlignment="Center" HorizontalAlignment="Left" <fcommon:IconButton Style="{StaticResource IconButton_Green}" VerticalAlignment="Center" HorizontalAlignment="Left"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/presets_16x16.png" Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/presets_16x16.png"
Content="预设队伍" Grid.Column="1" Width="80" Height="30" Margin="5,0,0,0" Content="预设分组" Grid.Column="1" Width="80" Height="30" Margin="5,0,0,0"
Command="{Binding PresetGroupCommand}"></fcommon:IconButton> Command="{Binding PresetGroupCommand}"></fcommon:IconButton>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
<UserControl x:Class="VIZ.TVP.Golf.Module.GroupInfoWithHoleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.TVP.Golf.Module"
xmlns:core="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:domain="clr-namespace:VIZ.TVP.Golf.Domain;assembly=VIZ.TVP.Golf.Domain"
d:Background="White"
d:DataContext="{d:DesignInstance Type=local:GroupInfoViewModel}"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1600">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.TVP.Golf.Module.Resource;component/Style/IconButton/IconButton_Default.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<core:String2ImageSourceConverter x:Key="String2ImageSourceConverter" Type="Relative" WorkPath="picture/player"></core:String2ImageSourceConverter>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="600"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 版子操作 -->
<Border Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#44000000" Background="#66b6f2e3" BorderThickness="1" Margin="5" Padding="5">
<StackPanel Orientation="Horizontal">
<fcommon:IconButton Style="{StaticResource IconButton_Default}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/db_16x16.png"
Content="加载本地数据" Command="{Binding Path=LoadLocalDataCommand}"></fcommon:IconButton>
<fcommon:IconButton Style="{StaticResource IconButton_Default}" Margin="5,0,0,0"
IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
Content="刷新实时数据" Command="{Binding Path=LoadRemoteDataCommand}"></fcommon:IconButton>
</StackPanel>
</Border>
<!-- 版子信息 -->
<Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="140"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="220"></RowDefinition>
<RowDefinition Height="220"></RowDefinition>
</Grid.RowDefinitions>
<!-- 轮次与洞号 -->
<GroupBox Padding="10" Grid.Row="0">
<GroupBox.Header>
<TextBlock Text="轮次与洞号" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<!-- 轮次 -->
<TextBlock Text="轮次:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"></TextBlock>
<StackPanel Grid.Column="1" Margin="5,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Width="240" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Rounds}}"></ComboBox>
</StackPanel>
<!-- 洞号 -->
<TextBlock Text="洞号:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="2"></TextBlock>
<StackPanel Grid.Column="1" Grid.Row="1" Margin="5,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Width="240" VerticalContentAlignment="Center" DisplayMemberPath="HoleID"
SelectedValue="{Binding Path=SelectedHoleInfo,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:ApplicationDomainEx.HoleInfos}}"></ComboBox>
</StackPanel>
</Grid>
</GroupBox>
<!-- 预设 -->
<GroupBox Padding="10" Grid.Row="1">
<GroupBox.Header>
<TextBlock Text="预设" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- 预设 -->
<TextBlock Text="预设:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"></TextBlock>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<ComboBox Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" Width="240"
SelectedValue="{Binding Group,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Groups}}">
</ComboBox>
<fcommon:IconButton Style="{StaticResource IconButton_Green}" VerticalAlignment="Center" HorizontalAlignment="Left"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/presets_16x16.png"
Content="预设分组" Grid.Column="1" Width="80" Height="30" Margin="5,0,0,0"
Command="{Binding PresetGroupCommand}"></fcommon:IconButton>
</StackPanel>
</Grid>
</GroupBox>
<!-- 分组1 -->
<GroupBox Grid.Row="2" Padding="10">
<GroupBox.Header>
<TextBlock Text="分组1" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel1}"></local:GroupPickerPanelNoPlayer>
</GroupBox>
<!-- 分组2 -->
<GroupBox Grid.Row="3" Padding="10">
<GroupBox.Header>
<TextBlock Text="分组2" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel2}"></local:GroupPickerPanelNoPlayer>
</GroupBox>
</Grid>
</Border>
<!-- 示意图 -->
<Border Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="300"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="pack://SiteOfOrigin:,,,/images/GroupInfo.jpg" />
<StackPanel Orientation="Horizontal" Grid.Row="1">
<fcommon:IconButton Style="{StaticResource IconButton_Red}" Margin="10,0,0,0"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/up_16x16.png"
Content="上版子"></fcommon:IconButton>
<fcommon:IconButton Style="{StaticResource IconButton_Red}" Margin="10,0,0,0"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/down_16x16.png"
Content="下版子"></fcommon:IconButton>
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.TVP.Golf.Module
{
/// <summary>
/// GroupInfoWithHoleView.xaml 的交互逻辑
/// </summary>
public partial class GroupInfoWithHoleView : UserControl
{
public GroupInfoWithHoleView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new GroupInfoWithHoleViewModel());
}
}
}
...@@ -3,6 +3,7 @@ using System.Collections.Generic; ...@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.WebSockets;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
...@@ -34,7 +35,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,7 +35,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次 #region SelectedRound -- 选中的轮次
private int selectedRound; private int selectedRound = 2;
/// <summary> /// <summary>
/// 选中的轮次 /// 选中的轮次
/// </summary> /// </summary>
...@@ -127,13 +128,8 @@ namespace VIZ.TVP.Golf.Module ...@@ -127,13 +128,8 @@ namespace VIZ.TVP.Golf.Module
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName); List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, this.SelectedRound, list); this.GroupPickerPanelModel1.UpdatePlayersScore(list, this.SelectedRound);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, this.SelectedRound, list); this.GroupPickerPanelModel2.UpdatePlayersScore(list, this.SelectedRound);
this.GroupPickerPanelModel1.UpdatePlayersProperty();
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, this.SelectedRound, list);
this.GroupPickerPanelModel2.UpdatePlayersProperty();
} }
#endregion #endregion
...@@ -160,11 +156,6 @@ namespace VIZ.TVP.Golf.Module ...@@ -160,11 +156,6 @@ namespace VIZ.TVP.Golf.Module
{ {
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName); List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, this.SelectedRound, list);
}); });
}); });
} }
...@@ -193,11 +184,13 @@ namespace VIZ.TVP.Golf.Module ...@@ -193,11 +184,13 @@ namespace VIZ.TVP.Golf.Module
{ {
var team = teams[0]; var team = teams[0];
GroupTempModel model = new GroupTempModel(); GroupTempModel model = new GroupTempModel();
model.Group = this.group;
model.TeamInfo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team.Key); model.TeamInfo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team.Key);
foreach (var player in team) var players = team.ToList();
if (players.Count == 2)
{ {
model.Players.Add(player); model.Player1 = players[0];
} model.Player2 = players[1];
this.GroupPickerPanelModel1.UpdateByGroupTempModel(model); this.GroupPickerPanelModel1.UpdateByGroupTempModel(model);
} }
...@@ -205,15 +198,29 @@ namespace VIZ.TVP.Golf.Module ...@@ -205,15 +198,29 @@ namespace VIZ.TVP.Golf.Module
{ {
this.GroupPickerPanelModel1.ClearProperty(); this.GroupPickerPanelModel1.ClearProperty();
} }
}
else
{
this.GroupPickerPanelModel1.ClearProperty();
}
if (teams.Count > 1) if (teams.Count > 1)
{ {
var team = teams[1]; var team = teams[1];
GroupTempModel model = new GroupTempModel(); GroupTempModel model = new GroupTempModel();
model.Group = this.group;
model.TeamInfo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team.Key); model.TeamInfo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team.Key);
foreach (var player in team) var players = team.ToList();
if (players.Count == 2)
{ {
model.Players.Add(player); model.Player1 = players[0];
model.Player2 = players[1];
this.GroupPickerPanelModel2.UpdateByGroupTempModel(model);
}
else
{
this.GroupPickerPanelModel2.ClearProperty();
} }
this.GroupPickerPanelModel2.UpdateByGroupTempModel(model); this.GroupPickerPanelModel2.UpdateByGroupTempModel(model);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.WebSockets;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Module
{
/// <summary>
/// 包装视图模型 -- 小组信息 -- 指定洞
/// </summary>
public class GroupInfoWithHoleViewModel : GroupInfoViewModel
{
public GroupInfoWithHoleViewModel()
{
}
// ===================================================================================
// Property
// ===================================================================================
#region SelectedHoleInfo -- 当前选择的洞
private HoleInfoModel selectedHoleInfo = ApplicationDomainEx.HoleInfos.FirstOrDefault();
/// <summary>
/// 当前选择的洞
/// </summary>
public HoleInfoModel SelectedHoleInfo
{
get { return selectedHoleInfo; }
set { selectedHoleInfo = value; this.RaisePropertyChanged(nameof(SelectedHoleInfo)); }
}
#endregion
// ===================================================================================
// Command
// ===================================================================================
// ===================================================================================
// Command
// ===================================================================================
#region SendCommand -- 发送命令
/// <summary>
/// 执行发送命令
/// </summary>
protected override void Send()
{
}
#endregion
#region LoadLocalDataCommand -- 加载本地数据命令
/// <summary>
/// 加载本地数据
/// </summary>
protected override void LoadLocalData()
{
RealDataWindow window = new RealDataWindow();
window.ShowDialog();
RealDataViewModel vm = window.realDataView.DataContext as RealDataViewModel;
if (vm == null)
return;
if (!vm.IsEnter)
return;
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.GroupPickerPanelModel1.UpdatePlayersScore(list, this.SelectedRound, this.SelectedHoleInfo.HoleID);
this.GroupPickerPanelModel2.UpdatePlayersScore(list, this.SelectedRound, this.SelectedHoleInfo.HoleID);
}
#endregion
#region LoadRemoteDataCommand -- 加载远程数据命令
/// <summary>
/// 加载远程数据
/// </summary>
protected override void LoadRemoteData()
{
Task.Run(() =>
{
string fileName = this.realDataService.DownLoadData(INTERFACE_TOURNAMENT);
if (string.IsNullOrWhiteSpace(fileName))
{
MessageBox.Show("加载远程数据失败!");
return;
}
WPFHelper.BeginInvoke(() =>
{
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName);
});
});
}
#endregion
}
}
...@@ -35,7 +35,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -35,7 +35,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次 #region SelectedRound -- 选中的轮次
private int selectedRound; private int selectedRound = 2;
/// <summary> /// <summary>
/// 选中的轮次信息 /// 选中的轮次信息
/// </summary> /// </summary>
...@@ -126,30 +126,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -126,30 +126,7 @@ namespace VIZ.TVP.Golf.Module
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected virtual void UpdateGroupTempModels(List<PlayerRealModel> list) protected virtual void UpdateGroupTempModels(List<PlayerRealModel> list)
{ {
ObservableCollection<GroupTempModel> groupTempModels = new ObservableCollection<GroupTempModel>();
var groups = ApplicationDomainEx.PlayerInfos.GroupBy(p => p.Group);
foreach (var group in groups)
{
foreach (var team_group in group.GroupBy(p => p.TeamID))
{
GroupTempModel temp_model = new GroupTempModel();
temp_model.Group = group.Key;
foreach (PlayerInfoModel player in team_group)
{
temp_model.Players.Add(player);
}
temp_model.PlayersDisplayName = string.Join(" / ", temp_model.Players.Select(p => p.Name));
List<int> player_ids = temp_model.Players.Select(p => p.PlayerID).ToList();
temp_model.PlayersScore = list.Where(p => player_ids.Contains(p.PlayerID)).Sum(p => p.Score).ToString();
temp_model.TeamLogo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team_group.Key)?.Logo;
groupTempModels.Add(temp_model);
}
}
this.GroupTempModels = groupTempModels;
} }
} }
} }
...@@ -133,36 +133,5 @@ namespace VIZ.TVP.Golf.Module ...@@ -133,36 +133,5 @@ namespace VIZ.TVP.Golf.Module
// Action // Action
// =================================================================================== // ===================================================================================
/// <summary>
/// 更新球员临时数据
/// </summary>
/// <param name="tempModel">临时模型</param>
/// <param name="round">轮次</param>
/// <param name="realModels">实时模型集合</param>
protected void UpdatePlayerTempModel(PlayerTempModel tempModel, int round, List<PlayerRealModel> realModels)
{
if (tempModel == null || realModels == null || tempModel.PlayerID <= 0 || realModels.Count == 0)
return;
PlayerRealModel realModel = realModels.FirstOrDefault(p => p.PlayerID == tempModel.PlayerID);
if (realModel == null)
return;
RoundRealModel roundModel = realModel.Rounds.FirstOrDefault(p => p.No == round);
if (roundModel == null)
return;
tempModel.Score = roundModel.Today;
}
/// <summary>
/// 获取得分字符串
/// </summary>
/// <param name="score">得分</param>
/// <returns>得分字符串</returns>
protected string GetScoreString(int score)
{
return score == 0 ? "E" : (score > 0 ? $"+{score}" : $"-{score}");
}
} }
} }
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" <DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}"> ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn> <DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240" <DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240"
......
...@@ -7,6 +7,7 @@ using System.Threading.Tasks; ...@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
...@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module ...@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module
// =================================================================================== // ===================================================================================
/// <summary> /// <summary>
/// 更新队伍临时模型 /// 获取队伍临时模型集合
/// </summary> /// </summary>
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected override void UpdateTeamTempModels(List<PlayerRealModel> list) /// <returns>队伍临时模型集合</returns>
protected override ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list)
{ {
List<TeamTempModel> teamTempModels = new List<TeamTempModel>(); List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
...@@ -47,18 +49,23 @@ namespace VIZ.TVP.Golf.Module ...@@ -47,18 +49,23 @@ namespace VIZ.TVP.Golf.Module
TeamTempModel temp_model = new TeamTempModel(); TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model); temp_model.FromInfoModel(info_model);
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList(); TeamRoundStatisticsData data1 = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, 1);
TeamRoundStatisticsData data2 = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, 1);
if (data1 != null && data2 != null)
{
temp_model.TotalScoreValue = data1.Score + data2.Score;
temp_model.TotalScore = this.realDataService.GetScoreString(data1.Score + data2.Score);
}
int total = real_players.Sum(p => p.Score);
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model); teamTempModels.Add(temp_model);
} }
// 赛后比较所有的轮次 // 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list); TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer); teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
this.TeamTempModels = teamTempModels.ToObservableCollection(); return teamTempModels.ToObservableCollection();
} }
} }
} }
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" <DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}"> ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn> <DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240" <DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240"
......
...@@ -7,6 +7,7 @@ using System.Threading.Tasks; ...@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
...@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module ...@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module
// =================================================================================== // ===================================================================================
/// <summary> /// <summary>
/// 更新队伍临时模型 /// 获取队伍临时模型集合
/// </summary> /// </summary>
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected override void UpdateTeamTempModels(List<PlayerRealModel> list) /// <returns>队伍临时模型集合</returns>
protected override ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list)
{ {
List<TeamTempModel> teamTempModels = new List<TeamTempModel>(); List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
...@@ -47,27 +49,22 @@ namespace VIZ.TVP.Golf.Module ...@@ -47,27 +49,22 @@ namespace VIZ.TVP.Golf.Module
TeamTempModel temp_model = new TeamTempModel(); TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model); temp_model.FromInfoModel(info_model);
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList(); TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, 1);
if (data != null)
int total = 0;
foreach (PlayerRealModel real_player in real_players)
{ {
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == 1); temp_model.TotalScoreValue = data.Score;
if (real_round == null) temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
continue;
total += real_round.Today;
} }
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model); teamTempModels.Add(temp_model);
} }
// 赛前比较第一轮 // 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1); TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer); teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
this.TeamTempModels = teamTempModels.ToObservableCollection(); return teamTempModels.ToObservableCollection();
} }
} }
} }
...@@ -41,6 +41,14 @@ ...@@ -41,6 +41,14 @@
IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}" IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
Content="刷新实时数据" Command="{Binding Path=LoadRemoteDataCommand}"></fcommon:IconButton> Content="刷新实时数据" Command="{Binding Path=LoadRemoteDataCommand}"></fcommon:IconButton>
<Rectangle Width="2" Margin="10,0,10,0" Height="30" Fill="#44000000"></Rectangle>
<fcommon:IconButton Style="{StaticResource IconButton_Default}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/contrast_16x16.png"
Content="加载对比数据" Command="{Binding Path=LoadContrastDataCommand}"></fcommon:IconButton>
<fcommon:IconButton Style="{StaticResource IconButton_Default}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_green_16x16.png" Margin="5,0,0,0"
Content="根据界面值刷新索引变化" Command="{Binding Path=RefreshIndexChangedCommand}"></fcommon:IconButton>
</StackPanel> </StackPanel>
</Border> </Border>
<!-- 版子信息 --> <!-- 版子信息 -->
...@@ -78,21 +86,39 @@ ...@@ -78,21 +86,39 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition> <ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" <Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
VerticalAlignment="Top" Margin="0,5,0,0"></Image> VerticalAlignment="Top" Margin="0,30,0,0"></Image>
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
<!-- 实时数据 -->
<GroupBox Header="实时数据" Grid.Column="1" Padding="10" Margin="0,0,5,0">
<DataGrid AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}"> ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="排名(*)" Width="60" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称(*)" Width="120" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn> <DataGridTextColumn Header="得分(*)" Width="80" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn Header="Logo" Width="240" <DataGridTextColumn Header="之前索引" Width="60" Binding="{Binding Path=PositionOldIndex}"></DataGridTextColumn>
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" <DataGridTextColumn Header="之后索引" Width="60" Binding="{Binding Path=PositionNewIndex}"></DataGridTextColumn>
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> <DataGridTextColumn Header="索引变化" Width="80" Binding="{Binding Path=PositionChangedDesc}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</GroupBox>
<!-- 对比数据 -->
<GroupBox Header="对比数据" Grid.Column="2" Padding="10" Margin="5,0,0,0">
<DataGrid Grid.Column="2" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=ContrastTeamTempModels}" Margin="5,0,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="60" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="120" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="80" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</GroupBox>
</Grid> </Grid>
</GroupBox> </GroupBox>
......
...@@ -7,13 +7,14 @@ using System.Threading.Tasks; ...@@ -7,13 +7,14 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
/// <summary> /// <summary>
/// 包装视图模型 -- 板球队排名 /// 包装视图模型 -- 板球队排名
/// </summary> /// </summary>
public class LongTeamRankingViewModel : TeamRankingViewModelBase public class LongTeamRankingViewModel : TeamRankingConstrrastViewModelBase
{ {
public LongTeamRankingViewModel() public LongTeamRankingViewModel()
{ {
...@@ -33,5 +34,36 @@ namespace VIZ.TVP.Golf.Module ...@@ -33,5 +34,36 @@ namespace VIZ.TVP.Golf.Module
// Private Function // Private Function
// =================================================================================== // ===================================================================================
/// <summary>
/// 获取队伍临时模型集合
/// </summary>
/// <param name="list">球员真实模型</param>
/// <returns>队伍临时模型集合</returns>
protected override ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list)
{
List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos)
{
TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model);
TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, this.SelectedRound);
if (data != null)
{
temp_model.TotalScoreValue = data.Score;
temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
}
teamTempModels.Add(temp_model);
}
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
return teamTempModels.ToObservableCollection();
}
} }
} }
...@@ -41,6 +41,14 @@ ...@@ -41,6 +41,14 @@
IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}" IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
Content="刷新实时数据" Command="{Binding Path=LoadRemoteDataCommand}"></fcommon:IconButton> Content="刷新实时数据" Command="{Binding Path=LoadRemoteDataCommand}"></fcommon:IconButton>
<Rectangle Width="2" Margin="10,0,10,0" Height="30" Fill="#44000000"></Rectangle>
<fcommon:IconButton Style="{StaticResource IconButton_Default}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/contrast_16x16.png"
Content="加载对比数据" Command="{Binding Path=LoadContrastDataCommand}"></fcommon:IconButton>
<fcommon:IconButton Style="{StaticResource IconButton_Default}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_green_16x16.png" Margin="5,0,0,0"
Content="根据界面值刷新索引变化" Command="{Binding Path=RefreshIndexChangedCommand}"></fcommon:IconButton>
</StackPanel> </StackPanel>
</Border> </Border>
<!-- 版子信息 --> <!-- 版子信息 -->
...@@ -78,21 +86,39 @@ ...@@ -78,21 +86,39 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition> <ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" <Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
VerticalAlignment="Top" Margin="0,5,0,0"></Image> VerticalAlignment="Top" Margin="0,30,0,0"></Image>
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
<!-- 实时数据 -->
<GroupBox Header="实时数据" Grid.Column="1" Padding="10" Margin="0,0,5,0">
<DataGrid AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}"> ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="排名(*)" Width="60" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称(*)" Width="120" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn> <DataGridTextColumn Header="得分(*)" Width="80" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240" <DataGridTextColumn Header="之前索引" Width="60" Binding="{Binding Path=PositionOldIndex}"></DataGridTextColumn>
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" <DataGridTextColumn Header="之后索引" Width="60" Binding="{Binding Path=PositionNewIndex}"></DataGridTextColumn>
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> <DataGridTextColumn Header="索引变化" Width="80" Binding="{Binding Path=PositionChangedDesc}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</GroupBox>
<!-- 对比数据 -->
<GroupBox Header="对比数据" Grid.Column="2" Padding="10" Margin="5,0,0,0">
<DataGrid Grid.Column="2" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=ContrastTeamTempModels}" Margin="5,0,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="60" Binding="{Binding Path=Position}"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="120" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="80" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</GroupBox>
</Grid> </Grid>
</GroupBox> </GroupBox>
......
...@@ -7,13 +7,14 @@ using System.Threading.Tasks; ...@@ -7,13 +7,14 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
/// <summary> /// <summary>
/// 包装视图模型 -- 短板球队排名 /// 包装视图模型 -- 短板球队排名
/// </summary> /// </summary>
public class ShortTeamRankingViewModel : TeamRankingViewModelBase public class ShortTeamRankingViewModel : TeamRankingConstrrastViewModelBase
{ {
public ShortTeamRankingViewModel() public ShortTeamRankingViewModel()
{ {
...@@ -24,7 +25,6 @@ namespace VIZ.TVP.Golf.Module ...@@ -24,7 +25,6 @@ namespace VIZ.TVP.Golf.Module
// Property // Property
// =================================================================================== // ===================================================================================
// =================================================================================== // ===================================================================================
// Command // Command
// =================================================================================== // ===================================================================================
...@@ -34,10 +34,11 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,10 +34,11 @@ namespace VIZ.TVP.Golf.Module
// =================================================================================== // ===================================================================================
/// <summary> /// <summary>
/// 更新队伍临时模型 /// 获取队伍临时模型集合
/// </summary> /// </summary>
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected override void UpdateTeamTempModels(List<PlayerRealModel> list) /// <returns>队伍临时模型集合</returns>
protected override ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list)
{ {
List<TeamTempModel> teamTempModels = new List<TeamTempModel>(); List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
...@@ -46,26 +47,22 @@ namespace VIZ.TVP.Golf.Module ...@@ -46,26 +47,22 @@ namespace VIZ.TVP.Golf.Module
TeamTempModel temp_model = new TeamTempModel(); TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model); temp_model.FromInfoModel(info_model);
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList(); TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, this.SelectedRound);
if (data != null)
int total = 0;
foreach (PlayerRealModel real_player in real_players)
{ {
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.SelectedRound); temp_model.TotalScoreValue = data.Score;
if (real_round == null) temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
continue;
total += real_round.Today;
} }
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model); teamTempModels.Add(temp_model);
} }
TeamTempModelComparer comparer = new TeamTempModelComparer(list, this.SelectedRound); // 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer); teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
this.TeamTempModels = teamTempModels.Take(5).ToObservableCollection(); return teamTempModels.Take(TvpStaticResource.DEFALUT_SHORT_TEAM_RANKING).ToObservableCollection();
} }
} }
} }
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module
{
/// <summary>
/// 包装视图模型 -- 球队排名包含对比
/// </summary>
public abstract class TeamRankingConstrrastViewModelBase : TeamRankingViewModelBase
{
public TeamRankingConstrrastViewModelBase()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadContrastDataCommand = new VCommand(this.LoadContrastData);
this.RefreshIndexChangedCommand = new VCommand(RefreshIndexChanged);
}
// ===================================================================================
// Property
// ===================================================================================
#region ContrastTeamTempModels -- 对比队伍临时模型集合
private ObservableCollection<TeamTempModel> contrastTeamTempModels;
/// <summary>
/// 对比队伍临时模型集合
/// </summary>
public ObservableCollection<TeamTempModel> ContrastTeamTempModels
{
get { return contrastTeamTempModels; }
set { contrastTeamTempModels = value; this.RaisePropertyChanged(nameof(ContrastTeamTempModels)); }
}
#endregion
// ===================================================================================
// Command
// ===================================================================================
#region LoadContrastDataCommand -- 加载对比数据命令
/// <summary>
/// 加载对比数据命令
/// </summary>
public VCommand LoadContrastDataCommand { get; set; }
/// <summary>
/// 加载对比数据
/// </summary>
private void LoadContrastData()
{
RealDataWindow window = new RealDataWindow();
window.ShowDialog();
RealDataViewModel vm = window.realDataView.DataContext as RealDataViewModel;
if (vm == null)
return;
if (!vm.IsEnter)
return;
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.ContrastTeamTempModels = this.GetTeamTempModels(list);
this.realDataService.UpdateTeamPositionChanged(this.ContrastTeamTempModels, this.TeamTempModels);
}
#endregion
#region RefreshIndexChangedCommand -- 刷新索引变化命令
/// <summary>
/// 刷新索引变化命令
/// </summary>
public VCommand RefreshIndexChangedCommand { get; set; }
/// <summary>
/// 刷新索引变化
/// </summary>
private void RefreshIndexChanged()
{
foreach (TeamTempModel team in this.TeamTempModels)
{
team.PositionChangedDesc = $"{team.PositionOldIndex} --> {team.PositionNewIndex}";
}
}
#endregion
// ===================================================================================
// Private Function
// ===================================================================================
/// <summary>
/// 获取队伍临时模型集合
/// </summary>
/// <param name="list">球员真实模型</param>
/// <returns>队伍临时模型集合</returns>
protected override ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list)
{
List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos)
{
TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model);
TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, this.SelectedRound);
if (data != null)
{
temp_model.TotalScoreValue = data.Score;
temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
}
teamTempModels.Add(temp_model);
}
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
return teamTempModels.Take(TvpStaticResource.DEFALUT_SHORT_TEAM_RANKING).ToObservableCollection();
}
}
}
...@@ -8,6 +8,7 @@ using System.Threading.Tasks; ...@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
...@@ -23,7 +24,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -23,7 +24,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次 #region SelectedRound -- 选中的轮次
private int selectedRound; private int selectedRound = 2;
/// <summary> /// <summary>
/// 选中的轮次信息 /// 选中的轮次信息
/// </summary> /// </summary>
...@@ -84,7 +85,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -84,7 +85,7 @@ namespace VIZ.TVP.Golf.Module
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName); List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.UpdateTeamTempModels(list); this.TeamTempModels = this.GetTeamTempModels(list);
} }
#endregion #endregion
...@@ -111,7 +112,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -111,7 +112,7 @@ namespace VIZ.TVP.Golf.Module
{ {
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName); List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName);
this.UpdateTeamTempModels(list); this.TeamTempModels = this.GetTeamTempModels(list);
}); });
}); });
} }
...@@ -123,38 +124,10 @@ namespace VIZ.TVP.Golf.Module ...@@ -123,38 +124,10 @@ namespace VIZ.TVP.Golf.Module
// =================================================================================== // ===================================================================================
/// <summary> /// <summary>
/// 更新队伍临时模型 /// 获取队伍临时模型集合
/// </summary> /// </summary>
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected virtual void UpdateTeamTempModels(List<PlayerRealModel> list) /// <returns>队伍临时模型集合</returns>
{ protected abstract ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list);
List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos)
{
TeamTempModel temp_model = new TeamTempModel();
temp_model.FromInfoModel(info_model);
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList();
int total = 0;
foreach (PlayerRealModel real_player in real_players)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.SelectedRound);
if (real_round == null)
continue;
total += real_round.Today;
}
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
}
TeamTempModelComparer comparer = new TeamTempModelComparer(list, this.SelectedRound);
teamTempModels.Sort(comparer);
this.TeamTempModels = teamTempModels.ToObservableCollection();
}
} }
} }
\ No newline at end of file
...@@ -122,12 +122,17 @@ namespace VIZ.TVP.Golf.Module ...@@ -122,12 +122,17 @@ namespace VIZ.TVP.Golf.Module
private void InitGroups() private void InitGroups()
{ {
ObservableCollection<string> groups = new ObservableCollection<string>(); ObservableCollection<string> groups = new ObservableCollection<string>();
ObservableCollection<string> groupsWithNone = new ObservableCollection<string>();
groupsWithNone.Add(string.Empty);
for (int i = 1; i <= 18; i++) for (int i = 1; i <= 18; i++)
{ {
groups.Add(i.ToString()); groups.Add(i.ToString());
groupsWithNone.Add(i.ToString());
} }
TvpStaticResource.Groups = groups; TvpStaticResource.Groups = groups;
TvpStaticResource.GroupsWithNone = groupsWithNone;
} }
/// <summary> /// <summary>
......
...@@ -93,6 +93,10 @@ ...@@ -93,6 +93,10 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Package\GroupInfo\View\GroupInfoWithHoleView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Package\GroupRanking\LongGroupRanking\View\LongGroupRankingView.xaml"> <Page Include="Package\GroupRanking\LongGroupRanking\View\LongGroupRankingView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -211,6 +215,10 @@ ...@@ -211,6 +215,10 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Package\GroupInfo\ViewModel\GroupInfoWithHoleViewModel.cs" />
<Compile Include="Package\GroupInfo\View\GroupInfoWithHoleView.xaml.cs">
<DependentUpon>GroupInfoWithHoleView.xaml</DependentUpon>
</Compile>
<Compile Include="Package\GroupRanking\LongGroupRanking\ViewModel\LongGroupRankingViewModel.cs" /> <Compile Include="Package\GroupRanking\LongGroupRanking\ViewModel\LongGroupRankingViewModel.cs" />
<Compile Include="Package\GroupRanking\LongGroupRanking\View\LongGroupRankingView.xaml.cs"> <Compile Include="Package\GroupRanking\LongGroupRanking\View\LongGroupRankingView.xaml.cs">
<DependentUpon>LongGroupRankingView.xaml</DependentUpon> <DependentUpon>LongGroupRankingView.xaml</DependentUpon>
...@@ -232,6 +240,7 @@ ...@@ -232,6 +240,7 @@
<Compile Include="Package\TeamRanking\LongTeamRanking\View\LongTeamRankingView.xaml.cs"> <Compile Include="Package\TeamRanking\LongTeamRanking\View\LongTeamRankingView.xaml.cs">
<DependentUpon>LongTeamRankingView.xaml</DependentUpon> <DependentUpon>LongTeamRankingView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Package\TeamRanking\TeamRankingConstrrastViewModelBase.cs" />
<Compile Include="Package\TeamRanking\ShortTeamRanking\ViewModel\ShortTeamRankingViewModel.cs" /> <Compile Include="Package\TeamRanking\ShortTeamRanking\ViewModel\ShortTeamRankingViewModel.cs" />
<Compile Include="Package\TeamRanking\ShortTeamRanking\View\ShortTeamRankingView.xaml.cs"> <Compile Include="Package\TeamRanking\ShortTeamRanking\View\ShortTeamRankingView.xaml.cs">
<DependentUpon>ShortTeamRankingView.xaml</DependentUpon> <DependentUpon>ShortTeamRankingView.xaml</DependentUpon>
......
...@@ -6,6 +6,7 @@ using System.Threading.Tasks; ...@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.Web.UI.HtmlControls; using System.Web.UI.HtmlControls;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain; using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module namespace VIZ.TVP.Golf.Module
{ {
...@@ -134,6 +135,15 @@ namespace VIZ.TVP.Golf.Module ...@@ -134,6 +135,15 @@ namespace VIZ.TVP.Golf.Module
#endregion #endregion
// =================================================================================== // ===================================================================================
// Field
// ===================================================================================
/// <summary>
/// 真实数据服务
/// </summary>
private IRealDataService realDataService = new RealDataService();
// ===================================================================================
// Command // Command
// =================================================================================== // ===================================================================================
...@@ -178,28 +188,26 @@ namespace VIZ.TVP.Golf.Module ...@@ -178,28 +188,26 @@ namespace VIZ.TVP.Golf.Module
if (groupTempModel == null) if (groupTempModel == null)
return; return;
this.SelectedGroupInfo = groupTempModel;
this.Name = groupTempModel.TeamInfo.Name; this.Name = groupTempModel.TeamInfo.Name;
this.Logo = groupTempModel.TeamInfo.Logo; this.Logo = groupTempModel.TeamInfo.Logo;
this.PlayersScore = groupTempModel.PlayersScore;
if (groupTempModel.Players.Count > 0) if (groupTempModel.Player1 != null)
{ {
PlayerInfoModel player = groupTempModel.Players[0]; this.Player1.PlayerID = groupTempModel.Player1.PlayerID;
this.Player1.Name = groupTempModel.Player1.Name;
this.Player1.PlayerID = player.PlayerID; this.Player1.HalfPicture = groupTempModel.Player1.HalfPicture;
this.Player1.Name = player.Name;
this.Player1.HalfPicture = player.HalfPicture;
} }
if (groupTempModel.Players.Count > 1) if (groupTempModel.Player2 != null)
{ {
PlayerInfoModel player = groupTempModel.Players[1]; this.player2.PlayerID = groupTempModel.Player2.PlayerID;
this.Player2.Name = groupTempModel.Player2.Name;
this.player2.PlayerID = player.PlayerID; this.Player2.HalfPicture = groupTempModel.Player2.HalfPicture;
this.Player2.Name = player.Name;
this.Player2.HalfPicture = player.HalfPicture;
} }
this.UpdatePlayersProperty(); this.UpdatePlayersDisplayName();
} }
/// <summary> /// <summary>
...@@ -213,12 +221,10 @@ namespace VIZ.TVP.Golf.Module ...@@ -213,12 +221,10 @@ namespace VIZ.TVP.Golf.Module
this.Player1.PlayerID = 0; this.Player1.PlayerID = 0;
this.Player1.Name = null; this.Player1.Name = null;
this.Player1.HalfPicture = null; this.Player1.HalfPicture = null;
this.Player1.Score = 0;
this.Player2.PlayerID = 0; this.Player2.PlayerID = 0;
this.Player2.Name = null; this.Player2.Name = null;
this.Player2.HalfPicture = null; this.Player2.HalfPicture = null;
this.Player2.Score = 0;
this.PlayersDisplayName = null; this.PlayersDisplayName = null;
this.PlayersScore = null; this.PlayersScore = null;
...@@ -227,7 +233,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -227,7 +233,7 @@ namespace VIZ.TVP.Golf.Module
/// <summary> /// <summary>
/// 更新球员集合属性 /// 更新球员集合属性
/// </summary> /// </summary>
public void UpdatePlayersProperty() public void UpdatePlayersDisplayName()
{ {
// 组成员 // 组成员
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -244,10 +250,45 @@ namespace VIZ.TVP.Golf.Module ...@@ -244,10 +250,45 @@ namespace VIZ.TVP.Golf.Module
} }
this.PlayersDisplayName = sb.ToString(); this.PlayersDisplayName = sb.ToString();
}
/// <summary>
/// 更新得分
/// </summary>
/// <param name="list">真实数据</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞号</param>
public void UpdatePlayersScore(List<PlayerRealModel> list, int round, int hole)
{
if (list == null)
return;
PlayerRealModel player1 = list.FirstOrDefault(p => p.PlayerID == this.Player1.PlayerID);
PlayerRealModel player2 = list.FirstOrDefault(p => p.PlayerID == this.Player2.PlayerID);
GroupHoleStatisticsData data = this.realDataService.GetGroupHoleStatisticsData(this.SelectedGroupInfo.Group, player1, player2, round, hole);
if (data == null)
return;
this.PlayersScore = this.realDataService.GetScoreString(data.Score);
}
/// <summary>
/// 更新得分
/// </summary>
/// <param name="list">真实数据</param>
/// <param name="round">轮次</param>
public void UpdatePlayersScore(List<PlayerRealModel> list, int round)
{
if (list == null)
return;
PlayerRealModel player1 = list.FirstOrDefault(p => p.PlayerID == this.Player1.PlayerID);
PlayerRealModel player2 = list.FirstOrDefault(p => p.PlayerID == this.Player2.PlayerID);
int score = this.realDataService.GetGroupRoundScore(this.SelectedGroupInfo.Group, player1, player2, round);
// 总杆数 this.PlayersScore = this.realDataService.GetScoreString(score);
int strokes = this.Player1?.Score ?? 0 + this.Player2?.Score ?? 0;
this.PlayersScore = strokes == 0 ? "E" : strokes > 0 ? $"+{strokes}" : $"-{strokes}";
} }
} }
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
SelectedValue="{Binding Path=SelectedGroupInfo,Mode=TwoWay}"> SelectedValue="{Binding Path=SelectedGroupInfo,Mode=TwoWay}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="分组" Width="80" Binding="{Binding Path=Group,Mode=OneWay}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="分组" Width="80" Binding="{Binding Path=Group,Mode=OneWay}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="成员" Width="240" Binding="{Binding Path=Players,Mode=OneWay,Converter={StaticResource PlayerInfos2DetailConverter}}" IsReadOnly="True"></DataGridTextColumn> <DataGridTextColumn Header="成员" Width="240" Binding="{Binding Path=PlayersDisplayName}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<!-- 按钮组 --> <!-- 按钮组 -->
......
...@@ -165,10 +165,15 @@ namespace VIZ.TVP.Golf.Module ...@@ -165,10 +165,15 @@ namespace VIZ.TVP.Golf.Module
model.Group = group.Key; model.Group = group.Key;
model.TeamInfo = this.SelectedTeamInfo; model.TeamInfo = this.SelectedTeamInfo;
model.TeamLogo = this.SelectedTeamInfo.Logo; model.TeamLogo = this.SelectedTeamInfo.Logo;
foreach (PlayerInfoModel item in group) var list = group.ToList();
{
model.Players.Add(item); // 每组只能有2人
} if (list.Count != 2)
continue;
model.Player1 = list[0];
model.Player2 = list[1];
model.PlayersDisplayName = $"{model.Player1.Name} / {model.Player2.Name}";
groupInfos.Add(model); groupInfos.Add(model);
} }
......
...@@ -3,8 +3,9 @@ using System.Collections.Generic; ...@@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Domain namespace VIZ.TVP.Golf.Service
{ {
/// <summary> /// <summary>
/// 分组临时模型排序比较器 /// 分组临时模型排序比较器
...@@ -33,21 +34,50 @@ namespace VIZ.TVP.Golf.Domain ...@@ -33,21 +34,50 @@ namespace VIZ.TVP.Golf.Domain
public List<PlayerRealModel> PlayerRealModels { get; private set; } public List<PlayerRealModel> PlayerRealModels { get; private set; }
/// <summary> /// <summary>
/// 真实数据服务
/// </summary>
private RealDataService RealDataService = new RealDataService();
/// <summary>
/// 比较 /// 比较
/// </summary> /// </summary>
public int Compare(GroupTempModel x, GroupTempModel y) public virtual int Compare(GroupTempModel x, GroupTempModel y)
{ {
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfo && p.PlayerInfoModel.Group == x.Group); // 是否符合规则
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfo && p.PlayerInfoModel.Group == y.Group); if (x.Player1 == null && y.Player2 == null)
return 0;
if (x.Player1 != null && y.Player2 == null)
return -1;
if (x.Player1 == null && y.Player1 != null)
return 1;
PlayerRealModel X_player1 = this.PlayerRealModels.FirstOrDefault(p => p.PlayerID == x.Player1.PlayerID);
PlayerRealModel X_player2 = this.PlayerRealModels.FirstOrDefault(p => p.PlayerID == x.Player2.PlayerID);
PlayerRealModel Y_player1 = this.PlayerRealModels.FirstOrDefault(p => p.PlayerID == y.Player1.PlayerID);
PlayerRealModel Y_player2 = this.PlayerRealModels.FirstOrDefault(p => p.PlayerID == y.Player2.PlayerID);
if ((X_player1 == null || X_player2 == null) && (Y_player1 == null || Y_player2 == null))
return 0;
if ((X_player1 != null && X_player2 != null) && (Y_player1 == null || Y_player2 == null))
return -1;
if ((X_player1 == null || X_player2 == null) && (Y_player1 != null && Y_player2 != null))
return 1;
// 比较杆数
int X_score = this.RealDataService.GetGroupRoundScore(x.Group, X_player1, X_player2, this.Round);
int Y_score = this.RealDataService.GetGroupRoundScore(x.Group, Y_player1, Y_player2, this.Round);
if (X_score < Y_score)
return -1;
// 杆数少 排名靠前 if (X_score > Y_score)
int total_x = real_players_X.Sum(p => p.Score); return 1;
int total_y = real_players_Y.Sum(p => p.Score);
if (total_x == total_y)
return 0; return 0;
else
return total_x < total_y ? -1 : 1;
} }
} }
} }
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Routing; using System.Web.Routing;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Domain namespace VIZ.TVP.Golf.Service
{ {
/// <summary> /// <summary>
/// 队伍临时模型比较器 /// 队伍临时模型比较器
...@@ -44,6 +46,11 @@ namespace VIZ.TVP.Golf.Domain ...@@ -44,6 +46,11 @@ namespace VIZ.TVP.Golf.Domain
public int? Round { get; private set; } public int? Round { get; private set; }
/// <summary> /// <summary>
/// 真实数据服务
/// </summary>
private RealDataService realDataService = new RealDataService();
/// <summary>
/// 比较大小 /// 比较大小
/// </summary> /// </summary>
public int Compare(TeamTempModel x, TeamTempModel y) public int Compare(TeamTempModel x, TeamTempModel y)
...@@ -62,35 +69,30 @@ namespace VIZ.TVP.Golf.Domain ...@@ -62,35 +69,30 @@ namespace VIZ.TVP.Golf.Domain
/// <returns></returns> /// <returns></returns>
private int CompareAllRound(TeamTempModel x, TeamTempModel y) private int CompareAllRound(TeamTempModel x, TeamTempModel y)
{ {
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfoModel); TeamRoundStatisticsData teamX_round1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, 1);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfoModel); TeamRoundStatisticsData teamY_round1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, 1);
// 1. 杆数少排名靠前 TeamRoundStatisticsData teamX_round2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, 1);
int total_x = real_players_X.Sum(p => p.Score); TeamRoundStatisticsData teamY_round2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, 1);
int total_y = real_players_Y.Sum(p => p.Score);
if (total_x != total_y) // 队伍X成绩无效 && 队伍Y成绩无效
{ if ((teamX_round1.Score == null || teamX_round2.Score == null) && (teamY_round1.Score == null || teamY_round2.Score == null))
return total_x < total_y ? -1 : 1; return 0;
}
// 2. 杆数相同时则比较第二轮成绩 // 队伍X成绩有效 && 队伍Y成绩无效
int round_result = this.CompareWithRound(x, y, 2); if ((teamX_round1.Score != null && teamX_round2.Score != null) && (teamY_round1.Score == null || teamY_round2.Score == null))
if (round_result != 0) return -1;
{
return total_x < total_y ? -1 : 1;
}
// 3. 逐个比较第二轮每一洞成绩 // 队伍X成绩无效 && 队伍Y成绩有效
for (int i = 18; i >= 1; --i) if ((teamX_round1.Score == null || teamX_round2.Score == null) && (teamY_round1.Score != null && teamY_round2.Score != null))
{ return 1;
int hole_result = this.CompareWithHole(x, y, 2, i);
if (hole_result != 0) // 比杆数
{ if (teamX_round1.Strokes + teamX_round2.Strokes < teamY_round1.Strokes + teamY_round2.Strokes)
return hole_result; return -1;
}
} if (teamX_round1.Strokes + teamX_round2.Strokes > teamY_round1.Strokes + teamY_round2.Strokes)
return -1;
return 0; return 0;
} }
...@@ -101,75 +103,22 @@ namespace VIZ.TVP.Golf.Domain ...@@ -101,75 +103,22 @@ namespace VIZ.TVP.Golf.Domain
/// <param name="round">轮次</param> /// <param name="round">轮次</param>
private int CompareWithRound(TeamTempModel x, TeamTempModel y, int round) private int CompareWithRound(TeamTempModel x, TeamTempModel y, int round)
{ {
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfoModel); TeamRoundStatisticsData team1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, round);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfoModel); TeamRoundStatisticsData team2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, round);
int total_x = 0;
foreach (var real_player in real_players_X)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round != null)
{
total_x += real_round.Today;
}
}
int total_y = 0;
foreach (var real_player in real_players_Y)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round != null)
{
total_y += real_round.Today;
}
}
if (total_x == total_y) if (team1.Score == null && team2.Score == null)
return 0; return 0;
else return total_x < total_y ? -1 : 1;
}
/// <summary> if (team1.Score != null && team2.Score != null)
/// 比较大小 return -1;
/// </summary>
/// <param name="round">轮次</param>
private int CompareWithHole(TeamTempModel x, TeamTempModel y, int round, int hole)
{
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfoModel);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfoModel);
int total_x = 0; if (team1.Score == null && team2.Score != null)
foreach (var real_player in real_players_X) return 1;
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round == null)
continue;
ScoreRealModel real_score = real_round.Scores.FirstOrDefault(p => p.Hole == hole);
if (real_score == null)
continue;
total_x += real_score.Strokes - real_score.Par;
}
int total_y = 0;
foreach (var real_player in real_players_Y)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == round);
if (real_round == null)
continue;
ScoreRealModel real_score = real_round.Scores.FirstOrDefault(p => p.Hole == hole);
if (real_score == null)
continue;
total_y += real_score.Strokes - real_score.Par;
}
if (total_x == total_y) if (team1.Score.Value == team2.Score.Value)
return 0; return 0;
else else
return total_x < total_y ? -1 : 1; return team1.Score.Value < team2.Score.Value ? -1 : 1;
} }
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Service
{
/// <summary>
/// 分组洞统计数据
/// </summary>
public class GroupHoleStatisticsData
{
/// <summary>
/// 分组
/// </summary>
public string Group { get; set; }
/// <summary>
/// 洞信息
/// </summary>
public HoleInfoModel HoleInfo { get; set; }
/// <summary>
/// 球员1
/// </summary>
public PlayerRealModel Player1 { get; set; }
/// <summary>
/// 球员2
/// </summary>
public PlayerRealModel Player2 { get; set; }
/// <summary>
/// 得分
/// </summary>
public int Score { get; set; }
/// <summary>
/// 总杆数
/// </summary>
public int Strokes { get; set; }
/// <summary>
/// 球员1杆数
/// </summary>
public int PlayerStrokes1 { get; set; }
/// <summary>
/// 球员2杆数
/// </summary>
public int PlayerStrokes2 { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Service
{
/// <summary>
/// 队伍轮次统计数据
/// </summary>
public class TeamRoundStatisticsData
{
/// <summary>
/// 队伍ID
/// </summary>
public int TeamID { get; set; }
/// <summary>
/// 队伍信息
/// </summary>
public TeamInfoModel TeamInfo { get; set; }
/// <summary>
/// 轮次
/// </summary>
public int Round { get; set; }
/// <summary>
/// 得分
/// </summary>
public int? Score { get; set; }
/// <summary>
/// 总杆数
/// </summary>
public int Strokes { get; set; }
/// <summary>
/// 分组每轮得分字典
/// </summary>
public Dictionary<string, int> GroupRoundScoreDic { get; set; } = new Dictionary<string, int>();
}
}
...@@ -37,5 +37,89 @@ namespace VIZ.TVP.Golf.Service ...@@ -37,5 +37,89 @@ namespace VIZ.TVP.Golf.Service
/// <param name="dir">工作文件夹</param> /// <param name="dir">工作文件夹</param>
/// <returns>本地数据文件名</returns> /// <returns>本地数据文件名</returns>
List<string> GetLocalDataFiles(string dir); List<string> GetLocalDataFiles(string dir);
/// <summary>
/// 获取得分字符串
/// </summary>
/// <param name="score">得分</param>
/// <returns>得分字符串</returns>
string GetScoreString(int? score);
/// <summary>
/// 获取队伍每洞得分
/// </summary>
/// <param name="players">球员集合</param>
/// <param name="data">队伍轮次统计数据</param>
/// <returns>得分</returns>
int GetTeamHoleScore(List<PlayerRealModel> players, TeamRoundStatisticsData data, int hole);
/// <summary>
/// 获取分组每轮得分
/// </summary>
/// <param name="players">球员集合</param>
/// <param name="teamId">队伍ID</param>
/// <param name="round">轮次</param>
/// <returns>得分</returns>
TeamRoundStatisticsData GetTeamRoundStatisticsData(List<PlayerRealModel> players, int teamId, int round);
/// <summary>
/// 获取分组每轮得分
/// </summary>
/// <param name="group">分组</param>
/// <param name="player1">球员1</param>
/// <param name="player2">球员2</param>
/// <param name="round">轮次</param>
/// <returns>得分</returns>
int GetGroupRoundScore(string group, PlayerRealModel player1, PlayerRealModel player2, int round);
/// <summary>
/// 获取分组每洞统计数据
/// </summary>
/// <param name="group">分组</param>
/// <param name="player1">球员1</param>
/// <param name="player2">球员2</param>
/// <param name="round">轮次</param>
/// <returns>分组每洞信息字典</returns>
Dictionary<int, GroupHoleStatisticsData> GetGroupHoleStatisticsDataDic(string group, PlayerRealModel player1, PlayerRealModel player2, int round);
/// <summary>
/// 获取队伍洞统计数据
/// </summary>
/// <param name="group">分组</param>
/// <param name="player1">队员1</param>
/// <param name="player2">队员2</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞号</param>
/// <returns>洞统计数据</returns>
GroupHoleStatisticsData GetGroupHoleStatisticsData(string group, PlayerRealModel player1, PlayerRealModel player2, int round, int hole);
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="player">球员</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞嗯呢</param>
/// <returns>是否已经完成该洞</returns>
bool IsPlayerHoleFinished(PlayerRealModel player, int round, int hole);
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="real_round">轮次真实数据</param>
/// <param name="hole">洞</param>
/// <returns>是否已经完成该洞</returns>
bool IsPlayerHoleFinished(RoundRealModel real_round, int hole);
/// <summary>
/// 更新队伍排名值
/// </summary>
/// <param name="teams">已经完成排序的队伍</param>
void UpdateTeamPosition(IList<TeamTempModel> teams);
/// <summary>
/// 更新队伍排名变化
/// </summary>
/// <param name="teams">已经完成排序的队伍</param>
void UpdateTeamPositionChanged(IList<TeamTempModel> before, IList<TeamTempModel> after);
} }
} }
...@@ -53,8 +53,12 @@ ...@@ -53,8 +53,12 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Comparer\GroupTempModelComparer.cs" />
<Compile Include="Comparer\TeamTempModelComparer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RealData\Implementation\RealDataService.cs" /> <Compile Include="RealData\Implementation\RealDataService.cs" />
<Compile Include="RealData\Info\GroupHoleStatisticsData.cs" />
<Compile Include="RealData\Info\TeamRoundStatisticsData.cs" />
<Compile Include="RealData\Interface\IRealDataService.cs" /> <Compile Include="RealData\Interface\IRealDataService.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -82,12 +82,12 @@ namespace VIZ.TVP.Golf.Storage ...@@ -82,12 +82,12 @@ namespace VIZ.TVP.Golf.Storage
/// <summary> /// <summary>
/// 得分 /// 得分
/// </summary> /// </summary>
public int score { get; set; } public int? score { get; set; }
/// <summary> /// <summary>
/// 总杆数 /// 总杆数
/// </summary> /// </summary>
public int strokes { get; set; } public int? strokes { get; set; }
/// <summary> /// <summary>
/// 轮次节点集合 /// 轮次节点集合
......
...@@ -22,32 +22,32 @@ namespace VIZ.TVP.Golf.Storage ...@@ -22,32 +22,32 @@ namespace VIZ.TVP.Golf.Storage
/// <summary> /// <summary>
/// 杆数 /// 杆数
/// </summary> /// </summary>
public int strokes { get; set; } public int? strokes { get; set; }
/// <summary> /// <summary>
/// 标准杆 /// 标准杆
/// </summary> /// </summary>
public int par { get; set; } public int? par { get; set; }
/// <summary> /// <summary>
/// 沙坑救球数 /// 沙坑救球数
/// </summary> /// </summary>
public int bunkers { get; set; } public int? bunkers { get; set; }
/// <summary> /// <summary>
/// 推杆数 /// 推杆数
/// </summary> /// </summary>
public int putts { get; set; } public int? putts { get; set; }
/// <summary> /// <summary>
/// 开球距离 /// 开球距离
/// </summary> /// </summary>
public double drive { get; set; } public double? drive { get; set; }
/// <summary> /// <summary>
/// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录 /// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录
/// </summary> /// </summary>
public int fairway { get; set; } public int? fairway { get; set; }
/// <summary> /// <summary>
/// 将当前节点转化为XElement节点 /// 将当前节点转化为XElement节点
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VIZ.TVP.Golf" xmlns:local="clr-namespace:VIZ.TVP.Golf"
xmlns:module="clr-namespace:VIZ.TVP.Golf.Module;assembly=VIZ.TVP.Golf.Module" xmlns:module="clr-namespace:VIZ.TVP.Golf.Module;assembly=VIZ.TVP.Golf.Module"
mc:Ignorable="d" WindowStartupLocation="CenterScreen" mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowState="Maximized"
Icon="logo.ico" Icon="logo.ico"
Title="高尔夫包装工具" Height="900" Width="1700"> Title="高尔夫包装工具" Height="950" Width="1700">
<Grid> <Grid>
<module:MainView Margin="10"></module:MainView> <module:MainView Margin="10"></module:MainView>
</Grid> </Grid>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment