Modification Titre tournois

Modification WPF (Ctrl +C) + Selection
This commit is contained in:
2019-03-13 22:54:39 +01:00
parent 330746b2c6
commit c23a8244da
5 changed files with 54 additions and 11 deletions

View File

@@ -12,7 +12,7 @@
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<ListView Grid.Row ="1" Margin="2" ItemsSource="{Binding Path=Reservation}"> <ListView Grid.Row ="1" Margin="2" ItemsSource="{Binding Path=Reservation}" TextSearch.TextPath="Name">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>

View File

@@ -198,7 +198,7 @@ namespace LaDOSE.DesktopApp.ViewModels
var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true); var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true);
findUser.ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate))); findUser.ForEach((e) => this.Players.AddUI(e,()=>NotifyOfPropertyChange(() => this.CanGenerate)));
findUser2.ForEach((e) => this.PlayersOptions.AddUI(e)); findUser2.ForEach((e) => this.PlayersOptions.AddUI(e,null));
} }
} }

View File

@@ -27,13 +27,13 @@
</DockPanel> </DockPanel>
<ListView Grid.Row="1" ItemsSource="{Binding Events}" x:Name="EventsList" Margin="0,0,0,5" <ListView Grid.Row="1" ItemsSource="{Binding Events}" x:Name="EventsList" Margin="0,0,0,5"
SelectedItem="{Binding SelectedWpEvent, Mode=TwoWay}"> SelectedItem="{Binding SelectedWpEvent, Mode=TwoWay}" >
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" /> <TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> <TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Date}" /> <TextBlock Margin="5,0,0,0" Text="{Binding Date, StringFormat=dd/MM/yyyy}" />
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
@@ -46,11 +46,12 @@
<ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}" <ListView Grid.Column="0" ItemsSource="{Binding ElementName=EventsList,Path=SelectedItem.WpBookings}"
x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUserDto.Name" Margin="2"> x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name" Margin="2" KeyUp="Copy">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding WpUser.Name}" /> <TextBlock Text="{Binding WpUser.Name}">
</TextBlock>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>

View File

@@ -3,15 +3,19 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using LaDOSE.DTO;
using Clipboard = System.Windows.Clipboard;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using ListViewItem = System.Windows.Controls.ListViewItem;
using UserControl = System.Windows.Controls.UserControl;
namespace LaDOSE.DesktopApp.Views namespace LaDOSE.DesktopApp.Views
{ {
@@ -27,5 +31,21 @@ namespace LaDOSE.DesktopApp.Views
} }
private void Copy(object sender, KeyEventArgs e)
{
if (sender != BookingList) return;
if (e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
CopySelectedValuesToClipboard();
}
private void CopySelectedValuesToClipboard()
{
var builder = new StringBuilder();
foreach (WPBookingDTO item in BookingList.SelectedItems)
builder.AppendLine(item.WpUser.Name);
Clipboard.SetText(builder.ToString());
}
} }
} }

View File

@@ -93,11 +93,12 @@ namespace LaDOSE.Business.Service
{ {
var currentEvent = currentWpEvent.FirstOrDefault(); var currentEvent = currentWpEvent.FirstOrDefault();
var eventDate = currentEvent.Date?.ToString("MM/dd/yy"); var eventDate = currentEvent.Date?.ToString("dd/MM/yy");
var remove = currentEvent.Date?.ToString("Mdyy"); var remove = currentEvent.Date?.ToString("Mdyy");
var url = $"{remove}{selectedGame.Id}"; var url = $"{remove}{selectedGame.Id}";
var name = $"[{eventDate}]Ranking {currentEvent.Name} {selectedGame.Name}"; var selectedEvent = FormatCurrentEventName(currentEvent.Name);
var name = $"[{eventDate}] LaDOSE.Net - {selectedEvent} - {selectedGame.Name}";
var tournament = _challongeProvider.CreateTournament(name, url).Result; var tournament = _challongeProvider.CreateTournament(name, url).Result;
@@ -146,5 +147,26 @@ namespace LaDOSE.Business.Service
return "error while creating challonge"; return "error while creating challonge";
} }
private string FormatCurrentEventName(string currentEventName)
{
if (currentEventName.Contains("-"))
{
var strings = currentEventName.Split('-');
var s = strings[strings.Length-1];
DateTime test;
if (DateTime.TryParse(s, out test))
{
var formatCurrentEventName = currentEventName.Replace(s, "");
formatCurrentEventName= formatCurrentEventName.Replace(" -", "");
return formatCurrentEventName;
}
}
return currentEventName;
}
} }
} }