Skip to content

Commit

Permalink
Merge pull request #17 from Panda-Sharp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Panda-Sharp authored Sep 8, 2021
2 parents 4b7b55d + b85bd7b commit 288dbcb
Show file tree
Hide file tree
Showing 40 changed files with 500 additions and 277 deletions.
7 changes: 5 additions & 2 deletions Yugen.DJ.Uwp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />

<ResourceDictionary>
<x:String x:Key="HeadPhonesIcon">&#xE7F6;</x:String>
<x:String x:Key="EjectIcon">&#xF847;</x:String>
<x:String x:Key="HamburgerMenuIcon">&#xE700;</x:String>
<x:String x:Key="HeadPhonesIcon">&#xE7F6;</x:String>
<x:String x:Key="AboutIcon">&#xE897;</x:String>
<x:String x:Key="HelpIcon">&#xE736;</x:String>
<x:String x:Key="SettingsIcon">&#xE713;</x:String>
<x:String x:Key="HelpIcon">&#xE897;</x:String>
<x:String x:Key="WhatsNewIcon">&#xE789;</x:String>

<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />

Expand Down
6 changes: 5 additions & 1 deletion Yugen.DJ.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Yugen.DJ.Uwp.Interfaces;
using Yugen.DJ.Uwp.StateTriggers;
using Yugen.DJ.Uwp.ViewModels;
using Yugen.DJ.Uwp.Views;
using Yugen.Toolkit.Uwp.Audio.Services.Abstractions;
Expand Down Expand Up @@ -72,6 +74,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
}
// Ensure the current window is active
Window.Current.Activate();

await Services.GetService<IWhatsNewDisplayService>().ShowIfAppropriateAsync();
}
}

Expand Down Expand Up @@ -110,14 +114,14 @@ private IServiceProvider ConfigureServices()
.AddSingleton<IMixerService, MixerService>()
.AddSingleton<ITrackService, TrackService>()
.AddSingleton<IWaveformService, WaveformService>()
.AddSingleton<IWhatsNewDisplayService, WhatsNewDisplayService>()

.AddSingleton<LeftDeckViewModel>()
.AddSingleton<RightDeckViewModel>()
.AddSingleton<MainViewModel>()
.AddSingleton<MixerViewModel>()
.AddTransient<VolumeViewModel>()
.AddTransient<VuBarViewModel>()
.AddTransient<AboutViewModel>()
.AddTransient<SettingsViewModel>()

.BuildServiceProvider();
Expand Down
9 changes: 9 additions & 0 deletions Yugen.DJ.Uwp/Interfaces/IWhatsNewDisplayService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace Yugen.DJ.Uwp.Interfaces
{
public interface IWhatsNewDisplayService
{
Task ShowIfAppropriateAsync();
}
}
30 changes: 30 additions & 0 deletions Yugen.DJ.Uwp/Services/WhatsNewDisplayService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.Toolkit.Uwp;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using System.Threading.Tasks;
using Windows.System;
using Yugen.DJ.Uwp.Interfaces;
using Yugen.DJ.Uwp.Views.Dialogs;

namespace Yugen.DJ.Uwp.StateTriggers
{
public class WhatsNewDisplayService : IWhatsNewDisplayService
{
private bool isShown = false;

public async Task ShowIfAppropriateAsync()
{
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();

if (SystemInformation.Instance.IsAppUpdated && !isShown)
{
isShown = true;
await dispatcherQueue.EnqueueAsync(async () =>
{
var dialog = new WhatsNewDialog();
await dialog.ShowAsync();
});
}
}
}
}
18 changes: 10 additions & 8 deletions Yugen.DJ.Uwp/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AboutHeaderTextBlock.Text" xml:space="preserve">
<value>Getting Started</value>
</data>
<data name="AboutSubHeaderTextBlock.Text" xml:space="preserve">
<value>Click the Eject button to load an mp3, if you have a second sound card you can hear a song clicking the headphones button, enjoy!</value>
</data>
<data name="AboutStatusTextBlock.Text" xml:space="preserve">
<value>The app is still not complete, for example it miss the scratch effect when you rotate the vinyl.</value>
</data>
Expand Down Expand Up @@ -153,13 +147,21 @@
<data name="AboutDesignHyperlink.NavigateUri" xml:space="preserve">
<value>https://twitter.com/zeealeid</value>
</data>
<data name="SettingsHeaderTextBlock.Text" xml:space="preserve">
<value>The app already support 2 audio cards, but the option to change them will come soon!</value>
<data name="HelpHeaderTextBlock.Text" xml:space="preserve">
<value>Getting Started</value>
</data>
<data name="HelpSubHeaderTextBlock.Text" xml:space="preserve">
<value>Click the Eject button to load an mp3, if you have a second sound card you can hear a song clicking the headphones button, enjoy!</value>
</data>
<data name="SettingsMasterAudioDevice.Header" xml:space="preserve">
<value>Master Audio Device:</value>
</data>
<data name="SettingsHeadphonesAudioDevice.Header" xml:space="preserve">
<value>Headphones Audio Device:</value>
</data>
<data name="WhatsNewBodyTextBlock.Text" xml:space="preserve">
<value>v1.1
- We added a new menu
- We added an option to choose the primary and seconday sound card in Settings</value>
</data>
</root>
11 changes: 0 additions & 11 deletions Yugen.DJ.Uwp/ViewModels/AboutViewModel.cs

