From d1b7974d42a1fc9b7e132dec232d21a080513f92 Mon Sep 17 00:00:00 2001 From: Kalakoi Date: Fri, 21 Jun 2019 14:49:37 -0400 Subject: [PATCH] Add files via upload --- src/App.config | 18 ++ src/App.xaml | 9 + src/App.xaml.cs | 17 ++ src/FriendSummary.xaml | 32 ++++ src/FriendSummary.xaml.cs | 76 +++++++++ src/Kalakoi.Xbox.App.csproj | 199 +++++++++++++++++++++++ src/MVVM/ModelBase.cs | 19 +++ src/MVVM/PropertyChangedBase.cs | 16 ++ src/MVVM/RelayCommand.cs | 39 +++++ src/Models/ConversationModel.cs | 48 ++++++ src/Models/FriendsListModel.cs | 91 +++++++++++ src/Models/InputBoxModel.cs | 89 ++++++++++ src/Models/LauncherModel.cs | 26 +++ src/Models/MainWindowModel.cs | 52 ++++++ src/Models/MassMessageModel.cs | 83 ++++++++++ src/Models/MessengerModel.cs | 48 ++++++ src/Models/ProfileViewerModel.cs | 121 ++++++++++++++ src/Properties/AssemblyInfo.cs | 55 +++++++ src/Properties/Resources.Designer.cs | 71 ++++++++ src/Properties/Resources.resx | 117 +++++++++++++ src/Properties/Settings.Designer.cs | 38 +++++ src/Properties/Settings.settings | 9 + src/TestFriendModel.cs | 27 +++ src/TestFriendView.xaml | 25 +++ src/TestFriendView.xaml.cs | 27 +++ src/TestFriendViewModel.cs | 28 ++++ src/ViewModels/ConversationViewModel.cs | 45 +++++ src/ViewModels/FriendsListViewModel.cs | 87 ++++++++++ src/ViewModels/InputBoxViewModel.cs | 68 ++++++++ src/ViewModels/LauncherViewModel.cs | 41 +++++ src/ViewModels/MainWindowViewModel.cs | 64 ++++++++ src/ViewModels/MassMessageViewModel.cs | 90 ++++++++++ src/ViewModels/MessengerViewModel.cs | 50 ++++++ src/ViewModels/ProfileViewerViewModel.cs | 33 ++++ src/Views/ConversationView.xaml | 29 ++++ src/Views/ConversationView.xaml.cs | 36 ++++ src/Views/FriendsListView.xaml | 46 ++++++ src/Views/FriendsListView.xaml.cs | 38 +++++ src/Views/InputBoxView.xaml | 30 ++++ src/Views/InputBoxView.xaml.cs | 36 ++++ src/Views/LauncherView.xaml | 22 +++ src/Views/LauncherView.xaml.cs | 27 +++ src/Views/MainWindow.xaml | 30 ++++ src/Views/MainWindow.xaml.cs | 28 ++++ src/Views/MassMessageView.xaml | 50 ++++++ src/Views/MassMessageView.xaml.cs | 27 +++ src/Views/MessengerView.xaml | 37 +++++ src/Views/MessengerView.xaml.cs | 29 ++++ src/Views/ProfileViewerView.xaml | 39 +++++ src/Views/ProfileViewerView.xaml.cs | 39 +++++ 50 files changed, 2401 insertions(+) create mode 100644 src/App.config create mode 100644 src/App.xaml create mode 100644 src/App.xaml.cs create mode 100644 src/FriendSummary.xaml create mode 100644 src/FriendSummary.xaml.cs create mode 100644 src/Kalakoi.Xbox.App.csproj create mode 100644 src/MVVM/ModelBase.cs create mode 100644 src/MVVM/PropertyChangedBase.cs create mode 100644 src/MVVM/RelayCommand.cs create mode 100644 src/Models/ConversationModel.cs create mode 100644 src/Models/FriendsListModel.cs create mode 100644 src/Models/InputBoxModel.cs create mode 100644 src/Models/LauncherModel.cs create mode 100644 src/Models/MainWindowModel.cs create mode 100644 src/Models/MassMessageModel.cs create mode 100644 src/Models/MessengerModel.cs create mode 100644 src/Models/ProfileViewerModel.cs create mode 100644 src/Properties/AssemblyInfo.cs create mode 100644 src/Properties/Resources.Designer.cs create mode 100644 src/Properties/Resources.resx create mode 100644 src/Properties/Settings.Designer.cs create mode 100644 src/Properties/Settings.settings create mode 100644 src/TestFriendModel.cs create mode 100644 src/TestFriendView.xaml create mode 100644 src/TestFriendView.xaml.cs create mode 100644 src/TestFriendViewModel.cs create mode 100644 src/ViewModels/ConversationViewModel.cs create mode 100644 src/ViewModels/FriendsListViewModel.cs create mode 100644 src/ViewModels/InputBoxViewModel.cs create mode 100644 src/ViewModels/LauncherViewModel.cs create mode 100644 src/ViewModels/MainWindowViewModel.cs create mode 100644 src/ViewModels/MassMessageViewModel.cs create mode 100644 src/ViewModels/MessengerViewModel.cs create mode 100644 src/ViewModels/ProfileViewerViewModel.cs create mode 100644 src/Views/ConversationView.xaml create mode 100644 src/Views/ConversationView.xaml.cs create mode 100644 src/Views/FriendsListView.xaml create mode 100644 src/Views/FriendsListView.xaml.cs create mode 100644 src/Views/InputBoxView.xaml create mode 100644 src/Views/InputBoxView.xaml.cs create mode 100644 src/Views/LauncherView.xaml create mode 100644 src/Views/LauncherView.xaml.cs create mode 100644 src/Views/MainWindow.xaml create mode 100644 src/Views/MainWindow.xaml.cs create mode 100644 src/Views/MassMessageView.xaml create mode 100644 src/Views/MassMessageView.xaml.cs create mode 100644 src/Views/MessengerView.xaml create mode 100644 src/Views/MessengerView.xaml.cs create mode 100644 src/Views/ProfileViewerView.xaml create mode 100644 src/Views/ProfileViewerView.xaml.cs diff --git a/src/App.config b/src/App.config new file mode 100644 index 0000000..98d0f98 --- /dev/null +++ b/src/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/App.xaml b/src/App.xaml new file mode 100644 index 0000000..59d181c --- /dev/null +++ b/src/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/src/App.xaml.cs b/src/App.xaml.cs new file mode 100644 index 0000000..432b74a --- /dev/null +++ b/src/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Kalakoi.Xbox.App +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/src/FriendSummary.xaml b/src/FriendSummary.xaml new file mode 100644 index 0000000..a63e955 --- /dev/null +++ b/src/FriendSummary.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FriendSummary.xaml.cs b/src/FriendSummary.xaml.cs new file mode 100644 index 0000000..81e66bb --- /dev/null +++ b/src/FriendSummary.xaml.cs @@ -0,0 +1,76 @@ +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 Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + /// + /// Interaction logic for FriendSummary.xaml + /// + public partial class FriendSummary : UserControl + { + public FriendSummary() + { + InitializeComponent(); + } + + public Friend Friend + { + get { return (Friend)GetValue(FriendProperty); } + set { SetValue(FriendProperty, value); } + } + + public static DependencyProperty FriendProperty = + DependencyProperty.Register(nameof(Friend), typeof(Friend), typeof(FriendSummary)); + + /* + public Uri ProfilePicture + { + get { return (Uri)GetValue(ProfilePictureProperty); } + set { SetValue(ProfilePictureProperty, value); } + } + + public string Gamertag + { + get { return (string)GetValue(GamertagProperty); } + set { SetValue(GamertagProperty, value); } + } + + public string Status + { + get { return (string)GetValue(StatusProperty); } + set { SetValue(StatusProperty, value); } + } + + public string Presence + { + get { return (string)GetValue(PresenceProperty); } + set { SetValue(PresenceProperty, value); } + } + + public static DependencyProperty ProfilePictureProperty = + DependencyProperty.Register(nameof(ProfilePicture), typeof(Uri), typeof(FriendSummary)); + + public static DependencyProperty GamertagProperty = + DependencyProperty.Register(nameof(Gamertag), typeof(string), typeof(FriendSummary)); + + public static DependencyProperty StatusProperty = + DependencyProperty.Register(nameof(Status), typeof(string), typeof(FriendSummary)); + + public static DependencyProperty PresenceProperty = + DependencyProperty.Register(nameof(Presence), typeof(string), typeof(FriendSummary)); + */ + } +} diff --git a/src/Kalakoi.Xbox.App.csproj b/src/Kalakoi.Xbox.App.csproj new file mode 100644 index 0000000..62a907f --- /dev/null +++ b/src/Kalakoi.Xbox.App.csproj @@ -0,0 +1,199 @@ + + + + + Debug + AnyCPU + {F3BEB689-21F7-4B9A-80F2-C44677DA5900} + WinExe + Properties + Kalakoi.Xbox.App + Kalakoi.Xbox.App + v4.7.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + FriendSummary.xaml + + + + + TestFriendView.xaml + + + + LauncherView.xaml + + + + + MassMessageView.xaml + + + + + InputBoxView.xaml + + + + ConversationView.xaml + + + + + + FriendsListView.xaml + + + + + + + MessengerView.xaml + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + ProfileViewerView.xaml + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + {c1a3c6a1-4817-42c7-986a-2f51f223cfea} + Kalakoi.Xbox.OpenXBL + + + + + + + + \ No newline at end of file diff --git a/src/MVVM/ModelBase.cs b/src/MVVM/ModelBase.cs new file mode 100644 index 0000000..20795e1 --- /dev/null +++ b/src/MVVM/ModelBase.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Kalakoi.Xbox.App +{ + public abstract class ModelBase : PropertyChangedBase + { + public void SetProperty(ref T storage, T value, string name) + { + if ((storage?.GetType() != value?.GetType()) && storage != null && value != null) + throw new InvalidCastException("Nexthermal.CodeBase.WPF.ModelBase.UpdateProperty\nVariable type mismatch between storage and value."); + storage = value; + OnPropertyChanged(name); + } + } +} diff --git a/src/MVVM/PropertyChangedBase.cs b/src/MVVM/PropertyChangedBase.cs new file mode 100644 index 0000000..4a53277 --- /dev/null +++ b/src/MVVM/PropertyChangedBase.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Kalakoi.Xbox.App +{ + public abstract class PropertyChangedBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + public void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } +} diff --git a/src/MVVM/RelayCommand.cs b/src/MVVM/RelayCommand.cs new file mode 100644 index 0000000..31fbce9 --- /dev/null +++ b/src/MVVM/RelayCommand.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace Kalakoi.Xbox.App +{ + public class RelayCommand : ICommand + { + private Action execute; + private Func canExecute; + + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + + public RelayCommand(Action execute, Func canExecute = null) + { + this.execute = execute; + this.canExecute = canExecute; + } + + public bool CanExecute(object parameter) + { + return this.canExecute == null || this.canExecute(parameter); + } + + public void Execute(object parameter) + { + this.execute(parameter); + } + } +} diff --git a/src/Models/ConversationModel.cs b/src/Models/ConversationModel.cs new file mode 100644 index 0000000..04b2c4b --- /dev/null +++ b/src/Models/ConversationModel.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class ConversationModel : ModelBase + { + private string _gamertag; + private string _xuid; + private Conversation _conversation; + + private ICommand _refreshList; + private ICommand _sendReply; + + public string Gamertag + { + get { return _gamertag; } + set { SetProperty(ref _gamertag, value, nameof(Gamertag)); OnPropertyChanged(nameof(Title)); } + } + public string Title => string.Format("Conversation with {0}", Gamertag); + public string xuid + { + get { return _xuid; } + set { SetProperty(ref _xuid, value, nameof(xuid)); } + } + public Conversation Conversation + { + get { return _conversation; } + set { SetProperty(ref _conversation, value, nameof(Conversation)); } + } + + public ICommand RefreshList + { + get { return _refreshList; } + set { SetProperty(ref _refreshList, value, nameof(RefreshList)); } + } + public ICommand SendReply + { + get { return _sendReply; } + set { SetProperty(ref _sendReply, value, nameof(SendReply)); } + } + } +} diff --git a/src/Models/FriendsListModel.cs b/src/Models/FriendsListModel.cs new file mode 100644 index 0000000..71384af --- /dev/null +++ b/src/Models/FriendsListModel.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class FriendsListModel : ModelBase + { + private string _gamertag; + private string _xuid; + private List _friends; + private int _selectedFriendIndex; + + public string Gamertag + { + get { return _gamertag; } + set { SetProperty(ref _gamertag, value, nameof(Gamertag)); OnPropertyChanged(nameof(Title)); } + } + public string Title => string.Format("{0}'s Friends List", Gamertag); + public string xuid + { + get { return _xuid; } + set { SetProperty(ref _xuid, value, nameof(xuid)); } + } + public List Friends + { + get { return _friends; } + set { SetProperty(ref _friends, value, nameof(Friends)); SelectedFriendIndex = -1; } + } + public int SelectedFriendIndex + { + get { return _selectedFriendIndex; } + set { SetProperty(ref _selectedFriendIndex, value, nameof(SelectedFriendIndex)); OnPropertyChanged(nameof(FriendSelected)); } + } + public bool FriendSelected => SelectedFriendIndex >= 0; + + private ICommand _addFriend; + private ICommand _removeFriend; + private ICommand _favoriteFriend; + private ICommand _unfavoriteFriend; + private ICommand _viewProfile; + private ICommand _viewFriends; + private ICommand _refreshList; + private ICommand _sendMessage; + + public ICommand AddFriend + { + get { return _addFriend; } + set { SetProperty(ref _addFriend, value, nameof(AddFriend)); } + } + public ICommand RemoveFriend + { + get { return _removeFriend; } + set { SetProperty(ref _removeFriend, value, nameof(RemoveFriend)); } + } + public ICommand FavoriteFriend + { + get { return _favoriteFriend; } + set { SetProperty(ref _favoriteFriend, value, nameof(FavoriteFriend)); } + } + public ICommand UnfavoriteFriend + { + get { return _unfavoriteFriend; } + set { SetProperty(ref _unfavoriteFriend, value, nameof(UnfavoriteFriend)); } + } + public ICommand ViewProfile + { + get { return _viewProfile; } + set { SetProperty(ref _viewProfile, value, nameof(ViewProfile)); } + } + public ICommand ViewFriends + { + get { return _viewFriends; } + set { SetProperty(ref _viewFriends, value, nameof(ViewFriends)); } + } + public ICommand RefreshList + { + get { return _refreshList; } + set { SetProperty(ref _refreshList, value, nameof(RefreshList)); } + } + public ICommand SendMessage + { + get { return _sendMessage; } + set { SetProperty(ref _sendMessage, value, nameof(SendMessage)); } + } + } +} diff --git a/src/Models/InputBoxModel.cs b/src/Models/InputBoxModel.cs new file mode 100644 index 0000000..9be01cd --- /dev/null +++ b/src/Models/InputBoxModel.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace Kalakoi.Xbox.App +{ + public abstract class InputBoxModel : ModelBase + { + private string _title; + private string _prompt; + private string _input; + private MessageBoxButton _buttons; + private MessageBoxResult _result; + + private ICommand _ok; + private ICommand _cancel; + private ICommand _yes; + private ICommand _no; + + public string Title + { + get { return _title; } + set { SetProperty(ref _title, value, nameof(Title)); } + } + public string Prompt + { + get { return _prompt; } + set { SetProperty(ref _prompt, value, nameof(Prompt)); } + } + public string Input + { + get { return _input; } + set { SetProperty(ref _input, value, nameof(Input)); } + } + public MessageBoxButton Buttons + { + get { return _buttons; } + set + { + SetProperty(ref _buttons, value, nameof(Buttons)); + OnPropertyChanged(nameof(OKVisible)); + OnPropertyChanged(nameof(CancelVisible)); + OnPropertyChanged(nameof(YesNoVisible)); + } + } + public MessageBoxResult Result + { + get { return _result; } + set { SetProperty(ref _result, value, nameof(Result)); } + } + public Visibility OKVisible => + Buttons == MessageBoxButton.OK || Buttons == MessageBoxButton.OKCancel ? + Visibility.Visible : + Visibility.Collapsed; + public Visibility CancelVisible => + Buttons == MessageBoxButton.OKCancel || Buttons == MessageBoxButton.YesNoCancel ? + Visibility.Visible : + Visibility.Collapsed; + public Visibility YesNoVisible => + Buttons == MessageBoxButton.YesNo || Buttons == MessageBoxButton.YesNoCancel ? + Visibility.Visible : + Visibility.Collapsed; + + public ICommand OK + { + get { return _ok; } + set { SetProperty(ref _ok, value, nameof(OK)); } + } + public ICommand Cancel + { + get { return _cancel; } + set { SetProperty(ref _cancel, value, nameof(Cancel)); } + } + public ICommand Yes + { + get { return _yes; } + set { SetProperty(ref _yes, value, nameof(Yes)); } + } + public ICommand No + { + get { return _no; } + set { SetProperty(ref _no, value, nameof(No)); } + } + } +} diff --git a/src/Models/LauncherModel.cs b/src/Models/LauncherModel.cs new file mode 100644 index 0000000..afe30f9 --- /dev/null +++ b/src/Models/LauncherModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace Kalakoi.Xbox.App +{ + public abstract class LauncherModel : ModelBase + { + private string _key; + private ICommand _launch; + + public string Key + { + get { return _key; } + set { SetProperty(ref _key, value, nameof(Key)); } + } + public ICommand Launch + { + get { return _launch; } + set { SetProperty(ref _launch, value, nameof(Launch)); } + } + } +} diff --git a/src/Models/MainWindowModel.cs b/src/Models/MainWindowModel.cs new file mode 100644 index 0000000..2763fa7 --- /dev/null +++ b/src/Models/MainWindowModel.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace Kalakoi.Xbox.App +{ + public abstract class MainWindowModel : ModelBase + { + private string _response; + + private ICommand _viewProfile; + private ICommand _viewFriends; + private ICommand _viewMessages; + private ICommand _viewMassMessage; + private ICommand _command; + + public string Response + { + get { return _response; } + set { SetProperty(ref _response, value, nameof(Response)); } + } + + public ICommand ViewProfile + { + get { return _viewProfile; } + set { SetProperty(ref _viewProfile, value, nameof(ViewProfile)); } + } + public ICommand ViewFriends + { + get { return _viewFriends; } + set { SetProperty(ref _viewFriends, value, nameof(ViewFriends)); } + } + public ICommand ViewMessages + { + get { return _viewMessages; } + set { SetProperty(ref _viewMessages, value, nameof(ViewMessages)); } + } + public ICommand ViewMassMessage + { + get { return _viewMassMessage; } + set { SetProperty(ref _viewMassMessage, value, nameof(ViewMassMessage)); } + } + public ICommand Command + { + get { return _command; } + set { SetProperty(ref _command, value, nameof(Command)); } + } + } +} diff --git a/src/Models/MassMessageModel.cs b/src/Models/MassMessageModel.cs new file mode 100644 index 0000000..5a89406 --- /dev/null +++ b/src/Models/MassMessageModel.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class MassMessageModel : ModelBase + { + private List _friends; + private int _friendIndex; + private List _selectedFriends; + private int _selectedFriendIndex; + private string _message; + private bool _individualMessages; + + private ICommand _addSelected; + private ICommand _addAll; + private ICommand _removeSelected; + private ICommand _removeAll; + private ICommand _sendMessage; + + public List Friends + { + get { return _friends; } + set { SetProperty(ref _friends, value, nameof(Friends)); FriendIndex = -1; } + } + public int FriendIndex + { + get { return _friendIndex; } + set { SetProperty(ref _friendIndex, value, nameof(FriendIndex)); } + } + public List SelectedFriends + { + get { return _selectedFriends; } + set { SetProperty(ref _selectedFriends, value, nameof(SelectedFriends)); } + } + public int SelectedFriendIndex + { + get { return _selectedFriendIndex; } + set { SetProperty(ref _selectedFriendIndex, value, nameof(SelectedFriendIndex)); } + } + public string Message + { + get { return _message; } + set { SetProperty(ref _message, value, nameof(Message)); } + } + public bool IndividualMessages + { + get { return _individualMessages; } + set { SetProperty(ref _individualMessages, value, nameof(IndividualMessages)); } + } + + public ICommand AddSelected + { + get { return _addSelected; } + set { SetProperty(ref _addSelected, value, nameof(AddSelected)); } + } + public ICommand AddAll + { + get { return _addAll; } + set { SetProperty(ref _addAll, value, nameof(AddAll)); } + } + public ICommand RemoveSelected + { + get { return _removeSelected; } + set { SetProperty(ref _removeSelected, value, nameof(RemoveSelected)); } + } + public ICommand RemoveAll + { + get { return _removeAll; } + set { SetProperty(ref _removeAll, value, nameof(RemoveAll)); } + } + public ICommand SendMessage + { + get { return _sendMessage; } + set { SetProperty(ref _sendMessage, value, nameof(SendMessage)); } + } + } +} diff --git a/src/Models/MessengerModel.cs b/src/Models/MessengerModel.cs new file mode 100644 index 0000000..feb37f0 --- /dev/null +++ b/src/Models/MessengerModel.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class MessengerModel : ModelBase + { + private List _conversations; + private int _selectedConversationIndex; + + public List Conversations + { + get { return _conversations; } + set { SetProperty(ref _conversations, value, nameof(Conversations)); SelectedConversationIndex = -1; } + } + public int SelectedConversationIndex + { + get { return _selectedConversationIndex; } + set { SetProperty(ref _selectedConversationIndex, value, nameof(SelectedConversationIndex)); OnPropertyChanged(nameof(ConversationSelected)); } + } + public bool ConversationSelected => SelectedConversationIndex >= 0; + + private ICommand _viewConversation; + private ICommand _refreshList; + private ICommand _sendReply; + + public ICommand ViewConversation + { + get { return _viewConversation; } + set { SetProperty(ref _viewConversation, value, nameof(ViewConversation)); } + } + public ICommand RefreshList + { + get { return _refreshList; } + set { SetProperty(ref _refreshList, value, nameof(RefreshList)); } + } + public ICommand SendReply + { + get { return _sendReply; } + set { SetProperty(ref _sendReply, value, nameof(SendReply)); } + } + } +} diff --git a/src/Models/ProfileViewerModel.cs b/src/Models/ProfileViewerModel.cs new file mode 100644 index 0000000..48ec2e5 --- /dev/null +++ b/src/Models/ProfileViewerModel.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class ProfileViewerModel : ModelBase + { + private XboxProfile _profile; + + private Uri _profilePicture; + private string _gamertag; + private int _gamerscore; + private string _bio; + private string _location; + private string _tier; + private string _reputation; + private string _realName; + private Brush _primary; + private Brush _secondary; + private Brush _tertiary; + + public XboxProfile Profile + { + get { return _profile; } + set + { + SetProperty(ref _profile, value, nameof(Profile)); + if (value == null) + { + ProfilePicture = null; + Gamertag = string.Empty; + Gamerscore = 0; + Bio = string.Empty; + Location = string.Empty; + Tier = string.Empty; + Reputation = string.Empty; + RealName = string.Empty; + Primary = new SolidColorBrush(Colors.White); + Secondary = new SolidColorBrush(Colors.White); + Tertiary = new SolidColorBrush(Colors.White); + } + else + { + ProfilePicture = value.GamerPic; + Gamertag = value.Gamertag; + Gamerscore = value.Gamerscore; + Bio = value.Bio; + Location = value.Location; + Tier = value.AccountTier; + Reputation = value.Reputation; + RealName = value.RealName; + Primary = new SolidColorBrush((Color)ColorConverter.ConvertFromString(string.Format("#{0}", value.PreferredColor.PrimaryColor))); + Secondary = new SolidColorBrush((Color)ColorConverter.ConvertFromString(string.Format("#{0}", value.PreferredColor.SecondaryColor))); + Tertiary = new SolidColorBrush((Color)ColorConverter.ConvertFromString(string.Format("#{0}", value.PreferredColor.TertiaryColor))); + } + } + } + + public Uri ProfilePicture + { + get { return _profilePicture; } + set { SetProperty(ref _profilePicture, value, nameof(ProfilePicture)); } + } + public string Gamertag + { + get { return _gamertag; } + set { SetProperty(ref _gamertag, value, nameof(Gamertag)); } + } + public int Gamerscore + { + get { return _gamerscore; } + set { SetProperty(ref _gamerscore, value, nameof(Gamerscore)); } + } + public string Bio + { + get { return _bio; } + set { SetProperty(ref _bio, value, nameof(Bio)); } + } + public string Location + { + get { return _location; } + set { SetProperty(ref _location, value, nameof(Location)); } + } + public string Tier + { + get { return _tier; } + set { SetProperty(ref _tier, value, nameof(Tier)); } + } + public string Reputation + { + get { return _reputation; } + set { SetProperty(ref _reputation, value, nameof(Reputation)); } + } + public string RealName + { + get { return _realName; } + set { SetProperty(ref _realName, value, nameof(RealName)); } + } + public Brush Primary + { + get { return _primary; } + set { SetProperty(ref _primary, value, nameof(Primary)); } + } + public Brush Secondary + { + get { return _secondary; } + set { SetProperty(ref _secondary, value, nameof(Secondary)); } + } + public Brush Tertiary + { + get { return _tertiary; } + set { SetProperty(ref _tertiary, value, nameof(Tertiary)); } + } + } +} diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a739ec5 --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Kalakoi.Xbox.App")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Kalakoi.Xbox.App")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Properties/Resources.Designer.cs b/src/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7a24837 --- /dev/null +++ b/src/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Kalakoi.Xbox.App.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kalakoi.Xbox.App.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/src/Properties/Resources.resx b/src/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/src/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Properties/Settings.Designer.cs b/src/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5f88f14 --- /dev/null +++ b/src/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Kalakoi.Xbox.App.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string LastKey { + get { + return ((string)(this["LastKey"])); + } + set { + this["LastKey"] = value; + } + } + } +} diff --git a/src/Properties/Settings.settings b/src/Properties/Settings.settings new file mode 100644 index 0000000..a3d93b4 --- /dev/null +++ b/src/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/TestFriendModel.cs b/src/TestFriendModel.cs new file mode 100644 index 0000000..5fe664b --- /dev/null +++ b/src/TestFriendModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public abstract class TestFriendModel : ModelBase + { + private List _friendsList; + private int _selectedFriendIndex; + + public List FriendsList + { + get { return _friendsList; } + set { SetProperty(ref _friendsList, value, nameof(FriendsList)); SelectedFriendIndex = -1; } + } + public int SelectedFriendIndex + { + get { return _selectedFriendIndex; } + set { SetProperty(ref _selectedFriendIndex, value, nameof(SelectedFriendIndex)); } + } + } +} diff --git a/src/TestFriendView.xaml b/src/TestFriendView.xaml new file mode 100644 index 0000000..7e22214 --- /dev/null +++ b/src/TestFriendView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/TestFriendView.xaml.cs b/src/TestFriendView.xaml.cs new file mode 100644 index 0000000..25db466 --- /dev/null +++ b/src/TestFriendView.xaml.cs @@ -0,0 +1,27 @@ +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.Shapes; + +namespace Kalakoi.Xbox.App +{ + /// + /// Interaction logic for TestFriendView.xaml + /// + public partial class TestFriendView : Window + { + public TestFriendView() + { + InitializeComponent(); + } + } +} diff --git a/src/TestFriendViewModel.cs b/src/TestFriendViewModel.cs new file mode 100644 index 0000000..c2807aa --- /dev/null +++ b/src/TestFriendViewModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class TestFriendViewModel : TestFriendModel + { + public TestFriendViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + FriendsList = new List(XboxConnection.GetFriends()); + } + + private void InitializeCommands() + { + + } + } +} diff --git a/src/ViewModels/ConversationViewModel.cs b/src/ViewModels/ConversationViewModel.cs new file mode 100644 index 0000000..cec2099 --- /dev/null +++ b/src/ViewModels/ConversationViewModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class ConversationViewModel : ConversationModel + { + public ConversationViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Gamertag = "Xbox Live"; + xuid = "0"; + Conversation = new Conversation() { Summary = new ConversationSummary(), Messages = new List() { new Message() } }; + } + + private void InitializeCommands() + { + RefreshList = new RelayCommand(ListRefresh); + SendReply = new RelayCommand(ReplySend); + } + + private void ListRefresh(object obj) + { + Conversation = XboxConnection.GetConversation(xuid); + } + + private void ReplySend(object obj) + { + string MessageText = string.Empty; + MessageBoxResult res = InputBoxView.ShowDialog(string.Format("New message to {0}", Gamertag), "Message:", out MessageText, MessageBoxButton.OKCancel); + if (res == MessageBoxResult.OK) + XboxConnection.SendMessage(Gamertag, MessageText); + } + } +} diff --git a/src/ViewModels/FriendsListViewModel.cs b/src/ViewModels/FriendsListViewModel.cs new file mode 100644 index 0000000..55f7f98 --- /dev/null +++ b/src/ViewModels/FriendsListViewModel.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class FriendsListViewModel : FriendsListModel + { + public FriendsListViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Gamertag = string.Empty; + xuid = string.Empty; + Friends = new List(); + } + + private void InitializeCommands() + { + RefreshList = new RelayCommand(ListRefresh); + ViewProfile = new RelayCommand(ProfileView); + ViewFriends = new RelayCommand(FriendsView); + RemoveFriend = new RelayCommand(FriendRemove); + AddFriend = new RelayCommand(FriendAdd); + FavoriteFriend = new RelayCommand(FriendFavorite); + UnfavoriteFriend = new RelayCommand(FriendUnfavorite); + SendMessage = new RelayCommand(MessageSend); + } + + private void ListRefresh(object obj) + { + Friends = new List(XboxConnection.GetFriends(xuid)); + } + + private void ProfileView(object obj) + { + XboxProfile Profile = XboxConnection.GetProfile(Friends.ElementAt(SelectedFriendIndex).Gamertag); + ProfileViewerView v = new ProfileViewerView(Profile); + v.Show(); + } + + private void FriendsView(object obj) + { + FriendsListView v = new FriendsListView(Friends.ElementAt(SelectedFriendIndex).Gamertag, Friends.ElementAt(SelectedFriendIndex).xuid); + v.Show(); + } + + private void FriendRemove(object obj) + { + XboxConnection.RemoveFriend(Friends.ElementAt(SelectedFriendIndex).xuid); + } + + private void FriendAdd(object obj) + { + string Gamertag = string.Empty; + MessageBoxResult res = InputBoxView.ShowDialog("Send Friend Request", "Gamertag to Add:", out Gamertag, MessageBoxButton.OKCancel); + if (res == MessageBoxResult.OK) + XboxConnection.AddFriend(XboxConnection.XuidFromGamertag(Gamertag)); + } + + private void FriendFavorite(object obj) + { + XboxConnection.FavoriteFriend(Friends.ElementAt(SelectedFriendIndex).xuid); + } + + private void FriendUnfavorite(object obj) + { + XboxConnection.UnfavoriteFriend(Friends.ElementAt(SelectedFriendIndex).xuid); + } + + private void MessageSend(object obj) + { + string MessageText = string.Empty; + MessageBoxResult res = InputBoxView.ShowDialog(string.Format("New message to {0}", Friends.ElementAt(SelectedFriendIndex).Gamertag), "Message:", out MessageText, MessageBoxButton.OKCancel); + if (res == MessageBoxResult.OK) + XboxConnection.SendMessage(Friends.ElementAt(SelectedFriendIndex).Gamertag, MessageText); + } + } +} diff --git a/src/ViewModels/InputBoxViewModel.cs b/src/ViewModels/InputBoxViewModel.cs new file mode 100644 index 0000000..e189578 --- /dev/null +++ b/src/ViewModels/InputBoxViewModel.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Kalakoi.Xbox.App +{ + public class InputBoxViewModel : InputBoxModel + { + public InputBoxViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Title = string.Empty; + Prompt = string.Empty; + Input = string.Empty; + Buttons = MessageBoxButton.OK; + Result = MessageBoxResult.None; + } + + private void InitializeCommands() + { + OK = new RelayCommand(OKClick); + Cancel = new RelayCommand(CancelClick); + Yes = new RelayCommand(YesClick); + No = new RelayCommand(NoClick); + } + + private void OKClick(object obj) + { + Result = MessageBoxResult.OK; + Application.Current.Windows.OfType().First().Close(); + } + + private void CancelClick(object obj) + { + Result = MessageBoxResult.Cancel; + Application.Current.Windows.OfType().First().Close(); + } + + private void YesClick(object obj) + { + Result = MessageBoxResult.Yes; + Application.Current.Windows.OfType().First().Close(); + } + + private void NoClick(object obj) + { + Result = MessageBoxResult.No; + Application.Current.Windows.OfType().First().Close(); + } + + public void SetBox(string Title, string Prompt, MessageBoxButton Buttons) + { + this.Title = Title; + this.Prompt = Prompt; + this.Buttons = Buttons; + Input = string.Empty; + } + } +} diff --git a/src/ViewModels/LauncherViewModel.cs b/src/ViewModels/LauncherViewModel.cs new file mode 100644 index 0000000..cda58e4 --- /dev/null +++ b/src/ViewModels/LauncherViewModel.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class LauncherViewModel : LauncherModel + { + public LauncherViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Key = Properties.Settings.Default.LastKey; + } + + private void InitializeCommands() + { + Launch = new RelayCommand(DoLaunch); + } + + private void DoLaunch(object obj) + { + Properties.Settings.Default.LastKey = Key; + Properties.Settings.Default.Save(); + XboxConnection.SetApiKey(Key); + MainWindow v = new MainWindow(); + v.Show(); + Application.Current.MainWindow = v; + Application.Current.Windows.OfType().First().Close(); + } + } +} diff --git a/src/ViewModels/MainWindowViewModel.cs b/src/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..0751159 --- /dev/null +++ b/src/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class MainWindowViewModel : MainWindowModel + { + public MainWindowViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Response = string.Empty; + } + + private void InitializeCommands() + { + ViewProfile = new RelayCommand(ProfileView); + ViewFriends = new RelayCommand(FriendsView); + ViewMessages = new RelayCommand(MessagesView); + ViewMassMessage = new RelayCommand(MassMessageView); + Command = new RelayCommand(DoCommand); + } + + private void DoCommand(object obj) + { + //Response = XboxConnection.GetClips(); + TestFriendView v = new TestFriendView(); + v.Show(); + } + + private void ProfileView(object obj) + { + ProfileViewerView v = new ProfileViewerView(); + v.Show(); + } + + private void FriendsView(object obj) + { + FriendsListView v = new FriendsListView(); + v.Show(); + } + + private void MessagesView(object obj) + { + MessengerView v = new MessengerView(); + v.Show(); + } + + private void MassMessageView(object obj) + { + MassMessageView v = new MassMessageView(); + v.Show(); + } + } +} diff --git a/src/ViewModels/MassMessageViewModel.cs b/src/ViewModels/MassMessageViewModel.cs new file mode 100644 index 0000000..81f745c --- /dev/null +++ b/src/ViewModels/MassMessageViewModel.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class MassMessageViewModel : MassMessageModel + { + public MassMessageViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Friends = new List(XboxConnection.GetFriends().OrderBy(b => b.Gamertag)); + SelectedFriends = new List(); + Message = string.Empty; + IndividualMessages = true; + } + + private void InitializeCommands() + { + AddSelected = new RelayCommand(SelectedAdd); + AddAll = new RelayCommand(AllAdd); + RemoveSelected = new RelayCommand(SelectedRemove); + RemoveAll = new RelayCommand(AllRemove); + SendMessage = new RelayCommand(MessageSend); + } + + private void MessageSend(object obj) + { + if (IndividualMessages) + { + foreach (Friend f in SelectedFriends) + { + XboxConnection.SendMessage(f.Gamertag, Message); + } + MessageBox.Show(string.Format("Message sent to {0} friends.", SelectedFriends.Count), "Success", MessageBoxButton.OK, MessageBoxImage.Exclamation); + } + else + { + throw new NotImplementedException(); + } + } + + private void SelectedAdd(object obj) + { + List LeftTemp = new List(Friends); + List RightTemp = new List(SelectedFriends); + RightTemp.Add(LeftTemp.ElementAt(FriendIndex)); + LeftTemp.RemoveAt(FriendIndex); + Friends = LeftTemp; + SelectedFriends = RightTemp; + } + + private void AllAdd(object obj) + { + List RightTemp = new List(SelectedFriends); + foreach (Friend f in Friends) + RightTemp.Add(f); + SelectedFriends = RightTemp; + Friends = new List(); + } + + private void SelectedRemove(object obj) + { + List LeftTemp = new List(Friends); + List RightTemp = new List(SelectedFriends); + LeftTemp.Add(RightTemp.ElementAt(SelectedFriendIndex)); + RightTemp.RemoveAt(SelectedFriendIndex); + Friends = LeftTemp; + SelectedFriends = RightTemp; + } + + private void AllRemove(object obj) + { + List LeftTemp = new List(Friends); + foreach (Friend f in SelectedFriends) + LeftTemp.Add(f); + SelectedFriends = new List(); + Friends = LeftTemp; + } + } +} diff --git a/src/ViewModels/MessengerViewModel.cs b/src/ViewModels/MessengerViewModel.cs new file mode 100644 index 0000000..fe4ce10 --- /dev/null +++ b/src/ViewModels/MessengerViewModel.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class MessengerViewModel : MessengerModel + { + public MessengerViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Conversations = new List(); + } + + private void InitializeCommands() + { + RefreshList = new RelayCommand(ListRefresh); + ViewConversation = new RelayCommand(ConversationView); + SendReply = new RelayCommand(ReplySend); + } + + private void ListRefresh(object obj) + { + Conversations = new List(XboxConnection.GetConversations()); + } + + private void ConversationView(object obj) + { + ConversationView v = new ConversationView(Conversations.ElementAt(SelectedConversationIndex).SenderGamertag, Conversations.ElementAt(SelectedConversationIndex).SenderXUID.ToString()); + v.Show(); + } + + private void ReplySend(object obj) + { + string MessageText = string.Empty; + MessageBoxResult res = InputBoxView.ShowDialog(string.Format("New message to {0}", Conversations.ElementAt(SelectedConversationIndex).SenderGamertag), "Message:", out MessageText, MessageBoxButton.OKCancel); + if (res == MessageBoxResult.OK) + XboxConnection.SendMessage(Conversations.ElementAt(SelectedConversationIndex).SenderGamertag, MessageText); + } + } +} diff --git a/src/ViewModels/ProfileViewerViewModel.cs b/src/ViewModels/ProfileViewerViewModel.cs new file mode 100644 index 0000000..b5075da --- /dev/null +++ b/src/ViewModels/ProfileViewerViewModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Kalakoi.Xbox.OpenXBL; + +namespace Kalakoi.Xbox.App +{ + public class ProfileViewerViewModel : ProfileViewerModel + { + public ProfileViewerViewModel() + { + InitializeVariables(); + InitializeCommands(); + } + + private void InitializeVariables() + { + Profile = null; + } + + private void InitializeCommands() + { + + } + + public void LoadProfile(XboxProfile profile) + { + Profile = profile; + } + } +} diff --git a/src/Views/ConversationView.xaml b/src/Views/ConversationView.xaml new file mode 100644 index 0000000..54ee7d8 --- /dev/null +++ b/src/Views/ConversationView.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + +