Skip to content

Commit 2852b55

Browse files
authored
Merge pull request #19 from samunohito/develop
v0.1.81-beta
2 parents 111c636 + af96efe commit 2852b55

18 files changed

+794
-293
lines changed

SimpleVolumeMixer/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<ResourceDictionary Source="/UI/Styles/TextBlock.xaml" />
4747
<ResourceDictionary Source="/UI/Styles/UserControl.xaml" />
4848
<ResourceDictionary Source="/UI/Styles/AudioSessionTemplate.xaml" />
49+
<ResourceDictionary Source="/UI/Styles/AudioDeviceTemplate.xaml" />
4950
</ResourceDictionary.MergedDictionaries>
5051

5152
<SolidColorBrush x:Key="PrimaryHueLightBrush" Color="{StaticResource Primary200}" po:Freeze="True" />

SimpleVolumeMixer/App.xaml.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,23 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
7373

7474
// Views
7575
containerRegistry.RegisterForNavigation<SettingsPage, SettingsPageViewModel>(PageKeys.Settings);
76+
7677
containerRegistry.RegisterForNavigation<AudioSessionsPage, AudioSessionsPageViewModel>(PageKeys.AudioSessions);
77-
containerRegistry.RegisterForNavigation<AudioSessionsSubHorizontalPage, AudioSessionsPageSubViewModel>(
78-
PageKeys.AudioSessionsSubHorizontal);
79-
containerRegistry.RegisterForNavigation<AudioSessionsSubVerticalPage, AudioSessionsPageSubViewModel>(
80-
PageKeys.AudioSessionsSubVertical);
78+
containerRegistry.RegisterForNavigation<
79+
AudioSessionsSubHorizontalPage,
80+
AudioSessionsPageSubViewModel>(PageKeys.AudioSessionsSubHorizontal);
81+
containerRegistry.RegisterForNavigation<
82+
AudioSessionsSubVerticalPage,
83+
AudioSessionsPageSubViewModel>(PageKeys.AudioSessionsSubVertical);
84+
8185
containerRegistry.RegisterForNavigation<AudioDevicesPage, AudioDevicesPageViewModel>(PageKeys.AudioDevices);
82-
86+
containerRegistry.RegisterForNavigation<
87+
AudioDevicesSubHorizontalPage,
88+
AudioDevicesPageSubViewModel>(PageKeys.AudioDevicesSubHorizontal);
89+
containerRegistry.RegisterForNavigation<
90+
AudioDevicesSubVerticalPage,
91+
AudioDevicesPageSubViewModel>(PageKeys.AudioDevicesSubVertical);
92+
8393
containerRegistry.RegisterForNavigation<ShellWindow, ShellWindowViewModel>();
8494

8595
// Configuration

