/// <summary> /// Initializes a new instance of the <see cref="PartitionViewModel"/> class. /// </summary> /// <param name="sessionViewModel">The view model of the session to which this partition belongs.</param> /// <param name="partition">The partition for which to create the view model.</param> public PartitionViewModel(SessionViewModel sessionViewModel, IPartition partition) { this.partition = partition; this.sessionViewModel = sessionViewModel; this.sessionViewModel.DatasetViewModel.PropertyChanged += this.OnDatasetViewModelPropertyChanged; this.streamsById = new Dictionary <int, StreamTreeNode>(); this.StreamTreeRoot = new StreamContainerTreeNode(this, null, null); foreach (var stream in this.partition.AvailableStreams) { this.streamsById[stream.Id] = this.StreamTreeRoot.AddStreamTreeNode(stream); this.streamsById[stream.Id].IsTreeNodeExpanded = true; } // Check if this is a live partition (i.e. it still has a writer attached) this.UpdateLiveStatus(); if (this.IsLivePartition) { this.liveMessageCallback = new LiveMessageReceivedDelegate(this.OnMessageWritten); this.newMetadataCallback = new UpdateStreamMetadataDelegate(this.UpdateStreamMetadata); this.MonitorLivePartition(); } this.IsTreeNodeExpanded = true; // If there's no store backing the partition, alert the user. if (!this.partition.IsStoreValid) { string errorMessage = $"An error occurred while attempting to load the partition {this.partition.Name} from the store at {this.StorePath}."; Application.Current.Dispatcher.BeginInvoke((Action)(() => new MessageBoxWindow(Application.Current.MainWindow, "Error Loading Store", errorMessage, "Close", null).ShowDialog())); } }
/// <summary> /// Initializes a new instance of the <see cref="PartitionViewModel"/> class. /// </summary> /// <param name="sessionViewModel">The view model of the session to which this partition belongs.</param> /// <param name="partition">The partition for which to create the view model.</param> public PartitionViewModel(SessionViewModel sessionViewModel, IPartition partition) { this.partition = partition; this.sessionViewModel = sessionViewModel; this.sessionViewModel.DatasetViewModel.PropertyChanged += this.DatasetViewModel_PropertyChanged; this.streamsById = new Dictionary <int, IStreamTreeNode>(); this.StreamTreeRoot = new StreamTreeNode(this); foreach (var stream in this.partition.AvailableStreams) { this.streamsById[stream.Id] = this.StreamTreeRoot.AddPath(stream); } // Check if this is a live partition (i.e. it still has a writer attached) this.UpdateLiveStatus(); if (this.IsLivePartition) { this.liveMessageCallback = new LiveMessageReceivedDelegate(this.OnMessageWritten); this.newMetadataCallback = new UpdateStreamMetadataDelegate(this.UpdateStreamMetadata); this.MonitorLivePartition(); } }