/
EventEditViewmodel.cs
924 lines (815 loc) · 33.1 KB
/
EventEditViewmodel.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.ComponentModel;
using System.Windows.Input;
using TAS.Client.Common;
using TAS.Common;
using System.Text.RegularExpressions;
using TAS.Common.Interfaces;
using resources = TAS.Client.Common.Properties.Resources;
namespace TAS.Client.ViewModels
{
public class EventEditViewmodel : EditViewmodelBase<IEvent>, IDataErrorInfo
{
private readonly EngineViewmodel _engineViewModel;
private IMedia _media;
private bool _isVolumeChecking;
private TEventType _eventType;
private string _eventName;
private string _command;
private bool _isEnabled;
private bool _isHold;
private bool _isLoop;
private TStartType _startType;
private AutoStartFlags _autoStartFlags;
private bool _bindToEnd;
private TimeSpan _scheduledTc;
private TTransitionType _transitionType;
private TEasing _transitionEasing;
private TimeSpan _transitionTime;
private TimeSpan _transitionPauseTime;
private double? _audioVolume;
private DateTime _scheduledTime;
private TimeSpan? _requestedStartTime;
private TimeSpan _duration;
private TimeSpan _scheduledDelay;
private sbyte _layer;
public static readonly Regex RegexMixerFill = new Regex(TAS.Common.EventExtensions.MixerFillCommand, RegexOptions.IgnoreCase);
public static readonly Regex RegexMixerClip = new Regex(TAS.Common.EventExtensions.MixerClipCommand, RegexOptions.IgnoreCase);
public static readonly Regex RegexMixerClear = new Regex(TAS.Common.EventExtensions.MixerClearCommand, RegexOptions.IgnoreCase);
public static readonly Regex RegexPlay = new Regex(TAS.Common.EventExtensions.PlayCommand, RegexOptions.IgnoreCase);
public static readonly Regex RegexCg = new Regex(TAS.Common.EventExtensions.CgCommand, RegexOptions.IgnoreCase);
public EventEditViewmodel(IEvent @event, EngineViewmodel engineViewModel): base(@event)
{
_engineViewModel = engineViewModel;
Model.PropertyChanged += ModelPropertyChanged;
if (@event.EventType == TEventType.Container)
{
EventRightsEditViewmodel = new EventRightsEditViewmodel(@event, engineViewModel.Engine.AuthenticationService);
EventRightsEditViewmodel.ModifiedChanged += RightsModifiedChanged;
}
CommandSaveEdit = new UICommand {ExecuteDelegate = o => Save(), CanExecuteDelegate = _canSave};
CommandUndoEdit = new UICommand {ExecuteDelegate = o => UndoEdit(), CanExecuteDelegate = o => IsModified};
CommandChangeMovie = new UICommand {ExecuteDelegate = _changeMovie, CanExecuteDelegate = _canChangeMovie};
CommandEditMovie = new UICommand {ExecuteDelegate = _editMovie, CanExecuteDelegate = _canEditMovie};
CommandCheckVolume = new UICommand {ExecuteDelegate = _checkVolume, CanExecuteDelegate = _canCheckVolume};
CommandTriggerStartType = new UICommand
{
ExecuteDelegate = _triggerStartType,
CanExecuteDelegate = _canTriggerStartType
};
CommandMoveUp = new UICommand
{
ExecuteDelegate = o => Model.MoveUp(),
CanExecuteDelegate = o => Model.CanMoveUp()
};
CommandMoveDown = new UICommand
{
ExecuteDelegate = o => Model.MoveDown(),
CanExecuteDelegate = o => Model.CanMoveDown()
};
CommandDelete = new UICommand
{
ExecuteDelegate = o =>
{
if (MessageBox.Show(resources._query_DeleteItem, resources._caption_Confirmation, MessageBoxButton.OKCancel) != MessageBoxResult.OK)
return;
EventClipboard.SaveUndo(new List<IEvent> {Model},
Model.StartType == TStartType.After ? Model.Prior : Model.Parent);
Model.Delete();
},
CanExecuteDelegate = o => Model.AllowDelete() == true
};
if (@event is ITemplated templated)
{
TemplatedEditViewmodel = new TemplatedEditViewmodel(templated, true, true, engineViewModel.VideoFormat);
TemplatedEditViewmodel.ModifiedChanged += TemplatedEditViewmodel_ModifiedChanged;
}
}
public void Save()
{
Update();
}
public void UndoEdit()
{
TemplatedEditViewmodel?.UndoEdit();
EventRightsEditViewmodel?.UndoEdit();
Load();
}
protected override void Update(object destObject = null)
{
base.Update(Model);
EventRightsEditViewmodel?.Save();
TemplatedEditViewmodel?.Save();
Model.Save();
}
public ICommand CommandUndoEdit { get; }
public ICommand CommandSaveEdit { get; }
public ICommand CommandMoveUp { get; }
public ICommand CommandMoveDown { get; }
public ICommand CommandChangeMovie { get; }
public ICommand CommandEditMovie { get; }
public ICommand CommandCheckVolume { get; }
public ICommand CommandTriggerStartType { get; }
public ICommand CommandDelete { get; }
public string Error => null;
public string this[string propertyName]
{
get
{
string validationResult = null;
switch (propertyName)
{
case nameof(Duration):
validationResult = _validateDuration();
break;
case nameof(ScheduledTc):
validationResult = _validateScheduledTc();
break;
case nameof(ScheduledTime):
case nameof(ScheduledTimeOfDay):
case nameof(ScheduledDate):
validationResult = _validateScheduledTime();
break;
case nameof(TransitionTime):
validationResult = _validateTransitionTime();
break;
case nameof(TransitionPauseTime):
validationResult = _validateTransitionPauseTime();
break;
case nameof(ScheduledDelay):
validationResult = _validateScheduledDelay();
break;
case nameof(EventName):
validationResult = _validateEventName();
break;
case nameof(Command):
validationResult = IsValidCommand(_command)
? string.Empty
: resources._validate_CommandSyntax;
break;
}
return validationResult;
}
}
public IMedia Media
{
get => _media;
set => SetField(ref _media, value);
}
public bool IsVolumeChecking
{
get => _isVolumeChecking;
set
{
if (_isVolumeChecking != value)
return;
_isVolumeChecking = value;
NotifyPropertyChanged();
InvalidateRequerySuggested();
}
}
public TEventType EventType
{
get => _eventType;
set => SetField(ref _eventType, value);
}
public string EventName
{
get => _eventName;
set => SetField(ref _eventName, value);
}
public bool IsEditEnabled => Model.PlayState == TPlayState.Scheduled && Model.HaveRight(EventRight.Modify);
public bool IsAutoStartEvent => _startType == TStartType.OnFixedTime;
public bool IsMovieOrLive => Model.EventType == TEventType.Movie || Model.EventType == TEventType.Live;
public bool IsMovieOrLiveOrRundown
{
get
{
var et = Model.EventType;
return et == TEventType.Movie || et == TEventType.Live || et == TEventType.Rundown;
}
}
public bool IsCommandScript => Model is ICommandScript;
#region ICGElementsState
bool _isCGEnabled;
byte _crawl;
byte _logo;
byte _parental;
public bool IsCGEnabled
{
get => _isCGEnabled;
set => SetField(ref _isCGEnabled, value);
}
public byte Crawl
{
get => _crawl;
set => SetField(ref _crawl, value);
}
public byte Logo
{
get => _logo;
set => SetField(ref _logo, value);
}
public byte Parental
{
get => _parental;
set => SetField(ref _parental, value);
}
#endregion ICGElementsState
public string Command
{
get => _command;
set => SetField(ref _command, value);
}
public bool IsMovie => Model.EventType == TEventType.Movie;
public bool IsStillImage => Model.EventType == TEventType.StillImage;
public bool IsTransitionPanelEnabled
{
get
{
var et = Model.EventType;
return !_isHold && (et == TEventType.Live || et == TEventType.Movie);
}
}
public bool IsTransitionPropertiesVisible => _transitionType != TTransitionType.Cut;
public bool IsContainer => Model.EventType == TEventType.Container;
public bool CanHold => Model.Prior != null;
public bool CanLoop => Model.GetSuccessor() == null;
public bool IsEnabled
{
get => _isEnabled;
set => SetField(ref _isEnabled, value);
}
public bool IsHold
{
get => _isHold;
set
{
if (!SetField(ref _isHold, value))
return;
if (value)
TransitionTime = TimeSpan.Zero;
NotifyPropertyChanged(nameof(IsTransitionPanelEnabled));
}
}
public bool IsLoop
{
get => _isLoop;
set => SetField(ref _isLoop, value);
}
public TStartType StartType
{
get => _startType;
set
{
if (!SetField(ref _startType, value))
return;
_bindToEnd = value == TStartType.WithParentFromEnd;
NotifyPropertyChanged(nameof(BindToEnd));
NotifyPropertyChanged(nameof(IsAutoStartEvent));
}
}
public AutoStartFlags AutoStartFlags
{
get => _autoStartFlags;
set
{
if (!SetField(ref _autoStartFlags, value))
return;
NotifyPropertyChanged(nameof(AutoStartForced));
NotifyPropertyChanged(nameof(AutoStartDaily));
NotifyPropertyChanged(nameof(IsScheduledDateVisible));
}
}
public bool AutoStartForced
{
get => (_autoStartFlags & AutoStartFlags.Force) != AutoStartFlags.None;
set
{
if (value == AutoStartForced)
return;
if (value)
AutoStartFlags = AutoStartFlags | AutoStartFlags.Force;
else
AutoStartFlags = AutoStartFlags & ~AutoStartFlags.Force;
}
}
public bool AutoStartDaily
{
get => (_autoStartFlags & AutoStartFlags.Daily) != AutoStartFlags.None;
set
{
if (value == AutoStartDaily)
return;
if (value)
AutoStartFlags = AutoStartFlags | AutoStartFlags.Daily;
else
AutoStartFlags = AutoStartFlags & ~AutoStartFlags.Daily;
}
}
public string BoundEventName
{
get
{
var st = Model.StartType;
var boundEvent = st == TStartType.WithParent || st == TStartType.WithParentFromEnd
? Model.Parent
: (st == TStartType.After)
? Model.Prior
: null;
return boundEvent == null ? string.Empty : boundEvent.EventName;
}
}
public bool BindToEnd
{
get => _bindToEnd;
set
{
if (!SetField(ref _bindToEnd, value)) return;
if (_startType != TStartType.WithParent && _startType != TStartType.WithParentFromEnd) return;
StartType = value ? TStartType.WithParentFromEnd : TStartType.WithParent;
}
}
public bool IsDisplayBindToEnd => (_eventType == TEventType.CommandScript || _eventType == TEventType.StillImage)
&& (_startType == TStartType.WithParent || _startType == TStartType.WithParentFromEnd);
public TimeSpan ScheduledTc
{
get => _scheduledTc;
set
{
SetField(ref _scheduledTc, value);
NotifyPropertyChanged(nameof(Duration));
}
}
public Array TransitionTypes { get; } = Enum.GetValues(typeof(TTransitionType));
public Array TransitionEasings { get; } = Enum.GetValues(typeof(TEasing));
public TTransitionType TransitionType
{
get => _transitionType;
set
{
if (SetField(ref _transitionType, value))
{
if (value == TTransitionType.Cut)
{
TransitionTime = TimeSpan.Zero;
TransitionPauseTime = TimeSpan.Zero;
}
NotifyPropertyChanged(nameof(IsTransitionPropertiesVisible));
}
}
}
public TEasing TransitionEasing
{
get => _transitionEasing;
set => SetField(ref _transitionEasing, value);
}
public TimeSpan TransitionTime
{
get => _transitionTime;
set => SetField(ref _transitionTime, value);
}
public TimeSpan TransitionPauseTime
{
get => _transitionPauseTime;
set => SetField(ref _transitionPauseTime, value);
}
public double? AudioVolume
{
get => _audioVolume;
set
{
if (!SetField(ref _audioVolume, value))
return;
NotifyPropertyChanged(nameof(HasAudioVolume));
NotifyPropertyChanged(nameof(AudioVolumeLevel));
}
}
public double AudioVolumeLevel
{
get => _audioVolume ?? (_media?.AudioVolume ?? 0);
set
{
if (!SetField(ref _audioVolume, value))
return;
NotifyPropertyChanged(nameof(HasAudioVolume));
NotifyPropertyChanged(nameof(AudioVolume));
}
}
public bool HasAudioVolume
{
get => _audioVolume != null;
set
{
if (!SetField(ref _audioVolume,
value ? (_media != null ? (double?) _media.AudioVolume : 0) : null)) return;
NotifyPropertyChanged(nameof(AudioVolume));
NotifyPropertyChanged(nameof(AudioVolumeLevel));
}
}
public DateTime ScheduledTime
{
get => _scheduledTime;
set
{
if (!SetField(ref _scheduledTime, value))
return;
NotifyPropertyChanged(nameof(ScheduledDate));
NotifyPropertyChanged(nameof(ScheduledTimeOfDay));
}
}
public DateTime ScheduledDate
{
get => _scheduledTime.ToLocalTime().Date;
set
{
if (!value.Equals(ScheduledDate))
ScheduledTime = (value.Date + ScheduledTimeOfDay).ToUniversalTime();
}
}
public TimeSpan ScheduledTimeOfDay
{
get => _scheduledTime.ToLocalTime().TimeOfDay;
set
{
if (!value.Equals(ScheduledTimeOfDay))
ScheduledTime = new DateTime(value.Ticks + ScheduledDate.Ticks).ToUniversalTime();
}
}
public bool IsScheduledDateVisible => _startType != TStartType.OnFixedTime || !AutoStartDaily;
public TimeSpan? RequestedStartTime
{
get => _requestedStartTime;
set => SetField(ref _requestedStartTime, value);
}
public TimeSpan Duration
{
get => _duration;
set
{
SetField(ref _duration, value);
NotifyPropertyChanged(nameof(ScheduledTc));
}
}
public TVideoFormat VideoFormat => _engineViewModel.VideoFormat;
public TimeSpan ScheduledDelay
{
get => _scheduledDelay;
set => SetField(ref _scheduledDelay, value);
}
public sbyte Layer
{
get => _layer;
set => SetField(ref _layer, value);
}
public bool IsStartEvent
{
get
{
var st = Model.StartType;
return (st == TStartType.OnFixedTime || st == TStartType.Manual);
}
}
public bool IsDurationEnabled => Model.EventType != TEventType.Rundown;
public bool IsCGElementsEnabled => Model.EventType == TEventType.Live || Model.EventType == TEventType.Movie;
public bool IsDisplayCGElements => Model.Engine.CGElementsController != null;
public IEnumerable<ICGElement> Logos => Model.Engine.CGElementsController?.Logos;
public IEnumerable<ICGElement> Crawls => Model.Engine.CGElementsController?.Crawls;
public IEnumerable<ICGElement> Parentals => Model.Engine.CGElementsController?.Parentals;
public EventRightsEditViewmodel EventRightsEditViewmodel { get; }
public TemplatedEditViewmodel TemplatedEditViewmodel { get; }
public override string ToString()
{
return $"{Infralution.Localization.Wpf.ResourceEnumConverter.ConvertToString(EventType)} - {EventName}";
}
internal void _previewPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Media))
InvalidateRequerySuggested();
}
protected override void OnDispose()
{
Model.PropertyChanged -= ModelPropertyChanged;
if (TemplatedEditViewmodel != null)
{
TemplatedEditViewmodel.ModifiedChanged -= TemplatedEditViewmodel_ModifiedChanged;
TemplatedEditViewmodel?.Dispose();
}
if (EventRightsEditViewmodel != null)
{
EventRightsEditViewmodel.ModifiedChanged -= RightsModifiedChanged;
EventRightsEditViewmodel.Dispose();
}
}
#region Command methods
private void _triggerStartType(object obj)
{
if (StartType == TStartType.Manual)
StartType = TStartType.OnFixedTime;
else if (StartType == TStartType.OnFixedTime)
StartType = TStartType.Manual;
}
private bool _canTriggerStartType(object obj)
{
return (StartType == TStartType.Manual || StartType == TStartType.OnFixedTime)
&& Model.HaveRight(EventRight.Modify);
}
private void _changeMovie(object o)
{
if (Model.EventType == TEventType.Movie)
{
_chooseMedia(TMediaType.Movie, Model, Model.StartType);
}
}
private void _editMovie(object obj)
{
using (var evm = new MediaEditWindowViewmodel(Model.Media, Model.Engine.MediaManager) )
{
if (UiServices.ShowDialog<Views.MediaEditWindowView>(evm) == true)
evm.Editor.Save();
}
}
private void _checkVolume(object obj)
{
if (_media == null)
return;
IsVolumeChecking = true;
var fileManager = Model.Engine.MediaManager.FileManager;
var operation = fileManager.CreateLoudnessOperation();
operation.Source = Model.Media;
operation.MeasureStart = Model.ScheduledTc - _media.TcStart;
operation.MeasureDuration = Model.Duration;
operation.AudioVolumeMeasured += _audioVolumeMeasured;
operation.Finished += _audioVolumeFinished;
fileManager.Queue(operation, true);
}
private void _audioVolumeFinished(object sender, EventArgs e)
{
IsVolumeChecking = false;
((ILoudnessOperation) sender).Finished -= _audioVolumeFinished;
((ILoudnessOperation) sender).AudioVolumeMeasured -= _audioVolumeFinished;
}
private void _audioVolumeMeasured(object sender, AudioVolumeEventArgs e)
{
AudioVolume = e.AudioVolume;
}
private bool _canChangeMovie(object o)
{
return Model.PlayState == TPlayState.Scheduled
&& Model.EventType == TEventType.Movie
&& Model.HaveRight(EventRight.Modify);
}
private bool _canEditMovie(object o)
{
return Model.Media != null
&& Model.PlayState == TPlayState.Scheduled
&& Model.EventType == TEventType.Movie
&& Model.Engine.HaveRight(EngineRight.MediaEdit);
}
private bool _canCheckVolume(object o)
{
return !_isVolumeChecking && _canChangeMovie(o);
}
private bool _canSave(object o)
{
return IsModified
&& IsValid
&& Model.HaveRight(EventRight.Modify) == true;
}
private void _setCGElements(IMedia media)
{
IsCGEnabled = Model.Engine.EnableCGElementsForNewEvents;
if (media != null)
{
var category = media.MediaCategory;
Logo = (byte) (category == TMediaCategory.Fill || category == TMediaCategory.Show ||
category == TMediaCategory.Promo || category == TMediaCategory.Insert ||
category == TMediaCategory.Jingle
? 1
: 0);
Parental = media.Parental;
}
}
#endregion // command methods
private void ModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (!(sender is IEvent s))
return;
Application.Current?.Dispatcher.BeginInvoke((Action) delegate
{
switch (e.PropertyName)
{
case nameof(IEvent.AudioVolume):
_audioVolume = s.AudioVolume;
NotifyPropertyChanged(nameof(AudioVolume));
NotifyPropertyChanged(nameof(AudioVolumeLevel));
NotifyPropertyChanged(nameof(HasAudioVolume));
break;
case nameof(IEvent.AutoStartFlags):
_autoStartFlags = s.AutoStartFlags;
NotifyPropertyChanged(nameof(AutoStartForced));
NotifyPropertyChanged(nameof(AutoStartDaily));
break;
case nameof(IEvent.Crawl):
_crawl = s.Crawl;
NotifyPropertyChanged(nameof(Crawl));
break;
case nameof(IEvent.Logo):
_logo = s.Logo;
NotifyPropertyChanged(nameof(Logo));
break;
case nameof(IEvent.Parental):
_parental = s.Parental;
NotifyPropertyChanged(nameof(Parental));
break;
case nameof(IEvent.Duration):
_duration = s.Duration;
NotifyPropertyChanged(nameof(Duration));
break;
case nameof(IEvent.EventName):
_eventName = s.EventName;
NotifyPropertyChanged(nameof(EventName));
break;
case nameof(IEvent.IdAux):
case nameof(IEvent.IdProgramme):
break;
case nameof(IEvent.IsCGEnabled):
_isCGEnabled = s.IsCGEnabled;
NotifyPropertyChanged(nameof(IsCGEnabled));
break;
case nameof(IEvent.IsEnabled):
_isEnabled = s.IsEnabled;
NotifyPropertyChanged(nameof(IsEnabled));
break;
case nameof(IEvent.IsHold):
_isHold = s.IsHold;
NotifyPropertyChanged(nameof(IsHold));
break;
case nameof(IEvent.Media):
_media = s.Media;
NotifyPropertyChanged(nameof(Media));
break;
case nameof(IEvent.IsLoop):
_isLoop = s.IsLoop;
NotifyPropertyChanged(nameof(IsLoop));
InvalidateRequerySuggested();
break;
case nameof(IEvent.RequestedStartTime):
_requestedStartTime = s.RequestedStartTime;
NotifyPropertyChanged(nameof(RequestedStartTime));
break;
case nameof(IEvent.Offset):
break;
case nameof(IEvent.ScheduledTime):
_scheduledTime = s.ScheduledTime;
NotifyPropertyChanged(nameof(ScheduledTime));
break;
case nameof(IEvent.ScheduledTc):
_scheduledTc = s.ScheduledTc;
NotifyPropertyChanged(nameof(ScheduledTc));
break;
case nameof(IEvent.ScheduledDelay):
_scheduledDelay = s.ScheduledDelay;
NotifyPropertyChanged(nameof(ScheduledDelay));
break;
case nameof(IEvent.PlayState):
NotifyPropertyChanged(nameof(IsEditEnabled));
break;
case nameof(IEvent.StartType):
_startType = s.StartType;
NotifyPropertyChanged(nameof(StartType));
NotifyPropertyChanged(nameof(IsAutoStartEvent));
break;
case nameof(IEvent.TransitionEasing):
_transitionEasing = s.TransitionEasing;
NotifyPropertyChanged(nameof(TransitionEasing));
break;
case nameof(IEvent.TransitionType):
_transitionType = s.TransitionType;
NotifyPropertyChanged(nameof(TransitionType));
break;
case nameof(IEvent.TransitionTime):
_transitionTime = s.TransitionTime;
NotifyPropertyChanged(nameof(TransitionTime));
break;
case nameof(IEvent.TransitionPauseTime):
_transitionPauseTime = s.TransitionPauseTime;
NotifyPropertyChanged(nameof(TransitionPauseTime));
break;
case nameof(IEvent.Prior):
case nameof(IEvent.Parent):
NotifyPropertyChanged(nameof(BoundEventName));
break;
}
});
}
private void TemplatedEditViewmodel_ModifiedChanged(object sender, EventArgs e)
{
if (sender is TemplatedEditViewmodel templatedEditViewmodel && templatedEditViewmodel.IsModified)
IsModified = true;
}
private string _validateEventName()
{
if (Model.FieldLengths.TryGetValue(nameof(IEvent.EventName), out var length) && EventName.Length > length)
return resources._validate_TextTooLong;
return null;
}
private string _validateScheduledDelay()
{
if (Model.EventType != TEventType.StillImage && Model.EventType != TEventType.CommandScript)
return null;
var parent = Model.Parent;
if (parent != null && _duration + _scheduledDelay > parent.Duration)
return resources._validate_ScheduledDelayInvalid;
return null;
}
private string _validateScheduledTime()
{
if (((_startType == TStartType.OnFixedTime && (_autoStartFlags & AutoStartFlags.Daily) == AutoStartFlags.None)
|| _startType == TStartType.Manual) && Model.PlayState == TPlayState.Scheduled && _scheduledTime < Model.Engine.CurrentTime)
return resources._validate_StartTimePassed;
return null;
}
private string _validateScheduledTc()
{
var media = Media;
if (Model.EventType != TEventType.Movie || media == null)
return null;
if (_scheduledTc > media.Duration + media.TcStart)
return string.Format(resources._validate_StartTCAfterFile,
(media.Duration + media.TcStart).ToSMPTETimecodeString(Model.Engine.VideoFormat));
if (_scheduledTc < media.TcStart)
return string.Format(resources._validate_StartTCBeforeFile,
media.TcStart.ToSMPTETimecodeString(Model.Engine.VideoFormat));
return null;
}
private string _validateDuration()
{
var media = Media;
if (Model.EventType == TEventType.Movie && media != null
&& _duration + _scheduledTc > media.Duration + media.TcStart)
return resources._validate_DurationInvalid;
if (Model.EventType != TEventType.StillImage && Model.EventType != TEventType.CommandScript)
return null;
var parent = Model.Parent;
if (parent != null && _duration + _scheduledDelay > parent.Duration)
return resources._validate_ScheduledDelayInvalid;
return null;
}
private string _validateTransitionPauseTime()
{
if (_transitionPauseTime > _transitionTime)
return resources._validate_TransitionPauseTimeInvalid;
return null;
}
private string _validateTransitionTime()
{
if (_transitionTime > _duration)
return resources._validate_TransitionTimeInvalid;
return null;
}
private void _chooseMedia(TMediaType mediaType, IEvent baseEvent, TStartType startType,
VideoFormatDescription videoFormatDescription = null)
{
using (var vm = new MediaSearchViewmodel(
_engineViewModel.Engine.HaveRight(EngineRight.Preview) ? _engineViewModel.Engine : null,
Model.Engine,
mediaType, VideoLayer.Program, true, videoFormatDescription)
{
BaseEvent = baseEvent,
NewEventStartType = startType
})
{
if (UiServices.ShowDialog<Views.MediaSearchView>(vm) == true)
{
if (!(vm.SelectedMedia is IServerMedia media))
return;
Media = media;
Duration = media.DurationPlay;
ScheduledTc = media.TcPlay;
AudioVolume = null;
EventName = media.MediaName;
_setCGElements(media);
}
}
}
public bool IsValid => (from pi in GetType().GetProperties() select this[pi.Name]).All(string.IsNullOrEmpty);
private bool IsValidCommand(string commandText)
{
return string.IsNullOrWhiteSpace(commandText)
|| RegexPlay.IsMatch(commandText)
|| RegexMixerFill.IsMatch(commandText)
|| RegexMixerClip.IsMatch(commandText)
|| RegexMixerClear.IsMatch(commandText)
|| RegexCg.IsMatch(commandText)
;
}
private void RightsModifiedChanged(object sender, EventArgs e)
{
IsModified = true;
}
}
}