SimpleVolumeMixer/Core/Helper/Component/SynchronizedObservableCollectionWrapper.cs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,25 @@ namespace SimpleVolumeMixer.Core.Helper.Component;
1313
/// Wrapper for exclusive handling of <see cref="ObservableCollection{T}"/>.
1414
/// </summary>
1515
/// <typeparam name="T">element type</typeparam>
16-
public class SynchronizedObservableCollectionWrapper<T> : DisposableComponent, ICollection<T> where T : class
16+
public class SynchronizedObservableCollectionWrapper<T> : DisposableComponent where T : class
1717
{
1818
private readonly object _gate = new();
19-
private readonly ObservableCollection<T> _collection;
2019

2120
public SynchronizedObservableCollectionWrapper()
2221
{
23-
_collection = new ReactiveCollection<T>().AddTo(Disposable);
24-
ReadOnlyCollection = _collection
22+
Collection = new ReactiveCollection<T>().AddTo(Disposable);
23+
ReadOnlyCollection = Collection
2524
.ToReadOnlyReactiveCollection(disposeElement: false)
2625
.AddTo(Disposable);
2726
}
27+
28+
/// <summary>
29+
/// Managed ObservableCollection
30+
/// </summary>
31+
protected ObservableCollection<T> Collection { get; }
2832

2933
/// <summary>
3034
/// This is a read-only collection, linked to the update of the wrapped <see cref="ObservableCollection{T}"/>.
31-
/// Change notifications are sent to the UI thread.
3235
/// </summary>
3336
public ReadOnlyObservableCollection<T> ReadOnlyCollection { get; }
3437

@@ -37,65 +40,51 @@ public SynchronizedObservableCollectionWrapper()
3740
/// </summary>
3841
protected object Gate => _gate;
3942

40-
public IEnumerator<T> GetEnumerator()
41-
{
42-
lock (_gate)
43-
{
44-
return _collection.GetEnumerator();
45-
}
46-
}
47-
48-
IEnumerator IEnumerable.GetEnumerator()
49-
{
50-
return GetEnumerator();
51-
}
52-
53-
5443
public void Add(T item)
5544
{
5645
lock (_gate)
5746
{
58-
_collection.Add(item);
47+
Collection.Add(item);
5948
}
6049
}
6150

6251
public void Insert(int idx, T item)
6352
{
6453
lock (_gate)
6554
{
66-
_collection.Insert(idx, item);
55+
Collection.Insert(idx, item);
6756
}
6857
}
6958

7059
public void Clear()
7160
{
7261
lock (_gate)
7362
{
74-
_collection.Clear();
63+
Collection.Clear();
7564
}
7665
}
7766

7867
public bool Contains(T item)
7968
{
8069
lock (_gate)
8170
{
82-
return _collection.Contains(item);
71+
return Collection.Contains(item);
8372
}
8473
}
8574

8675
public void CopyTo(T[] array, int arrayIndex)
8776
{
8877
lock (_gate)
8978
{
90-
_collection.CopyTo(array, arrayIndex);
79+
Collection.CopyTo(array, arrayIndex);
9180
}
9281
}
9382

9483
public bool Remove(T item)
9584
{
9685
lock (_gate)
9786
{
98-
return _collection.Remove(item);
87+
return Collection.Remove(item);
9988
}
10089
}
10190

@@ -105,7 +94,7 @@ public int Count
10594
{
10695
lock (_gate)
10796
{
108-
return _collection.Count;
97+
return Collection.Count;
10998
}
11099
}
111100
}

SimpleVolumeMixer/Core/Helper/CoreAudio/AudioDeviceAccessorManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public bool Contains(string? deviceId, DataFlowType dataFlowType)
7878

7979
lock (Gate)
8080
{
81-
return this.Any(x => x.DeviceId == deviceId && x.DataFlow == dataFlowType);
81+
return Collection.Any(x => x.DeviceId == deviceId && x.DataFlow == dataFlowType);
8282
}
8383
}
8484

@@ -107,7 +107,7 @@ public bool Contains(MMDevice device)
107107

108108
lock (Gate)
109109
{
110-
return this.FirstOrDefault(x => x.DeviceId == deviceId && x.DataFlow == dataFlowType);
110+
return Collection.FirstOrDefault(x => x.DeviceId == deviceId && x.DataFlow == dataFlowType);
111111
}
112112
}
113113

