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
public const string TeamInfo = "TeamInfo";
/// <summary>
/// 组信息
/// 组信息
/// </summary>
public const string GroupInfo = "GroupInfo";
/// <summary>
/// 分组具体洞信息
/// </summary>
public const string GroupInfoWithHole = "GroupInfoWithHole";
/// <summary>
/// 冠军版
/// </summary>
public const string Champion = "Champion";
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -77,11 +78,12 @@ namespace VIZ.TVP.Golf.Domain
#region Score -- 得分
private int score;
private int? score;
/// <summary>
/// 得分
/// </summary>
public int Score
[Obsolete]
public int? Score
{
get { return score; }
set { score = value; this.RaisePropertyChanged(nameof(Score)); }
......@@ -91,11 +93,12 @@ namespace VIZ.TVP.Golf.Domain
#region Strokes -- 总杆数
private int strokes;
private int? strokes;
/// <summary>
/// 总杆数
/// </summary>
public int Strokes
[Obsolete]
public int? Strokes
{
get { return strokes; }
set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); }
......
......@@ -35,11 +35,11 @@ namespace VIZ.TVP.Golf.Domain
#region TeeTime -- 开球时间
private TimeSpan teeTime;
private TimeSpan? teeTime;
/// <summary>
/// 开球时间
/// </summary>
public TimeSpan TeeTime
public TimeSpan? TeeTime
{
get { return teeTime; }
set { teeTime = value; this.RaisePropertyChanged(nameof(TeeTime)); }
......@@ -77,11 +77,12 @@ namespace VIZ.TVP.Golf.Domain
#region Today -- 本轮(今日)杆数与标准杆的差值
private int today;
private int? today;
/// <summary>
/// 本轮(今日)杆数与标准杆的差值
/// </summary>
public int Today
[Obsolete]
public int? Today
{
get { return today; }
set { today = value; this.RaisePropertyChanged(nameof(Today)); }
......@@ -95,6 +96,7 @@ namespace VIZ.TVP.Golf.Domain
/// <summary>
/// 本轮(进入)总杆数
/// </summary>
[Obsolete]
public int Total
{
get { return total; }
......
......@@ -34,11 +34,11 @@ namespace VIZ.TVP.Golf.Domain
#region Strokes -- 杆数
private int strokes;
private int? strokes;
/// <summary>
/// 杆数
/// </summary>
public int Strokes
public int? Strokes
{
get { return strokes; }
set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); }
......@@ -48,11 +48,12 @@ namespace VIZ.TVP.Golf.Domain
#region Par -- 标准杆
private int par;
private int? par;
/// <summary>
/// 标准杆
/// </summary>
public int Par
[Obsolete]
public int? Par
{
get { return par; }
set { par = value; this.RaisePropertyChanged(nameof(Par)); }
......@@ -62,11 +63,11 @@ namespace VIZ.TVP.Golf.Domain
#region Bunkers -- 沙滩救球数
private int bunkers;
private int? bunkers;
/// <summary>
/// 沙滩救球数
/// </summary>
public int Bunkers
public int? Bunkers
{
get { return bunkers; }
set { bunkers = value; this.RaisePropertyChanged(nameof(Bunkers)); }
......@@ -76,11 +77,11 @@ namespace VIZ.TVP.Golf.Domain
#region Putts -- 推杆数
private int putts;
private int? putts;
/// <summary>
/// 推杆数
/// </summary>
public int Putts
public int? Putts
{
get { return putts; }
set { putts = value; this.RaisePropertyChanged(nameof(Putts)); }
......@@ -90,11 +91,11 @@ namespace VIZ.TVP.Golf.Domain
#region Drive -- 开球距离
private double drive;
private double? drive;
/// <summary>
/// 开球距离
/// </summary>
public double Drive
public double? Drive
{
get { return drive; }
set { drive = value; this.RaisePropertyChanged(nameof(Drive)); }
......@@ -104,11 +105,11 @@ namespace VIZ.TVP.Golf.Domain
#region Fairway -- 是否发球上球道 1: | 0: | : 未记录
private int fairway;
private int? fairway;
/// <summary>
/// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录
/// </summary>
public int Fairway
public int? Fairway
{
get { return fairway; }
set { fairway = value; this.RaisePropertyChanged(nameof(Fairway)); }
......
......@@ -54,6 +54,20 @@ namespace VIZ.TVP.Golf.Domain
#endregion
#region TotalScore -- 总得分
private string totalScore;
/// <summary>
/// 总得分
/// </summary>
public string TotalScore
{
get { return totalScore; }
set { totalScore = value; this.RaisePropertyChanged(nameof(TotalScore)); }
}
#endregion
#region TotalStrokesDetail -- 总杆数描述
private string totalStrokesDetail;
......
......@@ -55,16 +55,30 @@ namespace VIZ.TVP.Golf.Domain
#endregion
#region Players -- 球员信息
#region Player1 -- 球员1
private ObservableCollection<PlayerInfoModel> players = new ObservableCollection<PlayerInfoModel>();
private PlayerInfoModel player1;
/// <summary>
/// 球员信息
/// 球员1
/// </summary>
public ObservableCollection<PlayerInfoModel> Players
public PlayerInfoModel Player1
{
get { return players; }
set { players = value; this.RaisePropertyChanged(nameof(Players)); }
get { return player1; }
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
......
......@@ -68,20 +68,6 @@ namespace VIZ.TVP.Golf.Domain
#endregion
#region Score -- 得分
private int score;
/// <summary>
/// 得分
/// </summary>
public int Score
{
get { return score; }
set { score = value; this.RaisePropertyChanged(nameof(Score)); }
}
#endregion
/// <summary>
/// 从球员信息模型中获取数据
/// </summary>
......
......@@ -84,11 +84,11 @@ namespace VIZ.TVP.Golf.Domain
#region TotalScoreValue -- 总得分值
private int totalScoreValue;
private int? totalScoreValue;
/// <summary>
/// 总得分值
/// </summary>
public int TotalScoreValue
public int? TotalScoreValue
{
get { return totalScoreValue; }
set { totalScoreValue = value; this.RaisePropertyChanged(nameof(TotalScoreValue)); }
......@@ -110,6 +110,48 @@ namespace VIZ.TVP.Golf.Domain
#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>
......
......@@ -34,6 +34,11 @@ namespace VIZ.TVP.Golf.Domain
public static ObservableCollection<string> Groups { get; set; } = new ObservableCollection<string>();
/// <summary>
/// 包含空的分组
/// </summary>
public static ObservableCollection<string> GroupsWithNone { get; set; } = new ObservableCollection<string>();
/// <summary>
/// 轮次集合
/// </summary>
public static ObservableCollection<int> Rounds { get; set; } = new ObservableCollection<int>();
......@@ -47,6 +52,21 @@ namespace VIZ.TVP.Golf.Domain
/// 描述信息结合
/// </summary>
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 @@
</ItemGroup>
<ItemGroup>
<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="Model\EntityModel\HoleInfoModel.cs" />
<Compile Include="Model\EntityModel\PlayerInfoModel.cs" />
......
......@@ -185,5 +185,8 @@
<ItemGroup>
<Resource Include="Icons\refresh_green_16x16.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\contrast_16x16.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -72,7 +72,7 @@
ItemsSource="{Binding Source={x:Static domain:ApplicationDomainEx.TeamInfos}}"
SelectedValueBinding="{Binding Path=TeamInfoModel}"></DataGridComboBoxColumn>
<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>
</DataGrid.Columns>
</DataGrid>
......
......@@ -58,6 +58,8 @@
Content="队伍信息"></RadioButton>
<RadioButton x:Name="rb_GroupInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
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}"
Content="冠军版"></RadioButton>
<RadioButton x:Name="rb_GroupHoleInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
......@@ -106,6 +108,8 @@
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}"
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}"
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}"
......
......@@ -94,18 +94,19 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=GroupHoleTempModels}">
<DataGrid.Columns>
<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=TotalStrokes}"></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=TotalStrokes}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数描述" Width="200" Binding="{Binding Path=TotalStrokesDetail}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</GroupBox>
<!-- 汇总 -->
<!-- 总杆数汇总 -->
<GroupBox Padding="10" Grid.Row="3">
<GroupBox.Header>
<TextBlock Text="汇总" FontSize="18" FontWeight="Bold"></TextBlock>
<TextBlock Text="总杆数汇总" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
......
......@@ -6,8 +6,10 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media.Media3D;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module
{
......@@ -45,7 +47,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次
private int selectedRound;
private int selectedRound = TvpStaticResource.DEFAULT_ROUND;
/// <summary>
/// 选中的轮次
/// </summary>
......@@ -237,8 +239,6 @@ namespace VIZ.TVP.Golf.Module
/// <param name="list">真实球员模型</param>
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>();
if (this.SelectedRound == 0)
......@@ -249,32 +249,24 @@ namespace VIZ.TVP.Golf.Module
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)
{
GroupHoleTempModel model = new GroupHoleTempModel();
model.HoleID = holeInfo.HoleID.ToString();
model.Par = holeInfo.Par;
int total = 0;
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;
if (!dic.TryGetValue(holeInfo.HoleID, out GroupHoleStatisticsData data))
continue;
total += score_real.Strokes;
model.TotalStrokesDetail += $"{player.Name}: {score_real.Strokes} | ";
}
model.TotalStrokes = total.ToString();
model.TotalStrokes = data.Strokes.ToString();
model.TotalScore = this.realDataService.GetScoreString(data.Score);
model.TotalStrokesDetail = $"{data.Player1.Name}: {data.PlayerStrokes1} | {data.Player2.Name} : {data.PlayerStrokes2}";
groupHoleTempModels.Add(model);
}
......@@ -285,8 +277,7 @@ namespace VIZ.TVP.Golf.Module
this.Summary();
// 更新其他信息
this.GroupPickerPanelModel.UpdatePlayersProperty();
this.GroupPickerPanelModel.UpdatePlayersScore(list, this.SelectedRound);
}
}
}
......@@ -46,23 +46,26 @@
<Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="90"></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>
<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" 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">
<ComboBox Height="30" Width="240" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
......@@ -89,7 +92,7 @@
</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"
Content="预设分组" Grid.Column="1" Width="80" Height="30" Margin="5,0,0,0"
Command="{Binding PresetGroupCommand}"></fcommon:IconButton>
</StackPanel>
</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;
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;
......@@ -34,7 +35,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次
private int selectedRound;
private int selectedRound = 2;
/// <summary>
/// 选中的轮次
/// </summary>
......@@ -127,13 +128,8 @@ namespace VIZ.TVP.Golf.Module
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, this.SelectedRound, list);
this.GroupPickerPanelModel1.UpdatePlayersProperty();
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, this.SelectedRound, list);
this.GroupPickerPanelModel2.UpdatePlayersProperty();
this.GroupPickerPanelModel1.UpdatePlayersScore(list, this.SelectedRound);
this.GroupPickerPanelModel2.UpdatePlayersScore(list, this.SelectedRound);
}
#endregion
......@@ -160,11 +156,6 @@ namespace VIZ.TVP.Golf.Module
{
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,13 +184,20 @@ namespace VIZ.TVP.Golf.Module
{
var team = teams[0];
GroupTempModel model = new GroupTempModel();
model.Group = this.group;
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);
}
else
{
this.GroupPickerPanelModel1.ClearProperty();
}
}
else
{
......@@ -210,10 +208,19 @@ namespace VIZ.TVP.Golf.Module
{
var team = teams[1];
GroupTempModel model = new GroupTempModel();
model.Group = this.group;
model.TeamInfo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team.Key);
foreach (var player in team)
var players = team.ToList();
if (players.Count == 2)
{
model.Player1 = players[0];
model.Player2 = players[1];
this.GroupPickerPanelModel2.UpdateByGroupTempModel(model);
}
else
{
model.Players.Add(player);
this.GroupPickerPanelModel2.ClearProperty();
}
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
#region SelectedRound -- 选中的轮次
private int selectedRound;
private int selectedRound = 2;
/// <summary>
/// 选中的轮次信息
/// </summary>
......@@ -126,30 +126,7 @@ namespace VIZ.TVP.Golf.Module
/// <param name="list">球员真实模型</param>
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
// 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 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}">
<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="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240"
......
......@@ -7,6 +7,7 @@ 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
{
......@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module
// ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// 获取队伍临时模型集合
/// </summary>
/// <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>();
......@@ -47,18 +49,23 @@ namespace VIZ.TVP.Golf.Module
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();
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);
}
// 赛后比较所有的轮次
TeamTempModelComparer comparer = new TeamTempModelComparer(list);
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
this.TeamTempModels = teamTempModels.ToObservableCollection();
return teamTempModels.ToObservableCollection();
}
}
}
......@@ -64,7 +64,7 @@
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}">
<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="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240"
......
......@@ -7,6 +7,7 @@ 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
{
......@@ -35,10 +36,11 @@ namespace VIZ.TVP.Golf.Module
// ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// 获取队伍临时模型集合
/// </summary>
/// <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>();
......@@ -47,27 +49,22 @@ namespace VIZ.TVP.Golf.Module
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)
TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, 1);
if (data != null)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == 1);
if (real_round == null)
continue;
total += real_round.Today;
temp_model.TotalScoreValue = data.Score;
temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
}
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
}
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer);
this.realDataService.UpdateTeamPosition(teamTempModels);
this.TeamTempModels = teamTempModels.ToObservableCollection();
return teamTempModels.ToObservableCollection();
}
}
}
......@@ -41,6 +41,14 @@
IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
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>
</Border>
<!-- 版子信息 -->
......@@ -78,21 +86,39 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
VerticalAlignment="Top" Margin="0,5,0,0"></Image>
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn Header="Logo" Width="240"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
VerticalAlignment="Top" Margin="0,30,0,0"></Image>
<!-- 实时数据 -->
<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}">
<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>
<DataGridTextColumn Header="之前索引" Width="60" Binding="{Binding Path=PositionOldIndex}"></DataGridTextColumn>
<DataGridTextColumn Header="之后索引" Width="60" Binding="{Binding Path=PositionNewIndex}"></DataGridTextColumn>
<DataGridTextColumn Header="索引变化" Width="80" Binding="{Binding Path=PositionChangedDesc}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns>
</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>
</GroupBox>
......
......@@ -7,13 +7,14 @@ 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 class LongTeamRankingViewModel : TeamRankingViewModelBase
public class LongTeamRankingViewModel : TeamRankingConstrrastViewModelBase
{
public LongTeamRankingViewModel()
{
......@@ -33,5 +34,36 @@ namespace VIZ.TVP.Golf.Module
// 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 @@
IsEnabled="{Binding Path=IsLoadRemoteDataEnabled,Mode=OneWay}"
Icon="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
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>
</Border>
<!-- 版子信息 -->
......@@ -78,21 +86,39 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png"
VerticalAlignment="Top" Margin="0,5,0,0"></Image>
<DataGrid Grid.Column="1" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
ItemsSource="{Binding Path=TeamTempModels}">
<DataGrid.Columns>
<DataGridTextColumn Header="排名" Width="100" Binding="{Binding Path=Position}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
VerticalAlignment="Top" Margin="0,30,0,0"></Image>
<!-- 实时数据 -->
<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}">
<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>
<DataGridTextColumn Header="之前索引" Width="60" Binding="{Binding Path=PositionOldIndex}"></DataGridTextColumn>
<DataGridTextColumn Header="之后索引" Width="60" Binding="{Binding Path=PositionNewIndex}"></DataGridTextColumn>
<DataGridTextColumn Header="索引变化" Width="80" Binding="{Binding Path=PositionChangedDesc}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns>
</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>
</GroupBox>
......
......@@ -7,13 +7,14 @@ 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 class ShortTeamRankingViewModel : TeamRankingViewModelBase
public class ShortTeamRankingViewModel : TeamRankingConstrrastViewModelBase
{
public ShortTeamRankingViewModel()
{
......@@ -24,7 +25,6 @@ namespace VIZ.TVP.Golf.Module
// Property
// ===================================================================================
// ===================================================================================
// Command
// ===================================================================================
......@@ -34,10 +34,11 @@ namespace VIZ.TVP.Golf.Module
// ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// 获取队伍临时模型集合
/// </summary>
/// <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>();
......@@ -46,26 +47,22 @@ namespace VIZ.TVP.Golf.Module
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)
TeamRoundStatisticsData data = this.realDataService.GetTeamRoundStatisticsData(list, info_model.TeamID, this.SelectedRound);
if (data != null)
{
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.SelectedRound);
if (real_round == null)
continue;
total += real_round.Today;
temp_model.TotalScoreValue = data.Score;
temp_model.TotalScore = this.realDataService.GetScoreString(data.Score);
}
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
}
TeamTempModelComparer comparer = new TeamTempModelComparer(list, this.SelectedRound);
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
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;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module
{
......@@ -23,7 +24,7 @@ namespace VIZ.TVP.Golf.Module
#region SelectedRound -- 选中的轮次
private int selectedRound;
private int selectedRound = 2;
/// <summary>
/// 选中的轮次信息
/// </summary>
......@@ -84,7 +85,7 @@ namespace VIZ.TVP.Golf.Module
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(vm.SelectedFile.FileName);
this.UpdateTeamTempModels(list);
this.TeamTempModels = this.GetTeamTempModels(list);
}
#endregion
......@@ -111,7 +112,7 @@ namespace VIZ.TVP.Golf.Module
{
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName);
this.UpdateTeamTempModels(list);
this.TeamTempModels = this.GetTeamTempModels(list);
});
});
}
......@@ -123,38 +124,10 @@ namespace VIZ.TVP.Golf.Module
// ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// 获取队伍临时模型集合
/// </summary>
/// <param name="list">球员真实模型</param>
protected virtual void UpdateTeamTempModels(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();
}
/// <returns>队伍临时模型集合</returns>
protected abstract ObservableCollection<TeamTempModel> GetTeamTempModels(List<PlayerRealModel> list);
}
}
\ No newline at end of file
......@@ -122,12 +122,17 @@ namespace VIZ.TVP.Golf.Module
private void InitGroups()
{
ObservableCollection<string> groups = new ObservableCollection<string>();
ObservableCollection<string> groupsWithNone = new ObservableCollection<string>();
groupsWithNone.Add(string.Empty);
for (int i = 1; i <= 18; i++)
{
groups.Add(i.ToString());
groupsWithNone.Add(i.ToString());
}
TvpStaticResource.Groups = groups;
TvpStaticResource.GroupsWithNone = groupsWithNone;
}
/// <summary>
......
......@@ -93,6 +93,10 @@
</Reference>
</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">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -211,6 +215,10 @@
</Page>
</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\View\LongGroupRankingView.xaml.cs">
<DependentUpon>LongGroupRankingView.xaml</DependentUpon>
......@@ -232,6 +240,7 @@
<Compile Include="Package\TeamRanking\LongTeamRanking\View\LongTeamRankingView.xaml.cs">
<DependentUpon>LongTeamRankingView.xaml</DependentUpon>
</Compile>
<Compile Include="Package\TeamRanking\TeamRankingConstrrastViewModelBase.cs" />
<Compile Include="Package\TeamRanking\ShortTeamRanking\ViewModel\ShortTeamRankingViewModel.cs" />
<Compile Include="Package\TeamRanking\ShortTeamRanking\View\ShortTeamRankingView.xaml.cs">
<DependentUpon>ShortTeamRankingView.xaml</DependentUpon>
......
......@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.Web.UI.HtmlControls;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
using VIZ.TVP.Golf.Service;
namespace VIZ.TVP.Golf.Module
{
......@@ -134,6 +135,15 @@ namespace VIZ.TVP.Golf.Module
#endregion
// ===================================================================================
// Field
// ===================================================================================
/// <summary>
/// 真实数据服务
/// </summary>
private IRealDataService realDataService = new RealDataService();
// ===================================================================================
// Command
// ===================================================================================
......@@ -178,28 +188,26 @@ namespace VIZ.TVP.Golf.Module
if (groupTempModel == null)
return;
this.SelectedGroupInfo = groupTempModel;
this.Name = groupTempModel.TeamInfo.Name;
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 = player.PlayerID;
this.Player1.Name = player.Name;
this.Player1.HalfPicture = player.HalfPicture;
this.Player1.PlayerID = groupTempModel.Player1.PlayerID;
this.Player1.Name = groupTempModel.Player1.Name;
this.Player1.HalfPicture = groupTempModel.Player1.HalfPicture;
}
if (groupTempModel.Players.Count > 1)
if (groupTempModel.Player2 != null)
{
PlayerInfoModel player = groupTempModel.Players[1];
this.player2.PlayerID = player.PlayerID;
this.Player2.Name = player.Name;
this.Player2.HalfPicture = player.HalfPicture;
this.player2.PlayerID = groupTempModel.Player2.PlayerID;
this.Player2.Name = groupTempModel.Player2.Name;
this.Player2.HalfPicture = groupTempModel.Player2.HalfPicture;
}
this.UpdatePlayersProperty();
this.UpdatePlayersDisplayName();
}
/// <summary>
......@@ -213,12 +221,10 @@ namespace VIZ.TVP.Golf.Module
this.Player1.PlayerID = 0;
this.Player1.Name = null;
this.Player1.HalfPicture = null;
this.Player1.Score = 0;
this.Player2.PlayerID = 0;
this.Player2.Name = null;
this.Player2.HalfPicture = null;
this.Player2.Score = 0;
this.PlayersDisplayName = null;
this.PlayersScore = null;
......@@ -227,7 +233,7 @@ namespace VIZ.TVP.Golf.Module
/// <summary>
/// 更新球员集合属性
/// </summary>
public void UpdatePlayersProperty()
public void UpdatePlayersDisplayName()
{
// 组成员
StringBuilder sb = new StringBuilder();
......@@ -244,10 +250,45 @@ namespace VIZ.TVP.Golf.Module
}
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);
// 总杆数
int strokes = this.Player1?.Score ?? 0 + this.Player2?.Score ?? 0;
this.PlayersScore = strokes == 0 ? "E" : strokes > 0 ? $"+{strokes}" : $"-{strokes}";
this.PlayersScore = this.realDataService.GetScoreString(score);
}
}
}
......@@ -40,7 +40,7 @@
SelectedValue="{Binding Path=SelectedGroupInfo,Mode=TwoWay}">
<DataGrid.Columns>
<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>
<!-- 按钮组 -->
......
......@@ -165,10 +165,15 @@ namespace VIZ.TVP.Golf.Module
model.Group = group.Key;
model.TeamInfo = this.SelectedTeamInfo;
model.TeamLogo = this.SelectedTeamInfo.Logo;
foreach (PlayerInfoModel item in group)
{
model.Players.Add(item);
}
var list = group.ToList();
// 每组只能有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);
}
......
......@@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Domain
namespace VIZ.TVP.Golf.Service
{
/// <summary>
/// 分组临时模型排序比较器
......@@ -33,21 +34,50 @@ namespace VIZ.TVP.Golf.Domain
public List<PlayerRealModel> PlayerRealModels { get; private set; }
/// <summary>
/// 真实数据服务
/// </summary>
private RealDataService RealDataService = new RealDataService();
/// <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;
// 杆数少 排名靠前
int total_x = real_players_X.Sum(p => p.Score);
int total_y = real_players_Y.Sum(p => p.Score);
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 (total_x == total_y)
if ((X_player1 == null || X_player2 == null) && (Y_player1 == null || Y_player2 == null))
return 0;
else
return total_x < total_y ? -1 : 1;
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)
return 1;
return 0;
}
}
}
......@@ -2,11 +2,13 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Domain
namespace VIZ.TVP.Golf.Service
{
/// <summary>
/// 队伍临时模型比较器
......@@ -44,6 +46,11 @@ namespace VIZ.TVP.Golf.Domain
public int? Round { get; private set; }
/// <summary>
/// 真实数据服务
/// </summary>
private RealDataService realDataService = new RealDataService();
/// <summary>
/// 比较大小
/// </summary>
public int Compare(TeamTempModel x, TeamTempModel y)
......@@ -62,35 +69,30 @@ namespace VIZ.TVP.Golf.Domain
/// <returns></returns>
private int CompareAllRound(TeamTempModel x, TeamTempModel y)
{
var real_players_X = this.PlayerRealModels.Where(p => p.TeamInfoModel == x.TeamInfoModel);
var real_players_Y = this.PlayerRealModels.Where(p => p.TeamInfoModel == y.TeamInfoModel);
// 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. 杆数相同时则比较第二轮成绩
int round_result = this.CompareWithRound(x, y, 2);
if (round_result != 0)
{
return total_x < total_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;
}
}
TeamRoundStatisticsData teamX_round1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, 1);
TeamRoundStatisticsData teamY_round1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, 1);
TeamRoundStatisticsData teamX_round2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, 1);
TeamRoundStatisticsData teamY_round2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, 1);
// 队伍X成绩无效 && 队伍Y成绩无效
if ((teamX_round1.Score == null || teamX_round2.Score == null) && (teamY_round1.Score == null || teamY_round2.Score == null))
return 0;
// 队伍X成绩有效 && 队伍Y成绩无效
if ((teamX_round1.Score != null && teamX_round2.Score != null) && (teamY_round1.Score == null || teamY_round2.Score == null))
return -1;
// 队伍X成绩无效 && 队伍Y成绩有效
if ((teamX_round1.Score == null || teamX_round2.Score == null) && (teamY_round1.Score != null && teamY_round2.Score != null))
return 1;
// 比杆数
if (teamX_round1.Strokes + teamX_round2.Strokes < teamY_round1.Strokes + teamY_round2.Strokes)
return -1;
if (teamX_round1.Strokes + teamX_round2.Strokes > teamY_round1.Strokes + teamY_round2.Strokes)
return -1;
return 0;
}
......@@ -101,75 +103,22 @@ namespace VIZ.TVP.Golf.Domain
/// <param name="round">轮次</param>
private int CompareWithRound(TeamTempModel x, TeamTempModel y, int round)
{
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;
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)
TeamRoundStatisticsData team1 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, x.TeamID, round);
TeamRoundStatisticsData team2 = this.realDataService.GetTeamRoundStatisticsData(this.PlayerRealModels, y.TeamID, round);
if (team1.Score == null && team2.Score == null)
return 0;
else return total_x < total_y ? -1 : 1;
}
/// <summary>
/// 比较大小
/// </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;
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)
if (team1.Score != null && team2.Score != null)
return -1;
if (team1.Score == null && team2.Score != null)
return 1;
if (team1.Score.Value == team2.Score.Value)
return 0;
else
return total_x < total_y ? -1 : 1;
else
return team1.Score.Value < team2.Score.Value ? -1 : 1;
}
}
}
......@@ -132,5 +132,309 @@ namespace VIZ.TVP.Golf.Service
return files.ToList();
}
/// <summary>
/// 获取得分字符串
/// </summary>
/// <param name="score">得分</param>
/// <returns>得分字符串</returns>
public string GetScoreString(int? score)
{
if (score == null)
return null;
return score.Value == 0 ? "E" : (score.Value > 0 ? $"+{score.Value}" : $"{score.Value}");
}
/// <summary>
/// 获取队伍每洞得分
/// </summary>
/// <param name="players">球员集合</param>
/// <param name="data">队伍轮次统计数据</param>
/// <returns>得分</returns>
public int GetTeamHoleScore(List<PlayerRealModel> players, TeamRoundStatisticsData data, int hole)
{
var groups = data.GroupRoundScoreDic.ToList().OrderByDescending(p => p.Value).Select(p => p.Key).Take(5);
int total = 0;
foreach (var group in groups)
{
var group_players = ApplicationDomainEx.PlayerInfos.Where(p => p.TeamID == data.TeamID && p.Group == group).ToList();
if (group_players.Count != 2)
continue;
var real_player1 = players.FirstOrDefault(p => p.PlayerID == group_players[0].PlayerID);
var real_player2 = players.FirstOrDefault(p => p.PlayerID == group_players[1].PlayerID);
if (real_player1 == null)
{
log.Info($"can`t found real_player, id: {group_players[0].PlayerID}");
continue;
}
if (real_player2 == null)
{
log.Info($"can`t found real_player, id: {group_players[1].PlayerID}");
continue;
}
GroupHoleStatisticsData hole_data = this.GetGroupHoleStatisticsData(group, real_player1, real_player2, data.Round, hole);
if (hole_data == null)
continue;
total += hole_data.Score;
}
return total;
}
/// <summary>
/// 获取分组每轮得分
/// </summary>
/// <param name="players">球员集合</param>
/// <param name="teamId">队伍ID</param>
/// <param name="round">轮次</param>
/// <returns>得分</returns>
public TeamRoundStatisticsData GetTeamRoundStatisticsData(List<PlayerRealModel> players, int teamId, int round)
{
TeamRoundStatisticsData result = new TeamRoundStatisticsData();
result.TeamID = teamId;
result.Round = round;
var groups = ApplicationDomainEx.PlayerInfos.Where(p => p.TeamID == teamId).GroupBy(p => p.Group);
foreach (var group in groups)
{
var group_players = group.ToList();
// 分组一定是2人一组
if (group_players.Count != 2)
continue;
PlayerRealModel real_player1 = players.FirstOrDefault(p => p.PlayerID == group_players[0].PlayerID);
PlayerRealModel real_player2 = players.FirstOrDefault(p => p.PlayerID == group_players[1].PlayerID);
if (real_player1 == null)
{
log.Info($"can`t found real_player, id: {group_players[0].PlayerID}");
continue;
}
if (real_player2 == null)
{
log.Info($"can`t found real_player, id: {group_players[1].PlayerID}");
continue;
}
int score = this.GetGroupRoundScore(group.Key, real_player1, real_player2, round);
result.GroupRoundScoreDic[group.Key] = score;
}
// 获取前五名成绩计入团队成绩
if (result.GroupRoundScoreDic.Count >= TvpStaticResource.DEFALUT_TOP_GROUP)
{
result.Score = result.GroupRoundScoreDic.Values.OrderByDescending(p => p).Take(TvpStaticResource.DEFALUT_TOP_GROUP).Sum();
}
return result;
}
/// <summary>
/// 获取分组每轮得分
/// </summary>
/// <param name="group">分组</param>
/// <param name="player1">球员1</param>
/// <param name="player2">球员2</param>
/// <param name="round">轮次</param>
/// <returns>得分</returns>
public int GetGroupRoundScore(string group, PlayerRealModel player1, PlayerRealModel player2, int round)
{
Dictionary<int, GroupHoleStatisticsData> dic = this.GetGroupHoleStatisticsDataDic(group, player1, player2, round);
return dic.Values.Sum(p => p.Score);
}
/// <summary>
/// 获取分组每洞统计数据
/// </summary>
/// <param name="group">分组</param>
/// <param name="player1">球员1</param>
/// <param name="player2">球员2</param>
/// <param name="round">轮次</param>
/// <returns>分组每洞信息字典</returns>
public Dictionary<int, GroupHoleStatisticsData> GetGroupHoleStatisticsDataDic(string group, PlayerRealModel player1, PlayerRealModel player2, int round)
{
Dictionary<int, GroupHoleStatisticsData> dic = new Dictionary<int, GroupHoleStatisticsData>();
if (player1 == null || player2 == null)
return dic;
RoundRealModel real_round1 = player1.Rounds.FirstOrDefault(p => p.No == round);
RoundRealModel real_round2 = player2.Rounds.FirstOrDefault(p => p.No == round);
if (real_round1 == null || real_round2 == null)
return dic;
foreach (HoleInfoModel holeInfo in ApplicationDomainEx.HoleInfos)
{
ScoreRealModel real_score1 = real_round1.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
ScoreRealModel real_score2 = real_round2.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
if (real_score1 == null || real_score2 == null)
continue;
if (!this.IsPlayerHoleFinished(real_round1, holeInfo.HoleID) || !this.IsPlayerHoleFinished(real_round2, holeInfo.HoleID))
continue;
GroupHoleStatisticsData data = new GroupHoleStatisticsData();
data.Group = group;
data.Player1 = player1;
data.Player2 = player2;
data.HoleInfo = holeInfo;
data.PlayerStrokes1 = real_score1.Strokes ?? 0;
data.PlayerStrokes2 = real_score2.Strokes ?? 0;
data.Strokes = (real_score1.Strokes ?? 0) + (real_score2.Strokes ?? 0);
data.Score = (real_score1.Strokes ?? 0) + (real_score2.Strokes ?? 0) - holeInfo.Par;
dic[holeInfo.HoleID] = data;
}
return dic;
}
/// <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>
public GroupHoleStatisticsData GetGroupHoleStatisticsData(string group, PlayerRealModel player1, PlayerRealModel player2, int round, int hole)
{
if (player1 == null || player2 == null)
return null;
RoundRealModel real_round1 = player1.Rounds.FirstOrDefault(p => p.No == round);
RoundRealModel real_round2 = player2.Rounds.FirstOrDefault(p => p.No == round);
if (real_round1 == null || real_round2 == null)
return null;
HoleInfoModel holeInfo = ApplicationDomainEx.HoleInfos.FirstOrDefault(p => p.HoleID == hole);
if (holeInfo == null)
return null;
ScoreRealModel real_score1 = real_round1.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
ScoreRealModel real_score2 = real_round2.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
if (real_score1 == null || real_score2 == null)
return null;
if (!this.IsPlayerHoleFinished(real_round1, holeInfo.HoleID) || !this.IsPlayerHoleFinished(real_round2, holeInfo.HoleID))
return null;
GroupHoleStatisticsData data = new GroupHoleStatisticsData();
data.Group = group;
data.Player1 = player1;
data.Player2 = player2;
data.HoleInfo = holeInfo;
data.PlayerStrokes1 = real_score1.Strokes ?? 0;
data.PlayerStrokes2 = real_score2.Strokes ?? 0;
data.Strokes = (real_score1.Strokes ?? 0) + (real_score2.Strokes ?? 0);
data.Score = (real_score1.Strokes ?? 0) + (real_score2.Strokes ?? 0) - holeInfo.Par;
return data;
}
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="player">球员</param>
/// <param name="round">轮次</param>
/// <param name="hole">洞嗯呢</param>
/// <returns>是否已经完成该洞</returns>
public bool IsPlayerHoleFinished(PlayerRealModel player, int round, int hole)
{
if (player == null || player.Rounds == null)
return false;
RoundRealModel real_round = player.Rounds.FirstOrDefault(p => p.No == hole);
return this.IsPlayerHoleFinished(real_round, hole);
}
/// <summary>
/// 球员是否完成指定洞的比赛
/// </summary>
/// <param name="real_round">轮次真实数据</param>
/// <param name="hole">洞</param>
/// <returns>是否已经完成该洞</returns>
public bool IsPlayerHoleFinished(RoundRealModel real_round, int hole)
{
if (real_round == null)
return false;
int total_hole = ApplicationDomainEx.HoleInfos.Count;
if (hole >= real_round.StartingTee && hole < real_round.StartingTee + real_round.Thru)
{
return true;
}
if ((real_round.StartingTee + real_round.Thru > total_hole) && (hole < (real_round.StartingTee + real_round.Thru) % total_hole))
{
return true;
}
return false;
}
/// <summary>
/// 更新队伍排名值
/// </summary>
/// <param name="teams">已经完成排序的队伍</param>
public void UpdateTeamPosition(IList<TeamTempModel> teams)
{
int position = 1;
for (int i = 0; i < teams.Count; i++)
{
if (teams[i].TotalScoreValue == null)
break;
if (i == 0)
{
teams[i].Position = position.ToString();
continue;
}
if (teams[i].TotalScoreValue == teams[i - 1].TotalScoreValue)
{
teams[i].Position = $"T{position}";
}
else
{
teams[i].Position = $"{position}";
++position;
}
}
}
/// <summary>
/// 更新队伍排名变化
/// </summary>
/// <param name="teams">已经完成排序的队伍</param>
public void UpdateTeamPositionChanged(IList<TeamTempModel> before, IList<TeamTempModel> after)
{
foreach (TeamTempModel after_team in after)
{
TeamTempModel before_team = before.FirstOrDefault(p => p.TeamID == after_team.TeamID);
if (before_team == null)
continue;
after_team.PositionOldIndex = before.IndexOf(before_team);
after_team.PositionNewIndex = after.IndexOf(after_team);
after_team.PositionChangedDesc = $"{after_team.PositionOldIndex} --> {after_team.PositionNewIndex}";
}
}
}
}
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
/// <param name="dir">工作文件夹</param>
/// <returns>本地数据文件名</returns>
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 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Comparer\GroupTempModelComparer.cs" />
<Compile Include="Comparer\TeamTempModelComparer.cs" />
<Compile Include="Properties\AssemblyInfo.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" />
</ItemGroup>
<ItemGroup>
......
......@@ -82,12 +82,12 @@ namespace VIZ.TVP.Golf.Storage
/// <summary>
/// 得分
/// </summary>
public int score { get; set; }
public int? score { get; set; }
/// <summary>
/// 总杆数
/// </summary>
public int strokes { get; set; }
public int? strokes { get; set; }
/// <summary>
/// 轮次节点集合
......
......@@ -22,32 +22,32 @@ namespace VIZ.TVP.Golf.Storage
/// <summary>
/// 杆数
/// </summary>
public int strokes { get; set; }
public int? strokes { get; set; }
/// <summary>
/// 标准杆
/// </summary>
public int par { get; set; }
public int? par { get; set; }
/// <summary>
/// 沙坑救球数
/// </summary>
public int bunkers { get; set; }
public int? bunkers { get; set; }
/// <summary>
/// 推杆数
/// </summary>
public int putts { get; set; }
public int? putts { get; set; }
/// <summary>
/// 开球距离
/// </summary>
public double drive { get; set; }
public double? drive { get; set; }
/// <summary>
/// 是否发球上球道 1: 是 | 0: 否 | 空: 未记录
/// </summary>
public int fairway { get; set; }
public int? fairway { get; set; }
/// <summary>
/// 将当前节点转化为XElement节点
......
......@@ -5,9 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VIZ.TVP.Golf"
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"
Title="高尔夫包装工具" Height="900" Width="1700">
Title="高尔夫包装工具" Height="950" Width="1700">
<Grid>
<module:MainView Margin="10"></module:MainView>
</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