-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitMainModel.cs
More file actions
118 lines (105 loc) · 3.79 KB
/
SplitMainModel.cs
File metadata and controls
118 lines (105 loc) · 3.79 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using VideoSplitter;
using VideoSplitterBase;
using WinUIShared.Enums;
namespace VideoSplitterPage
{
public class SplitMainModel : INotifyPropertyChanged
{
private TimeSpan _duration;
public TimeSpan Duration
{
get => _duration;
set => SetProperty(ref _duration, value);
}
private bool _inmultiselectmode;
public bool InMultiSelectMode
{
get => _inmultiselectmode;
set => SetProperty(ref _inmultiselectmode, value);
}
private SplitRangeModel? _selectedrange;
public SplitRangeModel? SelectedRange
{
get => _selectedrange;
set => SetProperty(ref _selectedrange, value, alsoNotify: [nameof(HasMoreBeforeSelected), nameof(HasMoreAfterSelected)]);
}
private bool _rangesavailable;
public bool RangesAvailable
{
get => _rangesavailable;
set => SetProperty(ref _rangesavailable, value);
}
private bool _allareselected;
public bool AllAreSelected
{
get => _allareselected;
set => SetProperty(ref _allareselected, value);
}
private bool _doprecisesplit;
public bool DoPreciseSplit
{
get => _doprecisesplit;
set => SetProperty(ref _doprecisesplit, value);
}
private OperationState _state;
public OperationState State
{
get => _state;
set => SetProperty(ref _state, value, alsoNotify: [nameof(BeforeOperation), nameof(DuringOperation), nameof(AfterOperation)]);
}
private bool _isaudio;
public bool IsAudio
{
get => _isaudio;
set => SetProperty(ref _isaudio, value);
}
public bool HasMoreBeforeSelected => SelectedRange != null && SplitModel.SplitRanges.Any(r => r.Start < SelectedRange.Start);
public bool HasMoreAfterSelected => SelectedRange != null && SplitModel.SplitRanges.Any(r => r.Start > SelectedRange.Start);
public bool BeforeOperation => State == OperationState.BeforeOperation;
public bool DuringOperation => State == OperationState.DuringOperation;
public bool AfterOperation => State == OperationState.AfterOperation;
public SplitViewModel<SplitRangeModel> SplitModel { get; set; } = new();
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string? propertyName = null, params string[] alsoNotify)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
foreach (var dep in alsoNotify) OnPropertyChanged(dep);
return true;
}
}
public class SplitRangeModel : SplitRange
{
private bool _isSelected;
public bool IsSelected
{
get => _isSelected;
set
{
if(_isSelected == value) return;
_isSelected = value;
OnPropertyChanged();
}
}
private bool _ismultiselected;
public bool IsMultiSelected
{
get => _ismultiselected;
set
{
if (_ismultiselected == value) return;
_ismultiselected = value;
OnPropertyChanged();
}
}
}
}