|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using DiagnosticExplorer.Silverlight.WebServices;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
namespace DiagnosticExplorer.Silverlight.Controls
{
public class DiagGroup : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public DiagGroup()
{
_items = new ObservableCollection<DiagGroup>();
}
private string _id;
public string Id
{
get { return _id; }
set
{
if (_id != value)
{
_id = value;
OnPropertyChanged("Id");
}
}
}
public bool IsFolder
{
get { return string.IsNullOrEmpty(Uri); }
}
public bool IsProcess
{
get { return !IsFolder; }
}
private string _name;
public string Name
{
get { return _name; }
set
{
if (_name != value)
{
_name = value;
OnPropertyChanged("Name");
}
}
}
private ObservableCollection<DiagGroup> _items;
public ObservableCollection<DiagGroup> Items
{
get { return _items; }
set
{
if (_items != value)
{
_items = value;
OnPropertyChanged("Items");
}
}
}
private DateTime? _lastOnline;
public DateTime? LastOnline
{
get { return _lastOnline; }
set
{
if (_lastOnline != value)
{
_lastOnline = value;
OnPropertyChanged("LastOnline");
}
}
}
private int? _processId;
public int? ProcessId
{
get { return _processId; }
set
{
if (_processId != value)
{
_processId = value;
OnPropertyChanged("ProcessId");
}
}
}
private string _processName;
public string ProcessName
{
get { return _processName; }
set
{
if (_processName != value)
{
_processName = value;
OnPropertyChanged("ProcessName");
}
}
}
private string _instanceName;
public string InstanceName
{
get { return _instanceName; }
set
{
if (_instanceName != value)
{
_instanceName = value;
OnPropertyChanged("InstanceName");
}
}
}
private string _imagePath;
public string ImagePath
{
get { return _imagePath; }
set
{
if (_imagePath != value)
{
_imagePath = value;
OnPropertyChanged("ImagePath");
}
}
}
private string _message;
public string Message
{
get { return _message; }
set
{
if (_message != value)
{
_message = value;
OnPropertyChanged("Message");
}
}
}
private OnlineState _state;
public OnlineState State
{
get { return _state; }
set
{
if (_state != value)
{
_state = value;
OnPropertyChanged("State");
}
}
}
private string _uri;
public string Uri
{
get { return _uri; }
set
{
if (_uri != value)
{
_uri = value;
OnPropertyChanged("Uri");
}
}
}
private string _fullPath;
public string FullPath
{
get { return _fullPath; }
set
{
if (_fullPath != value)
{
_fullPath = value;
OnPropertyChanged("FullPath");
}
}
}
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public static class DiagGroupExtensions
{
const StringComparison _ignoreCase = StringComparison.CurrentCultureIgnoreCase;
public static IEnumerable<DiagGroup> EnumerateAll(this DiagGroup folder)
{
yield return folder;
foreach (DiagGroup child in folder.Items)
foreach (DiagGroup item in child.EnumerateAll())
yield return item;
}
public static DiagGroup FindByUri(this IEnumerable<DiagGroup> list, string uri)
{
return list.FirstOrDefault(x => string.Equals(x.Uri, uri, _ignoreCase));
}
public static DiagGroup FindById(this IEnumerable<DiagGroup> list, string id)
{
return list.FirstOrDefault(x => string.Equals(x.Id, id, _ignoreCase));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a software developer originally from Auckland, New Zealand. I have lived and worked in London since 2005.