public void Initialize(ViewRequest viewRequest) { var request = viewRequest as CardViewRequest; if (request == null) { return; } box = request.Box; card = request.Card; AvailableBoards = box.Boards.Items.ToList(); SelectedBoard = AvailableBoards.First(); var str = request.Card.Header; var maxLen = str.Length >= 22 ? 22 : str.Length; CardHeader = "Select destination board and cell to make move \"" + request.Card.Header.Substring(0, maxLen) + (str.Length > 22 ? "..." : "") + "\""; Title = $"Move card {card.Header} to"; IsOpened = true; }
private IEnumerable <Board> GetBoardsSelectedToExport() { var selectedBoardIds = new HashSet <int>( AvailableBoards .Where(x => x.IsChecked) .Select(x => x.Board.Id) ); return(mapper.Map <IEnumerable <Board> >(SelectedBox.Boards.Items) .Where(x => selectedBoardIds.Contains(x.Id))); }
private void refreshAvailableItems(IEnumerable <string> availableItems) { AvailableBoards.Clear(); foreach (var item in availableItems) { AvailableBoards.Add(new SavedBoardViewModel() { Name = item }); } }
public ExportViewModel(IShell sh, IAppModel am, IDialogCoordinator dc, IAppConfig cfg, IMapper mapper) { shell = sh; appModel = am; dialCoord = dc; this.mapper = mapper; _appConfig = cfg; AvailableBoxes = appModel.Boxes; boards = new SourceList <BoardToExport>(); AvailableBoards = boards.SpawnCollection(); ExportJson = true; DatePostfix = true; SplitBoardsToFiles = false; PdfOptionsAvailable = new PdfOptionsAvailable { PageSizes = Enum.GetValues(typeof(PageSize)).Cast <PageSize>().ToArray(), PageOrientations = Enum.GetValues(typeof(PageOrientation)).Cast <PageOrientation>().ToArray(), ScaleFittings = Enum.GetValues(typeof(ScaleFitting)).Cast <ScaleFitting>().ToArray() }; PdfOptions = new PdfOptions { PageSize = PageSize.A4, PageOrientation = PageOrientation.Portrait, ScaleOptions = new ScaleOptions { Padding = new Thickness(), ScaleToFit = true, ScaleFitting = ScaleFitting.BothDirections, MaxScale = 1.0, MinScale = 0.0 } }; var canExport = boards .Connect() .AutoRefresh() .Filter(x => x.IsChecked) .Select(x => AvailableBoards.Count(y => y.IsChecked) > 0 && !string.IsNullOrEmpty(SelectedBox.Uri) && File.Exists(SelectedBox.Uri)); ExportCommand = ReactiveCommand.CreateFromTask(ExportCommandExecute, canExport); SelectTargetFolderCommand = ReactiveCommand.Create(SelectTargetFolderCommandExecute); CancelCommand = ReactiveCommand.Create(Close); this.ObservableForProperty(x => x.SelectedBox) .Where(x => x.Value != null) .Select(x => x.Value) .Subscribe(box => { boards.ClearAndAddRange(box.Boards.Items .Select(x => new BoardToExport { Board = x, IsChecked = true })); TargetFile = Path.GetFileNameWithoutExtension(box.Uri) + "_export"; }); this.ObservableForProperty(x => x.TargetFolder) .Subscribe(x => cfg.ArchiveFolder = x.Value); SelectedBox = AvailableBoxes.First(); var fi = new FileInfo(SelectedBox.Uri); TargetFolder = cfg.ArchiveFolder ?? fi.DirectoryName; _appConfig.ColorThemeObservable .Subscribe(x => ColorTheme = x); }