protected override void Create() { var hudBumperStickerType = new HudBumperStickerType(true); BumperStickers.Add(hudBumperStickerType); SelectedBumperSticker = hudBumperStickerType; }
private void Import() { var openFileDialog = new OpenFileDialog { Filter = CommonResourceManager.Instance.GetResourceString("SystemSettings_BumperStickerFileDialogFilter") }; if (openFileDialog.ShowDialog() != true) { return; } var importedBumperStickerTypes = hudLayoutService.ImportBumperStickerType(openFileDialog.FileName); if (importedBumperStickerTypes == null || importedBumperStickerTypes.Length == 0) { return; } var bumperStickerTypesMap = (from importedPlayerType in importedBumperStickerTypes join bumperStickerType in BumperStickers on importedPlayerType.Name equals bumperStickerType.Name into gj from grouped in gj.DefaultIfEmpty() select new { ImportedPlayerType = importedPlayerType, ExistingPlayerType = grouped }).ToArray(); foreach (var bumperStickerTypeMapItem in bumperStickerTypesMap) { if (bumperStickerTypeMapItem.ExistingPlayerType == null) { BumperStickers.Add(bumperStickerTypeMapItem.ImportedPlayerType); continue; } bumperStickerTypeMapItem.ExistingPlayerType.MergeWith(bumperStickerTypeMapItem.ImportedPlayerType); } }
private bool Validate() { var groupedByName = (from bumperSticker in BumperStickers where !string.IsNullOrWhiteSpace(bumperSticker.Name) group bumperSticker by bumperSticker.Name into grouped select new { Name = grouped.Key, Count = grouped.Count() }); var validationResult = BumperStickers.All(x => !string.IsNullOrWhiteSpace(x.Name)) && groupedByName.All(x => x.Count < 2); return(validationResult); }
protected override void InitializeCommands() { base.InitializeCommands(); SelectColorCommand = ReactiveCommand.Create <object>(x => SelectColor(x)); PickerSelectColorCommand = ReactiveCommand.Create(() => IsColorPickerPopupOpened = false); FilterCommand = ReactiveCommand.Create(() => PopupFiltersRequestExecute(Service.FilterTupleCollection.FirstOrDefault(f => f.ModelType == EnumFilterModelType.FilterHandGridModel))); ButtonFilterModelSectionRemoveCommand = ReactiveCommand.Create <object>(x => ButtonFilterModelSectionRemove(x)); var canDelete = this.WhenAny(x => x.SelectedBumperSticker, x => x.Value != null); DeleteCommand = ReactiveCommand.Create(() => { if (SelectedBumperSticker != null) { BumperStickers.Remove(SelectedBumperSticker); SelectedBumperSticker = BumperStickers.FirstOrDefault(); } }, canDelete); ResetCommand = ReactiveCommand.Create(() => { var defaultBumperStickers = bumperStickerTypeService.CreateDefaultBumperStickerTypes(); var defaultBumperSticker = defaultBumperStickers.FirstOrDefault(p => p.Name == SelectedBumperSticker.Name); if (defaultBumperSticker == null) { return; } SelectedBumperSticker.StatsToMerge = defaultBumperSticker.Stats; }, canDelete); ExportCommand = ReactiveCommand.Create(() => Export(new[] { SelectedBumperSticker }), canDelete); ExportAllCommand = ReactiveCommand.Create(() => Export(bumperStickers)); ImportCommand = ReactiveCommand.Create(() => Import()); }