@@ -182,7 +182,7 @@ public void Remove(string deviceId)
182182
{
183183
lock (Gate)
184184
{
185-
this.Where(x => x.DeviceId == deviceId)
185+
Collection.Where(x => x.DeviceId == deviceId)
186186
.ToList()
187187
.ForEach(x => Remove(x));
188188
}
@@ -208,7 +208,7 @@ public void Remove(MMDevice device)
208208
/// </summary>
209209
public new void Clear()
210210
{
211-
var collections = this.ToList();
211+
var collections = Collection.ToList();
212212
base.Clear();
213213

214214
foreach (var ax in collections)
@@ -237,7 +237,7 @@ public void CollectAudioEndpoints()
237237
Add(device);
238238
}
239239

240-
if (this.Any(x => x.DataFlow == DataFlowType.Render))
240+
if (Collection.Any(x => x.DataFlow == DataFlowType.Render))
241241
{
242242
// deviceが1つもない状態でGetDefaultAudioEndpointを呼ぶとエラー落ちする
243243
using var mulDevice = _deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
@@ -246,7 +246,7 @@ public void CollectAudioEndpoints()
246246
DeviceRoleSync(comDevice.DeviceID, DataFlowType.Render, RoleType.Communications);
247247
}
248248

249-
if (this.Any(x => x.DataFlow == DataFlowType.Capture))
249+
if (Collection.Any(x => x.DataFlow == DataFlowType.Capture))
250250
{
251251
// deviceが1つもない状態でGetDefaultAudioEndpointを呼ぶとエラー落ちする
252252
using var mulDevice = _deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia);
@@ -271,14 +271,14 @@ private void DeviceRoleSync(string deviceId, DataFlowType dataFlowType, RoleType
271271
switch (roleType)
272272
{
273273
case RoleType.Communications:
274-
foreach (var device in this)
274+
foreach (var device in Collection)
275275
{
276276
device.Role.Communications = false;
277277
}
278278

279279
break;
280280
case RoleType.Multimedia:
281-
foreach (var device in this)
281+
foreach (var device in Collection)
282282
{
283283
device.Role.Multimedia = false;
284284
}

SimpleVolumeMixer/Core/Helper/CoreAudio/AudioSessionAccessorManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public bool Contains(int? procId)
6363

6464
lock (Gate)
6565
{
66-
return this.Any(x => x.Process?.Id == procId);
66+
return Collection.Any(x => x.Process?.Id == procId);
6767
}
6868
}
6969

@@ -81,7 +81,7 @@ public bool Contains(int? procId)
8181

8282
lock (Gate)
8383
{
84-
return this.FirstOrDefault(x => x.Process?.Id == procId);
84+
return Collection.FirstOrDefault(x => x.Process?.Id == procId);
8585
}
8686
}
8787

@@ -140,7 +140,7 @@ public void Remove(int? procId)
140140

141141
lock (Gate)
142142
{
143-
this.Where(x => x.Process?.Id == procId)
143+
Collection.Where(x => x.Process?.Id == procId)
144144
.ToList()
145145
.ForEach(x => Remove(x));
146146
}
@@ -167,7 +167,7 @@ public void Remove(AudioSessionControl session)
167167
/// </summary>
168168
public new void Clear()
169169
{
170-
var collections = this.ToList();
170+
var collections = Collection.ToList();
171171
base.Clear();
172172

173173
foreach (var ax in collections)

SimpleVolumeMixer/SimpleVolumeMixer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
</ItemGroup>
7676

7777
<ItemGroup>
78+
<Page Include="UI\Styles\AudioDeviceTemplate.xaml" />
79+
<Page Include="UI\Views\Controls\AudioDevicesSubHorizontalPage.xaml" />
80+
<Page Include="UI\Views\Controls\AudioDevicesSubVerticalPage.xaml" />
7881
<Page Include="UI\Views\ShellWindow.xaml" />
7982
<Page Include="UI\Views\SettingsPage.xaml" />
8083
<Page Include="UI\Views\AudioSessionsPage.xaml" />

SimpleVolumeMixer/UI/Constants/PageKeys.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ public class PageKeys
55
public const string AudioSessions = "AudioSessions";
66
public const string AudioSessionsSubVertical = "AudioSessionsSubVertical";
77
public const string AudioSessionsSubHorizontal = "AudioSessionsSubHorizontal";
8+
public const string AudioDevicesSubVertical = "AudioDevicesSubVertical";
9+
public const string AudioDevicesSubHorizontal = "AudioDevicesSubHorizontal";
810
public const string AudioDevices = "AudioDevices";
911
public const string Settings = "Settings";
1012
}

SimpleVolumeMixer/UI/Constants/Regions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ public class Regions
44
{
55
public const string Main = "MainRegion";
66
public const string AudioSessionSubRegion = "AudioSessionSubRegion";
7+
public const string AudioDeviceSubRegion = "AudioDeviceSubRegion";
78
public const string RightPane = "RightPane";
89
}

0 commit comments

Comments
 (0)