Files
Aaru/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs

90 lines
3.2 KiB
C#
Raw Normal View History

2020-04-17 21:45:50 +01:00
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : SdMmcInfoViewModel.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : GUI view models.
//
// --[ Description ] ----------------------------------------------------------
//
// View model and code for the SecureDigital / MultiMediaCard information tab.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2022-02-18 10:02:53 +00:00
// Copyright © 2011-2022 Natalia Portillo
2020-04-17 21:45:50 +01:00
// ****************************************************************************/
2022-03-06 13:29:38 +00:00
namespace Aaru.Gui.ViewModels.Tabs;
2022-03-07 07:36:44 +00:00
using Aaru.Decoders.MMC;
using JetBrains.Annotations;
using DeviceType = Aaru.CommonTypes.Enums.DeviceType;
2022-03-06 13:29:38 +00:00
public sealed class SdMmcInfoViewModel
{
2022-03-06 13:29:38 +00:00
public SdMmcInfoViewModel(DeviceType deviceType, [CanBeNull] byte[] cid, [CanBeNull] byte[] csd,
[CanBeNull] byte[] ocr, [CanBeNull] byte[] extendedCsd, [CanBeNull] byte[] scr)
{
2022-03-06 13:29:38 +00:00
switch(deviceType)
{
2022-03-06 13:29:38 +00:00
case DeviceType.MMC:
{
2022-03-06 13:29:38 +00:00
//Text = "MultiMediaCard";
2022-03-06 13:29:38 +00:00
if(cid != null)
2022-03-07 07:36:44 +00:00
CidText = Decoders.PrettifyCID(cid);
2022-03-06 13:29:38 +00:00
if(csd != null)
2022-03-07 07:36:44 +00:00
CsdText = Decoders.PrettifyCSD(csd);
2022-03-06 13:29:38 +00:00
if(ocr != null)
2022-03-07 07:36:44 +00:00
OcrText = Decoders.PrettifyOCR(ocr);
2022-03-06 13:29:38 +00:00
if(extendedCsd != null)
2022-03-07 07:36:44 +00:00
ExtendedCsdText = Decoders.PrettifyExtendedCSD(extendedCsd);
2022-03-06 13:29:38 +00:00
}
2022-03-06 13:29:38 +00:00
break;
case DeviceType.SecureDigital:
{
//Text = "SecureDigital";
2022-03-06 13:29:38 +00:00
if(cid != null)
2022-03-07 07:36:44 +00:00
CidText = Aaru.Decoders.SecureDigital.Decoders.PrettifyCID(cid);
2022-03-06 13:29:38 +00:00
if(csd != null)
2022-03-07 07:36:44 +00:00
CsdText = Aaru.Decoders.SecureDigital.Decoders.PrettifyCSD(csd);
2022-03-06 13:29:38 +00:00
if(ocr != null)
2022-03-07 07:36:44 +00:00
OcrText = Aaru.Decoders.SecureDigital.Decoders.PrettifyOCR(ocr);
2022-03-06 13:29:38 +00:00
if(scr != null)
2022-03-07 07:36:44 +00:00
ScrText = Aaru.Decoders.SecureDigital.Decoders.PrettifySCR(scr);
}
2022-03-06 13:29:38 +00:00
break;
}
}
2022-03-06 13:29:38 +00:00
public string CidText { get; }
public string CsdText { get; }
public string OcrText { get; }
public string ExtendedCsdText { get; }
public string ScrText { get; }
}