From c23a8244dab143aef9cc7ccbe9363d6c010b735f Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Wed, 13 Mar 2019 22:54:39 +0100 Subject: [PATCH] Modification Titre tournois Modification WPF (Ctrl +C) + Selection --- .../UserControls/BookingUserControl.xaml | 2 +- .../ViewModels/WordPressViewModel.cs | 2 +- .../Views/WordPressView.xaml | 11 ++++---- .../Views/WordPressView.xaml.cs | 24 +++++++++++++++-- .../Service/WordPressService.cs | 26 +++++++++++++++++-- 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/UserControls/BookingUserControl.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/UserControls/BookingUserControl.xaml index 2f44ae2..a89b7c9 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/UserControls/BookingUserControl.xaml +++ b/LaDOSE.Src/LaDOSE.DesktopApp/UserControls/BookingUserControl.xaml @@ -12,7 +12,7 @@ - + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs index 75949c8..686b649 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/WordPressViewModel.cs @@ -198,7 +198,7 @@ namespace LaDOSE.DesktopApp.ViewModels var findUser2 = FindUser(SelectedWpEvent.Id, SelectedGame,true); 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)); } } diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml index 7c8a664..0a24d30 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml @@ -27,13 +27,13 @@ + SelectedItem="{Binding SelectedWpEvent, Mode=TwoWay}" > - + @@ -46,11 +46,12 @@ + x:Name="BookingList" IsTextSearchEnabled="True" TextSearch.TextPath="WpUser.Name" Margin="2" KeyUp="Copy"> - - + + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml.cs b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml.cs index d775dbf..7d8c07a 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/WordPressView.xaml.cs @@ -3,15 +3,19 @@ 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.Forms; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; 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 { @@ -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()); + } } } diff --git a/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs b/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs index b743485..4cf17b3 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/WordPressService.cs @@ -93,11 +93,12 @@ namespace LaDOSE.Business.Service { 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 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; @@ -146,5 +147,26 @@ namespace LaDOSE.Business.Service 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; + } } } \ No newline at end of file