Exemplo n.º 1
0
        private async Task <Unit> OpenRedFileAsync(FileEntry file)
        {
            if (file != null)
            {
                _progressService.IsIndeterminate = true;
                try
                {
                    var fileViewModel = new RedDocumentViewModel(file.FileName);
                    await using (var stream = new MemoryStream())
                    {
                        file.Extract(stream);
                        fileViewModel.OpenStream(stream, null);
                    }

                    if (!DockedViews.Contains(fileViewModel))
                    {
                        DockedViews.Add(fileViewModel);
                    }

                    ActiveDocument = fileViewModel;
                    UpdateTitle();
                }
                catch (Exception e)
                {
                    _loggerService.Error(e.Message);
                }
                finally
                {
                    _progressService.IsIndeterminate = false;
                }
            }

            return(Unit.Default);
        }
Exemplo n.º 2
0
        public void OpenFileFromHash(ulong hash)
        {
            if (hash != 0)
            {
                _progressService.IsIndeterminate = true;
                try
                {
                    var _archiveManager = Locator.Current.GetService <IArchiveManager>();
                    var file            = _archiveManager.Lookup(hash);
                    if (file.HasValue && file.Value is FileEntry fe)
                    {
                        var fileViewModel = new RedDocumentViewModel(fe.FileName);
                        using (var stream = new MemoryStream())
                        {
                            fe.Extract(stream);
                            fileViewModel.OpenStream(stream, null);
                        }
                        if (!DockedViews.Contains(fileViewModel))
                        {
                            DockedViews.Add(fileViewModel);
                        }

                        ActiveDocument = fileViewModel;
                        UpdateTitle();
                    }
                }
                catch (Exception e)
                {
                    _loggerService.Error(e.Message);
                }
                finally
                {
                    _progressService.IsIndeterminate = false;
                }
            }
        }
Exemplo n.º 3
0
 private void OnAddNewDockedWindow(BioViewModel vm)
 {
     DockedViews.Add(vm);
     SelectedView = vm;
 }