// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace MemoryStreamVisualizer;
using System.IO;
using System.Runtime.Serialization;
using System.Windows;
using Microsoft.VisualStudio.Extensibility.UI;
///
/// ViewModel class representing the data contained by a .
///
[DataContract]
public class MemoryStreamData : NotifyPropertyChangedObject
{
private long length;
private long position;
private Visibility loadingVisibility = Visibility.Visible;
///
/// Gets or sets the length of the .
///
[DataMember]
public long Length
{
get => this.length;
set
{
if (this.SetProperty(ref this.length, value))
{
this.RaiseNotifyPropertyChangedEvent(nameof(this.HexLength));
}
}
}
///
/// Gets the length of the in hex format.
///
[DataMember]
public string HexLength => $"{this.length:X}h";
///
/// Gets or sets the current position of the .
///
[DataMember]
public long Position
{
get => this.position;
set
{
if (this.SetProperty(ref this.position, value))
{
this.RaiseNotifyPropertyChangedEvent(nameof(this.HexPosition));
}
}
}
///
/// Gets the current position of the in hex format.
///
[DataMember]
public string HexPosition => $"{this.position:X}h";
///
/// Gets the data currently contained in the .
///
[DataMember]
public ObservableList Data { get; } = new();
///
/// Gets or sets whether the loading bar should be visible.
///
[DataMember]
public Visibility LoadingVisibility
{
get => this.loadingVisibility;
set => this.SetProperty(ref this.loadingVisibility, value);
}
}