-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainPage.xaml.cs
44 lines (35 loc) · 1.25 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Windows.Input;
using CommunityToolkit.Maui.Views;
namespace AudioLoopbackTest;
public partial class MainPage : ContentPage
{
private readonly IServiceProvider _serviceProvider;
private AudioLoopbackFFT _audioLoopbackFft;
public MainPage(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
InitializeComponent();
BindingContext = this;
_audioLoopbackFft = new AudioLoopbackFFT(serviceProvider);
var spectrum = new SpectrumDrawable(serviceProvider);
// spectrum.ContentWidthChanged += (sender, args) =>
// {
// GraphicsView.WidthRequest = args.NewWidth;
// };
GraphicsView.Drawable = spectrum;
GraphicsView.SizeChanged += (sender, args) =>
{
spectrum.WindowWidthChanged(GraphicsView.Width);
};
_audioLoopbackFft.FFTCalculated += (sender, args) =>
{
((SpectrumDrawable)GraphicsView.Drawable).Data = args.Spectrum;
GraphicsView.Invalidate();
};
}
private async void OpenSettingsAsync(object sender, EventArgs e)
{
var settings = _serviceProvider.GetService<SettingsPopup>();
await this.ShowPopupAsync(settings);
}
}