-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathViewControl.cs
More file actions
90 lines (72 loc) · 2.49 KB
/
ViewControl.cs
File metadata and controls
90 lines (72 loc) · 2.49 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
// Copyright (c) TensorStack. All rights reserved.
// Licensed under the Apache 2.0 License.
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Controls;
using TensorStack.WPF.Services;
namespace TensorStack.WPF.Controls
{
public abstract class ViewControl : UserControl, IViewControl, INotifyPropertyChanged
{
private readonly NavigationService _navigationService;
private bool _isDragDrop;
private DragDropType _dragDropType;
public ViewControl(NavigationService navigationService)
{
_navigationService = navigationService;
}
public virtual int Id { get; }
public NavigationService NavigationService => _navigationService;
public bool IsDragDrop
{
get { return _isDragDrop; }
set { SetProperty(ref _isDragDrop, value); }
}
public DragDropType DragDropType
{
get { return _dragDropType; }
set { SetProperty(ref _dragDropType, value); }
}
public virtual Task OpenAsync(OpenViewArgs args = default)
{
return Task.CompletedTask;
}
public virtual Task CloseAsync()
{
return Task.CompletedTask;
}
public virtual Task<bool> ShutdownAsync(bool force = false)
{
return Task.FromResult(false);
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null)
{
if (!Equals(field, newValue))
{
field = newValue;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return true;
}
return false;
}
#endregion
}
public interface IViewControl
{
int Id { get; }
Task OpenAsync(OpenViewArgs args = default);
Task CloseAsync();
Task<bool> ShutdownAsync(bool force = false);
NavigationService NavigationService { get; }
bool IsDragDrop { get; set; }
DragDropType DragDropType { get; set; }
}
public record OpenViewArgs;
}