Commit f84f786d by liulongfei

排序逻辑

parent 074f0cd9
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 GroupTempModelComparer : IComparer<GroupTempModel>
{
/// <summary>
/// 分组临时模型排序比较器
/// </summary>
/// <param name="playerRealModels">球员真实模型</param>
/// <param name="round">轮次</param>
public GroupTempModelComparer(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);
// 杆数少 排名靠前
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 0;
else
return total_x < total_y ? -1 : 1;
}
}
}
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;
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;
namespace VIZ.TVP.Golf.Domain
{
/// <summary>
/// 队伍临时模型比较器
/// </summary>
public class TeamTempModelComparer : IComparer<TeamTempModel>
{
/// <summary>
/// 队伍临时模型比较器
/// </summary>
/// <param name="playerRealModels">球员真实模型</param>
public TeamTempModelComparer(List<PlayerRealModel> playerRealModels)
{
this.PlayerRealModels = playerRealModels;
}
/// <summary>
/// 队伍临时模型比较器
/// </summary>
/// <param name="playerRealModels">球员真实模型</param>
/// <param name="round">轮次</param>
public TeamTempModelComparer(List<PlayerRealModel> playerRealModels, int round)
{
this.PlayerRealModels = playerRealModels;
this.Round = round;
}
/// <summary>
/// 球员真实模型
/// </summary>
public List<PlayerRealModel> PlayerRealModels { get; private set; }
/// <summary>
/// 轮次
/// </summary>
public int? Round { get; private set; }
/// <summary>
/// 比较大小
/// </summary>
public int Compare(TeamTempModel x, TeamTempModel y)
{
return this.Round == null ? this.CompareAllRound(x, y) : this.CompareWithRound(x, y, this.Round.Value);
}
/// <summary>
/// 比较大小, 所有轮次
/// </summary>
/// <remarks>
/// 1. 杆数少排名靠前
/// 2. 杆数相同时则比较第二轮成绩
/// 3. 如果再次相同,则比较第二轮由18号洞往前推的每一洞
/// </remarks>
/// <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;
}
}
return 0;
}
/// <summary>
/// 比较大小
/// </summary>
/// <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)
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)
return 0;
else
return total_x < total_y ? -1 : 1;
}
}
}
...@@ -98,15 +98,5 @@ namespace VIZ.TVP.Golf.Domain ...@@ -98,15 +98,5 @@ namespace VIZ.TVP.Golf.Domain
/// 长版小组排名 /// 长版小组排名
/// </summary> /// </summary>
public const string LongGroupRanking = "LongGroupRanking"; public const string LongGroupRanking = "LongGroupRanking";
/// <summary>
/// 人名条
/// </summary>
public const string NameBarView = "NameBarView";
/// <summary>
/// 底部人名条
/// </summary>
public const string NameBarBottomView = "NameBarBottomView";
} }
} }
...@@ -97,16 +97,16 @@ namespace VIZ.TVP.Golf.Domain ...@@ -97,16 +97,16 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region PlayersStrokes -- 总杆数 #region PlayersScore -- 总得分
private string playersStrokes; private string playersScore;
/// <summary> /// <summary>
/// 总杆数 /// 总杆数
/// </summary> /// </summary>
public string PlayersStrokes public string PlayersScore
{ {
get { return playersStrokes; } get { return playersScore; }
set { playersStrokes = value; this.RaisePropertyChanged(nameof(PlayersStrokes)); } set { playersScore = value; this.RaisePropertyChanged(nameof(PlayersScore)); }
} }
#endregion #endregion
......
...@@ -68,16 +68,16 @@ namespace VIZ.TVP.Golf.Domain ...@@ -68,16 +68,16 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region Strokes -- 总杆数 #region Score -- 得分
private int strokes; private int score;
/// <summary> /// <summary>
/// 总杆数 /// 得分
/// </summary> /// </summary>
public int Strokes public int Score
{ {
get { return strokes; } get { return score; }
set { strokes = value; this.RaisePropertyChanged(nameof(Strokes)); } set { score = value; this.RaisePropertyChanged(nameof(Score)); }
} }
#endregion #endregion
......
...@@ -82,16 +82,30 @@ namespace VIZ.TVP.Golf.Domain ...@@ -82,16 +82,30 @@ namespace VIZ.TVP.Golf.Domain
#endregion #endregion
#region TotalStrokes -- 总杆数 #region TotalScoreValue -- 总得分值
private string totalStrokes; private int totalScoreValue;
/// <summary>
/// 总得分值
/// </summary>
public int TotalScoreValue
{
get { return totalScoreValue; }
set { totalScoreValue = value; this.RaisePropertyChanged(nameof(TotalScoreValue)); }
}
#endregion
#region TotalScore -- 总得分
private string totalScore;
/// <summary> /// <summary>
/// 总杆数 /// 总杆数
/// </summary> /// </summary>
public string TotalStrokes public string TotalScore
{ {
get { return totalStrokes; } get { return totalScore; }
set { totalStrokes = value; this.RaisePropertyChanged(nameof(TotalStrokes)); } set { totalScore = value; this.RaisePropertyChanged(nameof(TotalScore)); }
} }
#endregion #endregion
......
...@@ -65,6 +65,9 @@ ...@@ -65,6 +65,9 @@
</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" />
......
...@@ -64,8 +64,10 @@ ...@@ -64,8 +64,10 @@
Content="分组洞信息版"></RadioButton> Content="分组洞信息版"></RadioButton>
<RadioButton x:Name="rb_BottomHoleInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_BottomHoleInfo" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="底部洞信息版"></RadioButton> Content="底部洞信息版"></RadioButton>
<!-- 队伍排名 --> <!-- 队伍排名 -->
<Rectangle Height="1" Fill="#44000000" Margin="0,5,0,5"></Rectangle> <Rectangle Height="1" Fill="#44000000" Margin="0,5,0,5"></Rectangle>
<RadioButton x:Name="rb_BeforeMatchTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_BeforeMatchTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="赛前队伍排名"></RadioButton> Content="赛前队伍排名"></RadioButton>
<RadioButton x:Name="rb_AfterMatchTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_AfterMatchTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
...@@ -74,7 +76,10 @@ ...@@ -74,7 +76,10 @@
Content="短版队伍排名"></RadioButton> Content="短版队伍排名"></RadioButton>
<RadioButton x:Name="rb_LongTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_LongTeamRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="长版队伍排名"></RadioButton> Content="长版队伍排名"></RadioButton>
<!-- 小组排名 -->
<Rectangle Height="1" Fill="#44000000" Margin="0,5,0,5"></Rectangle> <Rectangle Height="1" Fill="#44000000" Margin="0,5,0,5"></Rectangle>
<RadioButton x:Name="rb_BeforeMatchGroupRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_BeforeMatchGroupRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
Content="赛前分组排名"></RadioButton> Content="赛前分组排名"></RadioButton>
<RadioButton x:Name="rb_AfterMatchGroupRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}" <RadioButton x:Name="rb_AfterMatchGroupRanking" GroupName="MAIN" Style="{StaticResource RadioButton_MainView}"
......
...@@ -32,13 +32,7 @@ ...@@ -32,13 +32,7 @@
<!-- 版子操作 --> <!-- 版子操作 -->
<Border Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#44000000" Background="#66b6f2e3" BorderThickness="1" Margin="5" Padding="5"> <Border Grid.Row="0" Grid.ColumnSpan="2" BorderBrush="#44000000" Background="#66b6f2e3" BorderThickness="1" Margin="5" Padding="5">
<StackPanel Orientation="Horizontal"> <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> </StackPanel>
</Border> </Border>
<!-- 版子信息 --> <!-- 版子信息 -->
......
...@@ -48,20 +48,13 @@ ...@@ -48,20 +48,13 @@
<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="220"></RowDefinition>
<RowDefinition Height="80"></RowDefinition> <RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="220"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="80"></RowDefinition> <RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 组信息 -->
<GroupBox Padding="10">
<GroupBox.Header>
<TextBlock Text="组信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding Path=GroupPickerPanelModel}" Margin="5"></local:GroupPickerPanelNoPlayer>
</GroupBox>
<!-- 轮次 --> <!-- 轮次 -->
<GroupBox Padding="10" Grid.Row="1"> <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>
...@@ -79,6 +72,13 @@ ...@@ -79,6 +72,13 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</GroupBox> </GroupBox>
<!-- 组信息 -->
<GroupBox Padding="10" Grid.Row="1">
<GroupBox.Header>
<TextBlock Text="组信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding Path=GroupPickerPanelModel}" Margin="5"></local:GroupPickerPanelNoPlayer>
</GroupBox>
<!-- 洞得分信息 --> <!-- 洞得分信息 -->
<GroupBox Padding="10" Grid.Row="2"> <GroupBox Padding="10" Grid.Row="2">
<GroupBox.Header> <GroupBox.Header>
...@@ -114,12 +114,12 @@ ...@@ -114,12 +114,12 @@
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- 前18洞 --> <!-- 前9洞 -->
<fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60" <fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60"
Label="前18洞:" Text="{Binding Path=First18HoleStrokes,Mode=TwoWay}"></fcommon:LabelValue> Label="前9洞:" Text="{Binding Path=FirstHoleStrokes,Mode=TwoWay}"></fcommon:LabelValue>
<!-- 后18洞 --> <!-- 后9洞 -->
<fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60" <fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60"
Label="后18洞:" Text="{Binding Path=Secend18HoleStrokes,Mode=TwoWay}" Grid.Column="1"></fcommon:LabelValue> Label="后9洞:" Text="{Binding Path=SecendHoleStrokes,Mode=TwoWay}" Grid.Column="1"></fcommon:LabelValue>
<!-- 总计 --> <!-- 总计 -->
<fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60" <fcommon:LabelValue Style="{StaticResource LabelValue_Default}" LabelWidth="60"
Label="总计:" Text="{Binding Path=TotalHoleStrokes,Mode=TwoWay}" Grid.Column="2"></fcommon:LabelValue> Label="总计:" Text="{Binding Path=TotalHoleStrokes,Mode=TwoWay}" Grid.Column="2"></fcommon:LabelValue>
......
...@@ -34,6 +34,11 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,6 +34,11 @@ namespace VIZ.TVP.Golf.Module
// Field // Field
// =================================================================================== // ===================================================================================
/// <summary>
/// 上下半场每场洞数
/// </summary>
public const int FIRST_SECEND_HOLE_COUNT = 9;
// =================================================================================== // ===================================================================================
// Property // Property
// =================================================================================== // ===================================================================================
...@@ -80,30 +85,30 @@ namespace VIZ.TVP.Golf.Module ...@@ -80,30 +85,30 @@ namespace VIZ.TVP.Golf.Module
#endregion #endregion
#region First18HoleStrokes -- 18洞总杆数 #region FirstHoleStrokes -- 上半洞总杆数
private string first18HoleStrokes; private string firstHoleStrokes;
/// <summary> /// <summary>
/// 前18洞总杆数 /// 前18洞总杆数
/// </summary> /// </summary>
public string First18HoleStrokes public string FirstHoleStrokes
{ {
get { return first18HoleStrokes; } get { return firstHoleStrokes; }
set { first18HoleStrokes = value; this.RaisePropertyChanged(nameof(First18HoleStrokes)); } set { firstHoleStrokes = value; this.RaisePropertyChanged(nameof(FirstHoleStrokes)); }
} }
#endregion #endregion
#region Secend18HoleStrokes -- 18洞中杆数 #region SecendHoleStrokes -- 下半洞总杆数
private string secend18HoleStrokes; private string secendHoleStrokes;
/// <summary> /// <summary>
/// 后18洞中杆数 /// 后18洞中杆数
/// </summary> /// </summary>
public string Secend18HoleStrokes public string SecendHoleStrokes
{ {
get { return secend18HoleStrokes; } get { return secendHoleStrokes; }
set { secend18HoleStrokes = value; this.RaisePropertyChanged(nameof(Secend18HoleStrokes)); } set { secendHoleStrokes = value; this.RaisePropertyChanged(nameof(SecendHoleStrokes)); }
} }
#endregion #endregion
...@@ -205,19 +210,19 @@ namespace VIZ.TVP.Golf.Module ...@@ -205,19 +210,19 @@ namespace VIZ.TVP.Golf.Module
{ {
if (this.GroupHoleTempModels == null || this.GroupHoleTempModels.Count == 0) if (this.GroupHoleTempModels == null || this.GroupHoleTempModels.Count == 0)
{ {
this.First18HoleStrokes = null; this.FirstHoleStrokes = null;
this.Secend18HoleStrokes = null; this.SecendHoleStrokes = null;
this.TotalHoleStrokes = null; this.TotalHoleStrokes = null;
return; return;
} }
int first18 = this.GroupHoleTempModels.Take(18).Sum(p => ValueHelper.ConvertValue<int>(p.TotalStrokes)); int first = this.GroupHoleTempModels.Take(FIRST_SECEND_HOLE_COUNT).Sum(p => ValueHelper.ConvertValue<int>(p.TotalStrokes));
int secend18 = this.GroupHoleTempModels.Skip(18).Take(18).Sum(p => ValueHelper.ConvertValue<int>(p.TotalStrokes)); int secend = this.GroupHoleTempModels.Skip(FIRST_SECEND_HOLE_COUNT).Take(FIRST_SECEND_HOLE_COUNT).Sum(p => ValueHelper.ConvertValue<int>(p.TotalStrokes));
this.First18HoleStrokes = first18.ToString(); this.FirstHoleStrokes = first.ToString();
this.Secend18HoleStrokes = secend18.ToString(); this.SecendHoleStrokes = secend.ToString();
this.TotalHoleStrokes = (first18 + secend18).ToString(); this.TotalHoleStrokes = (first + secend).ToString();
} }
#endregion #endregion
...@@ -232,10 +237,18 @@ namespace VIZ.TVP.Golf.Module ...@@ -232,10 +237,18 @@ 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); 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)
{
this.GroupHoleTempModels = groupHoleTempModels;
// 统计
this.Summary();
return;
}
foreach (HoleInfoModel holeInfo in ApplicationDomainEx.HoleInfos) foreach (HoleInfoModel holeInfo in ApplicationDomainEx.HoleInfos)
{ {
GroupHoleTempModel model = new GroupHoleTempModel(); GroupHoleTempModel model = new GroupHoleTempModel();
...@@ -243,7 +256,6 @@ namespace VIZ.TVP.Golf.Module ...@@ -243,7 +256,6 @@ namespace VIZ.TVP.Golf.Module
model.Par = holeInfo.Par; model.Par = holeInfo.Par;
int total = 0; int total = 0;
foreach (PlayerInfoModel player in players) foreach (PlayerInfoModel player in players)
{ {
PlayerRealModel player_real = list.FirstOrDefault(p => p.PlayerID == player.PlayerID); PlayerRealModel player_real = list.FirstOrDefault(p => p.PlayerID == player.PlayerID);
...@@ -254,8 +266,12 @@ namespace VIZ.TVP.Golf.Module ...@@ -254,8 +266,12 @@ namespace VIZ.TVP.Golf.Module
if (round_real == null) if (round_real == null)
continue; continue;
total += round_real.Today; ScoreRealModel score_real = round_real.Scores.FirstOrDefault(p => p.Hole == holeInfo.HoleID);
model.TotalStrokesDetail += $"{player.Name}: {round_real.Today} | "; if (score_real == null)
continue;
total += score_real.Strokes;
model.TotalStrokesDetail += $"{player.Name}: {score_real.Strokes} | ";
} }
model.TotalStrokes = total.ToString(); model.TotalStrokes = total.ToString();
...@@ -267,6 +283,10 @@ namespace VIZ.TVP.Golf.Module ...@@ -267,6 +283,10 @@ namespace VIZ.TVP.Golf.Module
// 统计 // 统计
this.Summary(); this.Summary();
// 更新其他信息
this.GroupPickerPanelModel.UpdatePlayersProperty();
} }
} }
} }
...@@ -44,51 +44,71 @@ ...@@ -44,51 +44,71 @@
</Border> </Border>
<!-- 版子信息 --> <!-- 版子信息 -->
<Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5"> <Border Grid.Row="1" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
<ScrollViewer VerticalScrollBarVisibility="Auto"> <Grid>
<Grid> <Grid.RowDefinitions>
<Grid.RowDefinitions> <RowDefinition Height="80"></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>
<!-- 队伍1 --> <!-- 轮次 -->
<GroupBox Padding="10"> <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>
<TextBlock Text="预设:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"></TextBlock>
<StackPanel Grid.Column="1" Orientation="Horizontal"> <StackPanel Grid.Column="1" Margin="5,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" Width="240" <ComboBox Height="30" Width="240" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Rounds}}"></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}" SelectedValue="{Binding Group,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Groups}}"> ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Groups}}">
</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>
</GroupBox> </GroupBox>
<GroupBox Grid.Row="1" Padding="10"> <!-- 分组1 -->
<GroupBox.Header> <GroupBox Grid.Row="2" Padding="10">
<TextBlock Text="分组1" FontSize="18" FontWeight="Bold"></TextBlock> <GroupBox.Header>
</GroupBox.Header> <TextBlock Text="分组1" FontSize="18" FontWeight="Bold"></TextBlock>
<local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel1}"></local:GroupPickerPanelNoPlayer> </GroupBox.Header>
</GroupBox> <local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel1}"></local:GroupPickerPanelNoPlayer>
<GroupBox Grid.Row="2" Padding="10"> </GroupBox>
<GroupBox.Header> <!-- 分组2 -->
<TextBlock Text="分组2" FontSize="18" FontWeight="Bold"></TextBlock> <GroupBox Grid.Row="3" Padding="10">
</GroupBox.Header> <GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel2}"></local:GroupPickerPanelNoPlayer> <TextBlock Text="分组2" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox> </GroupBox.Header>
</Grid> <local:GroupPickerPanelNoPlayer DataContext="{Binding GroupPickerPanelModel2}"></local:GroupPickerPanelNoPlayer>
</ScrollViewer> </GroupBox>
</Grid>
</Border> </Border>
<!-- 示意图 --> <!-- 示意图 -->
<Border Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5"> <Border Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Padding="5" BorderBrush="#44000000" BorderThickness="1" Margin="5">
......
...@@ -32,6 +32,20 @@ namespace VIZ.TVP.Golf.Module ...@@ -32,6 +32,20 @@ namespace VIZ.TVP.Golf.Module
// Property // Property
// =================================================================================== // ===================================================================================
#region SelectedRound -- 选中的轮次
private int selectedRound;
/// <summary>
/// 选中的轮次
/// </summary>
public int SelectedRound
{
get { return selectedRound; }
set { selectedRound = value; this.RaisePropertyChanged(nameof(SelectedRound)); }
}
#endregion
#region Group -- 分组 #region Group -- 分组
private string group; private string group;
...@@ -113,11 +127,13 @@ namespace VIZ.TVP.Golf.Module ...@@ -113,11 +127,13 @@ 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, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, this.SelectedRound, list);
this.GroupPickerPanelModel1.UpdatePlayersProperty();
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, this.SelectedRound, list);
this.GroupPickerPanelModel2.UpdatePlayersProperty();
} }
#endregion #endregion
...@@ -144,11 +160,11 @@ namespace VIZ.TVP.Golf.Module ...@@ -144,11 +160,11 @@ namespace VIZ.TVP.Golf.Module
{ {
List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName); List<PlayerRealModel> list = this.realDataService.LoadPlayerRealModelFormLocal(fileName);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel1?.Player2, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player1, this.SelectedRound, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, list); this.UpdatePlayerTempModel(this.GroupPickerPanelModel2?.Player2, this.SelectedRound, list);
}); });
}); });
} }
......
...@@ -142,7 +142,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -142,7 +142,7 @@ namespace VIZ.TVP.Golf.Module
} }
temp_model.PlayersDisplayName = string.Join(" / ", temp_model.Players.Select(p => p.Name)); temp_model.PlayersDisplayName = string.Join(" / ", temp_model.Players.Select(p => p.Name));
List<int> player_ids = temp_model.Players.Select(p => p.PlayerID).ToList(); List<int> player_ids = temp_model.Players.Select(p => p.PlayerID).ToList();
temp_model.PlayersStrokes = list.Where(p => player_ids.Contains(p.PlayerID)).Sum(p => p.Strokes).ToString(); 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; temp_model.TeamLogo = ApplicationDomainEx.TeamInfos.FirstOrDefault(p => p.TeamID == team_group.Key)?.Logo;
groupTempModels.Add(temp_model); groupTempModels.Add(temp_model);
......
<UserControl x:Class="VIZ.TVP.Golf.Module.NameBarBottomView"
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: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"
xmlns:core="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
d:Background="White"
d:DataContext="{d:DesignInstance Type=local:NameBarBottomViewModel}"
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_team" Type="Relative" WorkPath="picture/team"></core:String2ImageSourceConverter>
<core:String2ImageSourceConverter x:Key="String2ImageSourceConverter_player" 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="220"></RowDefinition>
</Grid.RowDefinitions>
<!-- 组信息 -->
<GroupBox Padding="10">
<GroupBox.Header>
<TextBlock Text="组信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding Path=GroupPickerPanelModel}" Margin="5"></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/NameBarBottom.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>
/// NameBarBottomView.xaml 的交互逻辑
/// </summary>
public partial class NameBarBottomView : UserControl
{
public NameBarBottomView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new NameBarBottomViewModel());
}
}
}
<UserControl x:Class="VIZ.TVP.Golf.Module.NameBarView"
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: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"
xmlns:core="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
d:Background="White"
d:DataContext="{d:DesignInstance Type=local:NameBarViewModel}"
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_team" Type="Relative" WorkPath="picture/team"></core:String2ImageSourceConverter>
<core:String2ImageSourceConverter x:Key="String2ImageSourceConverter_player" 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="220"></RowDefinition>
<RowDefinition Height="170"></RowDefinition>
<RowDefinition Height="100"></RowDefinition>
</Grid.RowDefinitions>
<!-- 组信息 -->
<GroupBox Padding="10">
<GroupBox.Header>
<TextBlock Text="组信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:GroupPickerPanelNoPlayer DataContext="{Binding Path=GroupPickerPanelModel}" Margin="5"></local:GroupPickerPanelNoPlayer>
</GroupBox>
<!-- 洞信息 -->
<GroupBox Grid.Row="1" Padding="10">
<GroupBox.Header>
<TextBlock Text="洞信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:HolePickerPanelNoPicture DataContext="{Binding Path=HolePickerPanelNoPictureModel}" Grid.Row="1"></local:HolePickerPanelNoPicture>
</GroupBox>
<!-- 其他信息 -->
<GroupBox Grid.Row="2" Padding="10">
<GroupBox.Header>
<TextBlock Text="其他信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<local:DetailPanel DataContext="{Binding DetailPanelModel}"></local:DetailPanel>
</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/NameBar1.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>
/// NameBarView.xaml 的交互逻辑
/// </summary>
public partial class NameBarView : UserControl
{
public NameBarView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new NameBarViewModel());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.TVP.Golf.Domain;
namespace VIZ.TVP.Golf.Module
{
/// <summary>
/// 底部名条视图模型
/// </summary>
public class NameBarBottomViewModel : PackageViewModelBase
{
// ===================================================================================
// Property
// ===================================================================================
#region GroupPickerPanelModel -- 分组选择模型
private GroupPickerPanelModel groupPickerPanelModel = new GroupPickerPanelModel();
/// <summary>
/// 分组选择模型
/// </summary>
public GroupPickerPanelModel GroupPickerPanelModel
{
get { return groupPickerPanelModel; }
set { groupPickerPanelModel = value; this.RaisePropertyChanged(nameof(GroupPickerPanelModel)); }
}
#endregion
// ===================================================================================
// 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.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player1, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player2, list);
}
#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);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player1, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player2, list);
});
});
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
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 class NameBarViewModel : PackageViewModelBase
{
public NameBarViewModel()
{
}
// ===================================================================================
// Property
// ===================================================================================
#region GroupPickerPanelModel -- 分组选择模型
private GroupPickerPanelModel groupPickerPanelModel = new GroupPickerPanelModel();
/// <summary>
/// 分组选择模型
/// </summary>
public GroupPickerPanelModel GroupPickerPanelModel
{
get { return groupPickerPanelModel; }
set { groupPickerPanelModel = value; this.RaisePropertyChanged(nameof(GroupPickerPanelModel)); }
}
#endregion
#region HolePickerPanelNoPictureModel -- 洞选择模型
private HolePickerPanelNoPictureModel holePickerPanelNoPictureModel = new HolePickerPanelNoPictureModel();
/// <summary>
/// 洞选择模型
/// </summary>
public HolePickerPanelNoPictureModel HolePickerPanelNoPictureModel
{
get { return holePickerPanelNoPictureModel; }
set { holePickerPanelNoPictureModel = value; this.RaisePropertyChanged(nameof(HolePickerPanelNoPictureModel)); }
}
#endregion
#region DetailPanelModel -- 描述面板模型
private DetailPanelModel detailPanelModel = new DetailPanelModel();
/// <summary>
/// 描述面板模型
/// </summary>
public DetailPanelModel DetailPanelModel
{
get { return detailPanelModel; }
set { detailPanelModel = value; this.RaisePropertyChanged(nameof(DetailPanelModel)); }
}
#endregion
// ===================================================================================
// 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.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player1, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player2, list);
}
#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);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player1, list);
this.UpdatePlayerTempModel(this.GroupPickerPanelModel?.Player2, list);
});
});
}
#endregion
}
}
...@@ -137,18 +137,32 @@ namespace VIZ.TVP.Golf.Module ...@@ -137,18 +137,32 @@ namespace VIZ.TVP.Golf.Module
/// 更新球员临时数据 /// 更新球员临时数据
/// </summary> /// </summary>
/// <param name="tempModel">临时模型</param> /// <param name="tempModel">临时模型</param>
/// <param name="round">轮次</param>
/// <param name="realModels">实时模型集合</param> /// <param name="realModels">实时模型集合</param>
protected void UpdatePlayerTempModel(PlayerTempModel tempModel, List<PlayerRealModel> realModels) protected void UpdatePlayerTempModel(PlayerTempModel tempModel, int round, List<PlayerRealModel> realModels)
{ {
if (tempModel == null || realModels == null || tempModel.PlayerID <= 0 || realModels.Count == 0) if (tempModel == null || realModels == null || tempModel.PlayerID <= 0 || realModels.Count == 0)
return; return;
PlayerRealModel realModel = realModels.FirstOrDefault(p => p.PlayerID == tempModel.PlayerID); PlayerRealModel realModel = realModels.FirstOrDefault(p => p.PlayerID == tempModel.PlayerID);
if (realModel == null)
return;
if (realModel != null) RoundRealModel roundModel = realModel.Rounds.FirstOrDefault(p => p.No == round);
{ if (roundModel == null)
tempModel.Strokes = realModel.Strokes; 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}");
} }
} }
} }
...@@ -47,28 +47,8 @@ ...@@ -47,28 +47,8 @@
<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="100"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 轮次信息 -->
<GroupBox Padding="10">
<GroupBox.Header>
<TextBlock Text="轮次信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="轮次:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1"></TextBlock>
<StackPanel Grid.Column="1" Margin="10,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Width="220" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Rounds}}"></ComboBox>
</StackPanel>
</Grid>
</GroupBox>
<!-- 排名 --> <!-- 排名 -->
<GroupBox Padding="10" Grid.Row="1"> <GroupBox Padding="10" Grid.Row="1">
...@@ -86,8 +66,8 @@ ...@@ -86,8 +66,8 @@
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}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数" Width="100" Binding="{Binding Path=TotalStrokes}"></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"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
......
...@@ -34,5 +34,31 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,5 +34,31 @@ namespace VIZ.TVP.Golf.Module
// Private Function // Private Function
// =================================================================================== // ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// </summary>
/// <param name="list">球员真实模型</param>
protected override 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 = real_players.Sum(p => p.Score);
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
}
// 赛后比较所有的轮次
TeamTempModelComparer comparer = new TeamTempModelComparer(list);
teamTempModels.Sort(comparer);
this.TeamTempModels = teamTempModels.ToObservableCollection();
}
} }
} }
...@@ -47,29 +47,8 @@ ...@@ -47,29 +47,8 @@
<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="100"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 轮次信息 -->
<GroupBox Padding="10">
<GroupBox.Header>
<TextBlock Text="轮次信息" FontSize="18" FontWeight="Bold"></TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="轮次:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1"></TextBlock>
<StackPanel Grid.Column="1" Margin="10,0,10,0" HorizontalAlignment="Left" Orientation="Horizontal">
<ComboBox Height="30" Width="220" VerticalContentAlignment="Center"
SelectedValue="{Binding Path=SelectedRound,Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.Rounds}}"></ComboBox>
</StackPanel>
</Grid>
</GroupBox>
<!-- 排名 --> <!-- 排名 -->
<GroupBox Padding="10" Grid.Row="1"> <GroupBox Padding="10" Grid.Row="1">
<GroupBox.Header> <GroupBox.Header>
...@@ -86,8 +65,8 @@ ...@@ -86,8 +65,8 @@
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}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数" Width="100" Binding="{Binding Path=TotalStrokes}"></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"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
......
...@@ -34,5 +34,40 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,5 +34,40 @@ namespace VIZ.TVP.Golf.Module
// Private Function // Private Function
// =================================================================================== // ===================================================================================
/// <summary>
/// 更新队伍临时模型
/// </summary>
/// <param name="list">球员真实模型</param>
protected override 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 == 1);
if (real_round == null)
continue;
total += real_round.Today;
}
temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
}
// 赛前比较第一轮
TeamTempModelComparer comparer = new TeamTempModelComparer(list, 1);
teamTempModels.Sort(comparer);
this.TeamTempModels = teamTempModels.ToObservableCollection();
}
} }
} }
...@@ -86,9 +86,9 @@ ...@@ -86,9 +86,9 @@
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}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数" Width="100" Binding="{Binding Path=TotalStrokes}"></DataGridTextColumn> <DataGridTextColumn Header="得分" Width="100" Binding="{Binding Path=TotalScore}"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="c1" Header="Logo" Width="240" <DataGridComboBoxColumn Header="Logo" Width="240"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
</DataGrid.Columns> </DataGrid.Columns>
......
...@@ -86,8 +86,8 @@ ...@@ -86,8 +86,8 @@
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}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="队伍名称" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="队伍名称" Width="200" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="总杆数" Width="100" Binding="{Binding Path=TotalStrokes}"></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"
ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}" ItemsSource="{Binding Source={x:Static domain:TvpStaticResource.TeamLogos}}"
SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn> SelectedValueBinding="{Binding Path=Logo}"></DataGridComboBoxColumn>
......
...@@ -34,13 +34,12 @@ namespace VIZ.TVP.Golf.Module ...@@ -34,13 +34,12 @@ namespace VIZ.TVP.Golf.Module
// =================================================================================== // ===================================================================================
/// <summary> /// <summary>
/// 更新临时模型 /// 更新队伍临时模型
/// </summary> /// </summary>
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected void UpdateGroupTempModels(List<PlayerRealModel> list) protected override void UpdateTeamTempModels(List<PlayerRealModel> list)
{ {
ObservableCollection<TeamTempModel> teamTempModels = new ObservableCollection<TeamTempModel>(); List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
List<TeamTempModel> temp_list = new List<TeamTempModel>();
foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos) foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos)
{ {
...@@ -49,17 +48,24 @@ namespace VIZ.TVP.Golf.Module ...@@ -49,17 +48,24 @@ namespace VIZ.TVP.Golf.Module
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList(); var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList();
temp_model.TotalStrokes = real_players.Sum(p => p.Strokes).ToString(); int total = 0;
temp_list.Add(temp_model); foreach (PlayerRealModel real_player in real_players)
} {
RoundRealModel real_round = real_player.Rounds.FirstOrDefault(p => p.No == this.SelectedRound);
if (real_round == null)
continue;
temp_list = temp_list.Take(5).ToList(); total += real_round.Today;
foreach (TeamTempModel temp in temp_list) }
{
teamTempModels.Add(temp); temp_model.TotalScore = this.GetScoreString(total);
teamTempModels.Add(temp_model);
} }
this.TeamTempModels = teamTempModels; TeamTempModelComparer comparer = new TeamTempModelComparer(list, this.SelectedRound);
teamTempModels.Sort(comparer);
this.TeamTempModels = teamTempModels.Take(5).ToObservableCollection();
} }
} }
} }
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
...@@ -127,7 +128,7 @@ namespace VIZ.TVP.Golf.Module ...@@ -127,7 +128,7 @@ namespace VIZ.TVP.Golf.Module
/// <param name="list">球员真实模型</param> /// <param name="list">球员真实模型</param>
protected virtual void UpdateTeamTempModels(List<PlayerRealModel> list) protected virtual void UpdateTeamTempModels(List<PlayerRealModel> list)
{ {
ObservableCollection<TeamTempModel> teamTempModels = new ObservableCollection<TeamTempModel>(); List<TeamTempModel> teamTempModels = new List<TeamTempModel>();
foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos) foreach (TeamInfoModel info_model in ApplicationDomainEx.TeamInfos)
{ {
...@@ -136,11 +137,24 @@ namespace VIZ.TVP.Golf.Module ...@@ -136,11 +137,24 @@ namespace VIZ.TVP.Golf.Module
var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList(); var real_players = list.Where(p => p.TeamInfoModel != null && p.TeamInfoModel.TeamID == temp_model.TeamID).ToList();
temp_model.TotalStrokes = real_players.Sum(p => p.Strokes).ToString(); 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); teamTempModels.Add(temp_model);
} }
this.TeamTempModels = teamTempModels; TeamTempModelComparer comparer = new TeamTempModelComparer(list, this.SelectedRound);
teamTempModels.Sort(comparer);
this.TeamTempModels = teamTempModels.ToObservableCollection();
} }
} }
} }
\ No newline at end of file
...@@ -137,18 +137,10 @@ ...@@ -137,18 +137,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Package\NameBar\View\NameBarBottomView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Widgets\Detail\DetailPanel.xaml"> <Page Include="Widgets\Detail\DetailPanel.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Package\NameBar\View\NameBarView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Widgets\Group\GroupPickerPanelNoPlayer.xaml"> <Page Include="Widgets\Group\GroupPickerPanelNoPlayer.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -264,18 +256,10 @@ ...@@ -264,18 +256,10 @@
<Compile Include="Package\TeamInfo\View\TeamInfoView.xaml.cs"> <Compile Include="Package\TeamInfo\View\TeamInfoView.xaml.cs">
<DependentUpon>TeamInfoView.xaml</DependentUpon> <DependentUpon>TeamInfoView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Package\NameBar\ViewModel\NameBarBottomViewModel.cs" />
<Compile Include="Package\NameBar\View\NameBarBottomView.xaml.cs">
<DependentUpon>NameBarBottomView.xaml</DependentUpon>
</Compile>
<Compile Include="Package\TeamRanking\TeamRankingViewModelBase.cs" /> <Compile Include="Package\TeamRanking\TeamRankingViewModelBase.cs" />
<Compile Include="Widgets\Detail\DetailPanel.xaml.cs"> <Compile Include="Widgets\Detail\DetailPanel.xaml.cs">
<DependentUpon>DetailPanel.xaml</DependentUpon> <DependentUpon>DetailPanel.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Package\NameBar\ViewModel\NameBarViewModel.cs" />
<Compile Include="Package\NameBar\View\NameBarView.xaml.cs">
<DependentUpon>NameBarView.xaml</DependentUpon>
</Compile>
<Compile Include="Setup\Provider\Setup\AppSetup_ClearLocalData.cs" /> <Compile Include="Setup\Provider\Setup\AppSetup_ClearLocalData.cs" />
<Compile Include="Widgets\Detail\DetailPanelModel.cs" /> <Compile Include="Widgets\Detail\DetailPanelModel.cs" />
<Compile Include="Widgets\Group\GroupPickerPanelNoPlayer.xaml.cs"> <Compile Include="Widgets\Group\GroupPickerPanelNoPlayer.xaml.cs">
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
d:Background="White" d:Background="White"
d:DataContext="{d:DesignInstance Type=local:GroupPickerPanelModel}" d:DataContext="{d:DesignInstance Type=local:GroupPickerPanelModel}"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="700"> d:DesignHeight="300" d:DesignWidth="1000">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
...@@ -80,13 +80,13 @@ ...@@ -80,13 +80,13 @@
Margin="0,0,5,0"></TextBlock> Margin="0,0,5,0"></TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3" <TextBox Grid.Row="0" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3"
Text="{Binding Player1.Name,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox> Text="{Binding Player1.Name,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox>
<!-- 杆数 --> <!-- 得分 -->
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal">
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image> <Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image>
<TextBlock Text="杆数:" ></TextBlock> <TextBlock Text="得分:" ></TextBlock>
</StackPanel> </StackPanel>
<TextBox Grid.Row="1" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3" <TextBox Grid.Row="1" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3"
Text="{Binding Player1.Strokes,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox> Text="{Binding Player1.Score,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox>
<!-- 照片 --> <!-- 照片 -->
<TextBlock Text="照片:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" <TextBlock Text="照片:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0"
Margin="0,0,5,0"></TextBlock> Margin="0,0,5,0"></TextBlock>
...@@ -117,13 +117,13 @@ ...@@ -117,13 +117,13 @@
Margin="0,0,5,0"></TextBlock> Margin="0,0,5,0"></TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3" <TextBox Grid.Row="0" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3"
Text="{Binding Player2.Name,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox> Text="{Binding Player2.Name,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox>
<!-- 杆数 --> <!-- 得分 -->
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal">
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image> <Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image>
<TextBlock Text="杆数:" ></TextBlock> <TextBlock Text="得分:" ></TextBlock>
</StackPanel> </StackPanel>
<TextBox Grid.Row="1" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3" <TextBox Grid.Row="1" Grid.Column="1" Height="30" AcceptsReturn="False" TextWrapping="NoWrap" Padding="3"
Text="{Binding Player2.Strokes,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox> Text="{Binding Player2.Score,Mode=TwoWay}" VerticalContentAlignment="Center"></TextBox>
<!-- 照片 --> <!-- 照片 -->
<TextBlock Text="照片:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" <TextBlock Text="照片:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0"
Margin="0,0,5,0"></TextBlock> Margin="0,0,5,0"></TextBlock>
......
...@@ -119,16 +119,16 @@ namespace VIZ.TVP.Golf.Module ...@@ -119,16 +119,16 @@ namespace VIZ.TVP.Golf.Module
#endregion #endregion
#region PlayersStrokes -- 组成员杆数 #region PlayersScore -- 组成员得分
private string playersStrokes; private string playersScore;
/// <summary> /// <summary>
/// 组成员杆数 /// 组成员得分
/// </summary> /// </summary>
public string PlayersStrokes public string PlayersScore
{ {
get { return playersStrokes; } get { return playersScore; }
set { playersStrokes = value; this.RaisePropertyChanged(nameof(PlayersStrokes)); } set { playersScore = value; this.RaisePropertyChanged(nameof(PlayersScore)); }
} }
#endregion #endregion
...@@ -213,25 +213,21 @@ namespace VIZ.TVP.Golf.Module ...@@ -213,25 +213,21 @@ 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.Strokes = 0; 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.Strokes = 0; this.Player2.Score = 0;
this.PlayersDisplayName = null; this.PlayersDisplayName = null;
this.PlayersStrokes = null; this.PlayersScore = null;
} }
// ===================================================================================
// Private Action
// ===================================================================================
/// <summary> /// <summary>
/// 更新球员集合属性 /// 更新球员集合属性
/// </summary> /// </summary>
private void UpdatePlayersProperty() public void UpdatePlayersProperty()
{ {
// 组成员 // 组成员
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -250,8 +246,8 @@ namespace VIZ.TVP.Golf.Module ...@@ -250,8 +246,8 @@ namespace VIZ.TVP.Golf.Module
this.PlayersDisplayName = sb.ToString(); this.PlayersDisplayName = sb.ToString();
// 总杆数 // 总杆数
int strokes = this.Player1?.Strokes ?? 0 + this.Player2?.Strokes ?? 0; int strokes = this.Player1?.Score ?? 0 + this.Player2?.Score ?? 0;
this.PlayersStrokes = strokes == 0 ? "E" : strokes > 0 ? $"+{strokes}" : $"-{strokes}"; this.PlayersScore = strokes == 0 ? "E" : strokes > 0 ? $"+{strokes}" : $"-{strokes}";
} }
} }
} }
...@@ -42,13 +42,13 @@ ...@@ -42,13 +42,13 @@
<TextBlock Text="成员:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="1"></TextBlock> <TextBlock Text="成员:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="1"></TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" <TextBox Grid.Row="1" Grid.Column="1" Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center"
Text="{Binding Path=PlayersDisplayName,Mode=TwoWay}" Padding="3"></TextBox> Text="{Binding Path=PlayersDisplayName,Mode=TwoWay}" Padding="3"></TextBox>
<!-- 杆数 --> <!-- 得分 -->
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" Margin="0,0,5,0" Orientation="Horizontal">
<Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image> <Image Width="16" Height="16" Source="/VIZ.TVP.Golf.Module.Resource;component/Icons/refresh_16x16.png" Margin="0,0,5,0"></Image>
<TextBlock Text="杆数:" ></TextBlock> <TextBlock Text="得分:" ></TextBlock>
</StackPanel> </StackPanel>
<TextBox Grid.Row="2" Grid.Column="1" Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" <TextBox Grid.Row="2" Grid.Column="1" Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center"
Text="{Binding Path=PlayersStrokes,Mode=TwoWay}" Padding="3"></TextBox> Text="{Binding Path=PlayersScore,Mode=TwoWay}" Padding="3"></TextBox>
<!-- 球队Logo --> <!-- 球队Logo -->
<TextBlock Text="球队Logo:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="3"></TextBlock> <TextBlock Text="球队Logo:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="3"></TextBlock>
<ComboBox Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" Grid.Row="3" Grid.Column="1" <ComboBox Height="30" Margin="5,0,18,0" VerticalContentAlignment="Center" Grid.Row="3" Grid.Column="1"
......
...@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1 ...@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00-Doc", "00-Doc", "{CAE00ECF-BA01-4461-AE78-617D2977BEA0}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00-Doc", "00-Doc", "{CAE00ECF-BA01-4461-AE78-617D2977BEA0}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
高尔夫球数据获取api.xml = 高尔夫球数据获取api.xml 高尔夫球数据获取api.xml = 高尔夫球数据获取api.xml
高尔夫球数据获取_test.xml = 高尔夫球数据获取_test.xml
EndProjectSection EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-Lib", "05-Lib", "{5EC530D3-BA38-4C9A-AD51-4F458373A455}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-Lib", "05-Lib", "{5EC530D3-BA38-4C9A-AD51-4F458373A455}"
......
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