forked from burkeholland/RecordMe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
81 lines (66 loc) · 2.66 KB
/
App.xaml.cs
File metadata and controls
81 lines (66 loc) · 2.66 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Configuration;
using System.Data;
using System.Windows;
using RecordMe.Views;
using RecordMe.ViewModels;
using RecordMe.Models;
namespace RecordMe;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private RecordBarWindow? _recordBar;
private MainWindow? _mainWindow;
private MainViewModel? _mainViewModel;
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create the shared ViewModel
_mainViewModel = new MainViewModel();
// Create main window (Editor) and show it as the default window
_mainWindow = new MainWindow();
_mainWindow.DataContext = _mainViewModel;
MainWindow = _mainWindow;
_mainWindow.Show();
// Create the record bar but don't show it yet - it will be shown when user clicks "New Recording"
_recordBar = new RecordBarWindow();
_recordBar.RecordRequested += OnRecordRequested;
_recordBar.ScreenshotRequested += OnScreenshotRequested;
_recordBar.LibraryRequested += OnLibraryRequested;
_recordBar.SettingsRequested += OnSettingsRequested;
}
private async void OnRecordRequested(object? sender, CaptureMode mode)
{
if (_mainViewModel == null) return;
// Hide the record bar during recording
_recordBar?.Hide();
// Set capture mode and start recording
_mainViewModel.SelectedCaptureMode = mode;
_mainViewModel.SelectedCaptureType = CaptureType.Recording;
await _mainViewModel.StartRecordingCommand.ExecuteAsync(null);
}
private async void OnScreenshotRequested(object? sender, CaptureMode mode)
{
if (_mainViewModel == null) return;
// Hide the record bar during capture
_recordBar?.Hide();
// Set capture mode and take screenshot
_mainViewModel.SelectedCaptureMode = mode;
_mainViewModel.SelectedCaptureType = CaptureType.Screenshot;
await _mainViewModel.TakeScreenshotCommand.ExecuteAsync(null);
}
private async void OnLibraryRequested(object? sender, EventArgs e)
{
if (_mainViewModel == null || _mainWindow == null) return;
// Show the main window with editor mode
await _mainViewModel.OpenLibraryCommand.ExecuteAsync(null);
_mainWindow.Show();
_mainWindow.Activate();
// Keep record bar visible for quick access
}
private void OnSettingsRequested(object? sender, EventArgs e)
{
if (_mainViewModel == null) return;
_mainViewModel.OpenSettingsCommand.Execute(null);
}
}