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

96 lines
3.5 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-12-03 16:07:10 +00:00
// Copyright © 2011-2023 Natalia Portillo
2020-04-17 21:45:50 +01:00
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.Localization;
2022-03-07 07:36:44 +00:00
using JetBrains.Annotations;
namespace Aaru.Gui.ViewModels.Tabs;
2022-03-07 07:36:44 +00:00
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)
CidText = Decoders.MMC.Decoders.PrettifyCID(cid);
2022-03-06 13:29:38 +00:00
if(csd != null)
CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd);
2022-03-06 13:29:38 +00:00
if(ocr != null)
OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr);
2022-03-06 13:29:38 +00:00
if(extendedCsd != null)
ExtendedCsdText = Decoders.MMC.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)
CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid);
2022-03-06 13:29:38 +00:00
if(csd != null)
CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd);
2022-03-06 13:29:38 +00:00
if(ocr != null)
OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr);
2022-03-06 13:29:38 +00:00
if(scr != null)
ScrText = 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; }
public string CidLabel => UI.Title_CID;
public string CsdLabel => UI.Title_CSD;
public string OcrLabel => UI.Title_OCR;
public string ExtendedCsdLabel => UI.Title_Extended_CSD;
public string ScrLabel => UI.Title_SCR;
}