init
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable RedundantDefaultMemberInitializer
|
||||
// ReSharper disable UnassignedGetOnlyAutoProperty
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Viewer.GraphList
|
||||
{
|
||||
/// <summary>
|
||||
/// Main class to bind to treeview
|
||||
/// </summary>
|
||||
public class TreeViewChannels : IBaseModel
|
||||
{
|
||||
private string _name = string.Empty;
|
||||
public string Name { get => _name; set { _name = value; OnPropertyChanged("Name"); } }
|
||||
|
||||
private ObservableCollection<TestGroup> _groups = new ObservableCollection<TestGroup>();
|
||||
public ObservableCollection<TestGroup> Groups { get => _groups; set { _groups = value; _groupsCount = _groups.Count; OnPropertyChanged("Groups"); } }
|
||||
|
||||
private int _groupsCount = 0;
|
||||
public int GroupsCount { get => _groupsCount; set { _groupsCount = value; OnPropertyChanged("GroupsCount"); } }
|
||||
|
||||
private string _path = string.Empty;
|
||||
public string Path { get => _path; set { _path = value; OnPropertyChanged("Path"); } }
|
||||
|
||||
public bool IsSaved { get; }
|
||||
|
||||
private bool _isExpanded = true;
|
||||
public bool IsExpanded { get => _isExpanded; set { _isExpanded = value; OnPropertyChanged("IsExpanded"); } }
|
||||
|
||||
private bool _isSelected = false;
|
||||
public bool IsSelected { get => _isSelected; set { _isSelected = value; OnPropertyChanged("IsSelected"); } }
|
||||
|
||||
#region PropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion PropertyChanged
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Child class for TreeViewChannels
|
||||
/// </summary>
|
||||
public class TestGroup : INotifyPropertyChanged
|
||||
{
|
||||
private string _path = string.Empty;
|
||||
public string Path { get => _path; set { _path = value; OnPropertyChanged("Path"); } }
|
||||
|
||||
private string _dtsFile = string.Empty;
|
||||
public string DTSFile { get => _dtsFile; set { _dtsFile = value; OnPropertyChanged("DTSFile"); } }
|
||||
|
||||
private IBaseViewModel _parent;
|
||||
|
||||
/// <summary>
|
||||
/// Parent ViewModel
|
||||
/// </summary>
|
||||
public IBaseViewModel Parent { get => _parent; set { _parent = value; OnPropertyChanged("Parent"); } }
|
||||
|
||||
private bool _isLocked = false;
|
||||
/// <summary>
|
||||
/// Locked Graph - call parent function to lock graph's channels
|
||||
/// </summary>
|
||||
public bool IsLocked
|
||||
{
|
||||
get => _isLocked;
|
||||
set
|
||||
{
|
||||
_isLocked = value;
|
||||
((IGraphMainViewModel)Parent).AddLockedGroupChannels(TestName, Name, Channels.ToList(), _isLocked);
|
||||
OnPropertyChanged("IsLocked");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isGraph = false;
|
||||
public bool IsGraph { get => _isGraph; set { _isGraph = value; OnPropertyChanged("IsGraph"); } }
|
||||
|
||||
private bool _isExpanded = true;
|
||||
public bool IsExpanded { get => _isExpanded; set { _isExpanded = value; OnPropertyChanged("IsExpanded"); } }
|
||||
|
||||
private bool _canLock = true;
|
||||
|
||||
public bool CanLock
|
||||
{
|
||||
get => _canLock;
|
||||
set
|
||||
{
|
||||
_canLock = value;
|
||||
OnPropertyChanged("CanLock");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected = false;
|
||||
|
||||
/// <summary>
|
||||
/// Selected Graph - call parent function to select graph's channels
|
||||
/// </summary>
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (!CanLock && value)
|
||||
{
|
||||
return; //ignore, don't select
|
||||
}
|
||||
if (Name.StartsWith("Test Channels") || Name.StartsWith("Calculated Channels")) return;
|
||||
var prevValue = _isSelected;
|
||||
_isSelected = value;
|
||||
if (IsSelected && IsSelected != prevValue) ((IGraphMainViewModel)Parent).AddSelectedGroupChannels(Name, Channels.ToList());
|
||||
OnPropertyChanged("IsSelected");
|
||||
}
|
||||
}
|
||||
|
||||
private string _testName = string.Empty;
|
||||
public string TestName { get => _testName; set { _testName = value; OnPropertyChanged("TestName"); } }
|
||||
|
||||
private string _name = string.Empty;
|
||||
public string Name { get => _name; set { _name = value; OnPropertyChanged("Name"); } }
|
||||
|
||||
private string _displayName = string.Empty;
|
||||
public string DisplayName { get => _displayName; set { _displayName = value; OnPropertyChanged("DisplayName"); } }
|
||||
|
||||
private ObservableCollection<ITestChannel> _channels = new ObservableCollection<ITestChannel>();
|
||||
public ObservableCollection<ITestChannel> Channels { get => _channels; set { _channels = value; _channelCount = _channels.Count; OnPropertyChanged("Channels"); } }
|
||||
|
||||
private int _channelCount = 0;
|
||||
public int ChannelCount { get => _channelCount; set { _channelCount = value; OnPropertyChanged("ChannelCount"); } }
|
||||
|
||||
#region PropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
#endregion PropertyChanged
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user