private SearchInformation ConvertSearch(SparkImageViewer.FileSearch.SearchInformation source) { var result = new SearchInformation(this.ConvertComplexSearch(source.Root)) { DateLastUsed = source.DateLastUsed, Key = source.Key, Name = source.Name, ThumbnailFilePath = source.ThumbnailFilekey, }; //result.SortSettings.Clear(); //source.SortSettings.ForEach(x => //{ // var sort = this.ConvertSort(x); // result.SortSettings.Add(sort); //}); result.SetSort(source.SortSettings.Select(x => this.ConvertSort(x)), true); return(result); }
/// <summary> /// アプリ外から渡されたファイルリストを使用して起動 /// </summary> /// <param name="list"></param> public void ActivateFiles(IEnumerable <string> list) { var files = list?.Where(x => x.HasText()).ToArray(); if (files.IsNullOrEmpty()) { return; } var records = this.front.ActivateFiles(files); var state = new ViewState() { Search = null, GroupKey = null, CatalogIndex = 0, ViewerIndex = 0, Type = PageType.Catalog, }; this.History.MoveNew(state); this.ChangePage(PageType.Viewer, 0, 0); var record = records[0]; //画像ロード this.core.ImageBuffer.RequestLoading (record, this.GenerateImageLoadOption(ImageQuality.Resized), null, true, default(CancellationToken)); if (records.Length != 1) { return; } string directory; string tmpDir; try { directory = System.IO.Path.GetDirectoryName(record.FullPath); tmpDir = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempPath()); } catch { return; } //一時フォルダ内のファイル if (directory.ToLower().StartsWith(tmpDir.ToLower())) { return; } //ファイルが一つだけ、かつ一時フォルダでない Task.Run(async() => { //同じフォルダ内のファイルをライブラリに登録 await this.front.ActivateFolderAsync(directory).ConfigureAwait(false); var search = new SearchInformation(new ComplexSearch(false)); search.Root.Add(new UnitSearch() { Property = FileProperty.DirectoryPathStartsWith, Reference = record.Directory, Mode = CompareMode.Equal, }); search.SetSort(new[] { new SortSetting() { Property = FileProperty.FileName, IsDescending = false } }, false); var index = await core.Library.FindIndexAsync(search, record).ConfigureAwait(false); this.lastViewerImageIndex = new OldNewPair <long>(index, index); this.front.Length .Where(x => x > index) .Take(1) .Subscribe(x => { this.viewerImageChangeGate = false; this.ViewerIndexInner = index; this.viewerImageChangeGate = true; }); state.Search = search; this.History.Current.Search = search; await Application.Current.Dispatcher.InvokeAsync(() => { this.front.SetSearch(search, true); }); }) .FireAndForget(); }