This file was deleted.

22 changes: 20 additions & 2 deletions Yugen.DJ.Uwp/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.Threading.Tasks;
using System.Windows.Input;
using Yugen.DJ.Uwp.Views;
using Yugen.DJ.Uwp.Views.Dialogs;
using Yugen.Toolkit.Standard.Mvvm;

namespace Yugen.DJ.Uwp.ViewModels
Expand All @@ -12,31 +12,49 @@ public class MainViewModel : ViewModelBase
{
public MainViewModel()
{
AboutCommand = new AsyncRelayCommand(AboutCommandBehavior);
HelpCommand = new AsyncRelayCommand(HelpCommandBehavior);
SettingsCommand = new AsyncRelayCommand(SettingsCommandBehavior);
WhatsNewCommand = new AsyncRelayCommand(WhatsNewCommandBehavior);

LeftDeckViewModel = App.Current.Services.GetService<LeftDeckViewModel>();
RightDeckViewModel = App.Current.Services.GetService<RightDeckViewModel>();
}

public ICommand AboutCommand { get; }

public ICommand HelpCommand { get; }

public ICommand SettingsCommand { get; }

public ICommand WhatsNewCommand { get; }

public LeftDeckViewModel LeftDeckViewModel { get; }

public RightDeckViewModel RightDeckViewModel { get; }

private async Task HelpCommandBehavior()
private async Task AboutCommandBehavior()
{
var aboutDialog = new AboutDialog();
await aboutDialog.ShowAsync();
}

private async Task HelpCommandBehavior()
{
var helpDialog = new HelpDialog();
await helpDialog.ShowAsync();
}

private async Task SettingsCommandBehavior()
{
var settingsDialog = new SettingsDialog();
await settingsDialog.ShowAsync();
}

private async Task WhatsNewCommandBehavior()
{
var whatsNewDialog = new WhatsNewDialog();
await whatsNewDialog.ShowAsync();
}
}
}
42 changes: 27 additions & 15 deletions Yugen.DJ.Uwp/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using Windows.Devices.Enumeration;
using Yugen.Toolkit.Standard.Extensions;
using Yugen.Toolkit.Uwp.Audio.Services.Abstractions;

namespace Yugen.DJ.Uwp.ViewModels
{
public class SettingsViewModel : ObservableObject
{
private string _masterAudioDeviceInformation;
private string _headphonesAudioDeviceInformation;
private IAudioDeviceService _audioDeviceService;
private AudioDevice _masterAudioDeviceInformation;
private AudioDevice _headphonesAudioDeviceInformation;

public SettingsViewModel()
public SettingsViewModel(IAudioDeviceService audioDeviceService)
{
_audioDeviceService = audioDeviceService;

AudioDeviceInformationCollection.Add(_audioDeviceService.PrimaryDevice);
AudioDeviceInformationCollection.Add(_audioDeviceService.SecondaryDevice);

MasterAudioDeviceInformation = AudioDeviceInformationCollection[0];
HeadphonesAudioDeviceInformation = AudioDeviceInformationCollection[1];
}

public ObservableCollection<string> AudioDeviceInformationCollection { get; set; } =
new ObservableCollection<string>()
{
"Primary",
"Secondary"
};
public ObservableCollection<AudioDevice> AudioDeviceInformationCollection { get; set; } =
new ObservableCollection<AudioDevice>();

public string MasterAudioDeviceInformation
public AudioDevice MasterAudioDeviceInformation
{
get => _masterAudioDeviceInformation;
set => SetProperty(ref _masterAudioDeviceInformation, value);
set
{
if (SetProperty(ref _masterAudioDeviceInformation, value))
{
_audioDeviceService.PrimaryDevice = _masterAudioDeviceInformation;
}
}
}

public string HeadphonesAudioDeviceInformation
public AudioDevice HeadphonesAudioDeviceInformation
{
get => _headphonesAudioDeviceInformation;
set => SetProperty(ref _headphonesAudioDeviceInformation, value);
set
{
if (SetProperty(ref _headphonesAudioDeviceInformation, value))
{
_audioDeviceService.SecondaryDevice = _headphonesAudioDeviceInformation;
}
}
}
}
}
11 changes: 2 additions & 9 deletions Yugen.DJ.Uwp/ViewModels/VolumeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class VolumeViewModel : ObservableObject

private Side _side;
private double _volume = 100;
private bool _isHeadPhones;
private bool _isHeadPhones = true;

public VolumeViewModel(IMixerService mixerService)
{
Expand All @@ -20,14 +20,7 @@ public VolumeViewModel(IMixerService mixerService)
public Side Side
{
get => _side;
set
{
_side = value;
if (_side == Side.Left)
{
IsHeadPhones = true;
}
}
set => _side = value;
}

public bool IsHeadPhones
Expand Down
18 changes: 0 additions & 18 deletions Yugen.DJ.Uwp/Views/AboutDialog.cs

This file was deleted.

52 changes: 0 additions & 52 deletions Yugen.DJ.Uwp/Views/AboutDialog.xaml

This file was deleted.

10 changes: 10 additions & 0 deletions Yugen.DJ.Uwp/Views/Dialogs/AboutDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Yugen.DJ.Uwp.Views.Dialogs
{
public sealed partial class AboutDialog
{
public AboutDialog()
{
this.InitializeComponent();
}
}
}
Loading

0 comments on commit 288dbcb

Please sign in to comment.