public RFiDChipChildLayerViewModel( MifareUltralightPageModel _pageModel, RFiDChipParentLayerViewModel parentUID, CARD_TYPE cardType, ObservableCollection <IDialogViewModel> _dialogs = null, bool?_isTask = null) { if (_dialogs != null) { dialogs = _dialogs; } isTask = _isTask; //device = _device; pageModel = _pageModel; _cardType = cardType; _parentUid = parentUID != null ? parentUID.UidNumber : null; _cmdReadSectorWithDefaults = new RelayCommand(ReadSectorWithDefaults); _cmdEditAuthAndModifySector = new RelayCommand(ReadSectorWithCustoms); ContextMenuItems = new List <MenuItem>(); ContextMenuItems.Add(new MenuItem() { Header = "Read Sector using default Configuration", Command = _cmdReadSectorWithDefaults }); ContextMenuItems.Add(new MenuItem() { Header = "Edit Authentication Settings and Modify Sector", Command = _cmdEditAuthAndModifySector }); children = new ObservableCollection <RFiDChipGrandChildLayerViewModel>(); LoadChildren(); }
/// <summary> /// /// </summary> /// <param name="_selectedSetupViewModel"></param> /// <param name="_dialogs"></param> public MifareUltralightSetupViewModel(object _selectedSetupViewModel, ObservableCollection <IDialogViewModel> _dialogs) { try { MefHelper.Instance.Container.ComposeParts(this); //Load Plugins databaseReaderWriter = new DatabaseReaderWriter(); chipModel = new MifareUltralightChipModel(string.Format("Task Description: {0}", SelectedTaskDescription), CARD_TYPE.MifareUltralight); pageModel = new MifareUltralightPageModel(new byte[4], 0); pageModel.PageNumber = selectedUltralightPageCurrentAsInt; childNodeViewModelFromChip = new RFiDChipChildLayerViewModel(pageModel, null, CARD_TYPE.MifareUltralight, null, true); childNodeViewModelTemp = new RFiDChipChildLayerViewModel(pageModel, null, CARD_TYPE.MifareUltralight, null, true); if (_selectedSetupViewModel is MifareUltralightSetupViewModel) { PropertyInfo[] properties = typeof(MifareUltralightSetupViewModel).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo p in properties) { // If not writable then cannot null it; if not readable then cannot check it's value if (!p.CanWrite || !p.CanRead) { continue; } MethodInfo mget = p.GetGetMethod(false); MethodInfo mset = p.GetSetMethod(false); // Get and set methods have to be public if (mget == null) { continue; } if (mset == null) { continue; } p.SetValue(this, p.GetValue(_selectedSetupViewModel)); } } else { SelectedTaskIndex = "0"; SelectedTaskDescription = "Enter a Description"; } MifareUltralightPages = CustomConverter.GenerateStringSequence(0, 15).ToArray(); SelectedUltralightPageCurrent = "0"; HasPlugins = items != null?items.Any() : false; if (HasPlugins) { SelectedPlugin = Items.FirstOrDefault(); } } catch (Exception e) { LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : "")); } }