891562: Need to move the latest changes to public repo

This commit is contained in:
Bharat Ram 2024-07-01 12:01:57 +05:30
Родитель 5703821451
Коммит 13f407f5ec
203 изменённых файлов: 8932 добавлений и 1098 удалений

4
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,4 @@
**/.vs/
.git/
**/bin/
**/obj

Просмотреть файл

@ -9,7 +9,7 @@ This document explorer demo application showcases several Syncfusion Blazor UI c
The samples requires the below requirements to run.
* [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
* [.NET Core SDK 3.1.2](https://dotnet.microsoft.com/download/dotnet-core/3.1)
* [.NET 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
### Run

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
@* <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="DocumentExplorer.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
*@

Просмотреть файл

@ -12,13 +12,15 @@ using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;
using Syncfusion.Blazor.PdfViewer;
using DocumentExplorer.Models;
using SkiaSharp;
using System.Text.Json;
namespace DocumentExplorer.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DocumentEditorController : ControllerBase
{
{
private string basePath;
private string baseLocation;
IWebHostEnvironment _hostingEnvironment;
@ -30,19 +32,16 @@ namespace DocumentExplorer.Controllers
}
[Route("Import")]
public string[] Import([FromBody] FileManagerDirectoryContent args)
public string Import([FromBody] FileManagerDirectoryContent args)
{
string fileLocation = this.baseLocation + args.Path.Replace("/", "\\");
List<string> returnArray = new List<string>();
using (FileStream fs = new FileStream(fileLocation, FileMode.Open, FileAccess.Read))
{
WordDocument document = WordDocument.Load(fs, GetImportFormatType(Path.GetExtension(fileLocation).ToLower()));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
string json = JsonSerializer.Serialize(document);
document.Dispose();
returnArray.Add(json);
return ConvertToImages(fs, returnArray, GetDocIOFormatType(Path.GetExtension(args.Path).ToLower())).ToArray();
}
return json;
}
}
private List<string> ConvertToImages(FileStream fs, List<string> returnStrings, Syncfusion.DocIO.FormatType type)
{
@ -66,8 +65,20 @@ namespace DocumentExplorer.Controllers
pdfExportImage.Load(outputStream);
//Exports the PDF document pages into images
Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, pdfExportImage.PageCount-1);
foreach (Bitmap bitmap in bitmapimage)
SKBitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, pdfExportImage.PageCount - 1);
Bitmap[] bitmapImages = new Bitmap[bitmapimage.Length];
for (int i = 0; i < bitmapimage.Length; i++)
{
using (SKImage skImage = SKImage.FromBitmap(bitmapimage[i]))
using (SKData skData = skImage.Encode(SKEncodedImageFormat.Png, 100))
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(skData.ToArray()))
{
bitmapImages[i] = new Bitmap(stream);
}
}
foreach (Bitmap bitmap in bitmapImages)
{
using (MemoryStream ms = new MemoryStream())
{
@ -91,7 +102,7 @@ namespace DocumentExplorer.Controllers
}
}
private ImportFormatType GetImportFormatType(string format)
{
if (string.IsNullOrEmpty(format))

Просмотреть файл

@ -22,50 +22,103 @@ namespace DocumentExplorer.Controllers
{
private PhysicalFileProvider operation;
private string basePath;
string root = "wwwroot\\Files";
string rootPath;
string virtualConnection;
public FileManagerController(IWebHostEnvironment hostingEnvironment)
{
this.basePath = hostingEnvironment.ContentRootPath;
this.operation = new PhysicalFileProvider();
this.operation.RootFolder(this.basePath + "\\wwwroot\\Files"); // Data\\Files denotes in which files and folders are available.
if (basePath.EndsWith("\\"))
this.rootPath = this.basePath + this.root;
else
this.rootPath = this.basePath + "\\" + this.root;
this.operation.RootFolder(rootPath);
}
// Processing the File Manager operations
[Route("FileOperations")]
public object FileOperations([FromBody] FileManagerCustomContent args)
{
args.RootType = HttpContext.Request.Headers["RootType"];
if (basePath.EndsWith("\\"))
{
virtualConnection = this.basePath + "wwwroot\\VirtualConnections";
}
else
{
virtualConnection = this.basePath + "\\wwwroot\\VirtualConnections";
}
DateTime currentTime = DateTime.Now;
DateTime deletionThreshold = currentTime.AddHours(-24);
DirectoryInfo virtualDirectoryInfo = new DirectoryInfo(virtualConnection);
if (Directory.Exists(virtualConnection) && virtualDirectoryInfo.CreationTime <= deletionThreshold)
{
Directory.Delete(virtualConnection, true);
}
if (!Directory.Exists(virtualConnection))
{
//Create virtual root directory
Directory.CreateDirectory(virtualConnection);
}
string userID = virtualConnection + "\\" + HttpContext.Connection.Id + "\\Files";
string virtualUser = virtualConnection + "\\" + HttpContext.Connection.Id + "\\User";
string virtualTrash = virtualConnection + "\\" + HttpContext.Connection.Id + "\\Trash";
if (!Directory.Exists(userID))
{
Directory.CreateDirectory(userID);
Directory.CreateDirectory(virtualUser);
Directory.CreateDirectory(virtualTrash);
CopyFolder(rootPath, userID);
CopyFolder(this.basePath + "\\wwwroot\\User", virtualUser);
CopyFolder(this.basePath + "\\wwwroot\\Trash", virtualTrash);
}
//Set user directory as root
this.operation.RootFolder(userID);
if (args.Action == "delete" || args.Action == "rename")
{
if ((args.TargetPath == null) && (args.Path == ""))
{
FileManagerResponse response = new FileManagerResponse();
response.Error = new ErrorDetails { Code = "401", Message = "Restricted to modify the root folder." };
return this.operation.ToCamelCase(response);
}
}
switch (args.Action)
{
// Add your custom action here
case "read":
if ((args.RootType != null) && ((args.RootType == "Recent") /*|| (args.RootType == "Starred")*/))
if ((args.RootType != null) && ((args.RootType == "Recent")))
{
FileManagerResponse result1 = this.operation.Search(args.Path, "*", args.ShowHiddenItems, false);
result1 = FilterRecentFiles(result1);
return AddStarDetails(result1);
}
else if ((args.RootType != null) && (args.RootType == "Starred"))
{
return FilterStarred(this.operation.Search(args.Path, "*", args.ShowHiddenItems, false));
return FilterRecentFiles(result1);
}
else
{
return AddStarDetails(this.operation.GetFiles(args.Path, args.ShowHiddenItems));
return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems));
}
case "delete":
#if Publish
FileManagerResponse deleteResponse = new FileManagerResponse();
deleteResponse.Error = new ErrorDetails() { Code = "401", Message = "Restricted to perform this action" };
return this.operation.ToCamelCase(deleteResponse);
#else
FileManagerDirectoryContent[] items1 = args.Data;
string[] names1 = args.Names;
for (var i = 0; i < items1.Length; i++)
{
names1[i] = ((items1[i].FilterPath + items1[i].Name).Substring(1));
RemoveStarred(names1[i]);
}
return this.operation.ToCamelCase(MoveToTrash(args.Data));
return this.operation.ToCamelCase(MoveToTrash(args.Data, HttpContext.Connection.Id, virtualConnection, virtualUser));
#endif
case "copy":
case "move":
FileManagerResponse response = new FileManagerResponse();
response.Error = new ErrorDetails() { Code = "401", Message = "Restricted to perform this action" };
return this.operation.ToCamelCase(response);
case "details":
if ((args.RootType != null) && ((args.RootType == "Recent") || (args.RootType == "Starred")))
if ((args.RootType != null) && ((args.RootType == "Recent")))
{
FileManagerDirectoryContent[] items = args.Data;
string[] names = args.Names;
@ -87,16 +140,11 @@ namespace DocumentExplorer.Controllers
if ((args.RootType != null) && ((args.RootType == "Recent")))
{
FileManagerResponse result1 = this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive);
result1 = FilterRecentFiles(result1);
return AddStarDetails(result1);
}
else if ((args.RootType != null) && (args.RootType == "Starred"))
{
return FilterStarred(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));
return FilterRecentFiles(result1);
}
else
{
return AddStarDetails(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));
return this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));
}
case "rename":
// Path - Current path of the renamed file; Name - Old file name; NewName - New file name
@ -121,13 +169,13 @@ namespace DocumentExplorer.Controllers
result.Files = allFiles;
return result;
}
public FileManagerResponse MoveToTrash(FileManagerDirectoryContent[] dataArray)
public FileManagerResponse MoveToTrash(FileManagerDirectoryContent[] dataArray, string userId, String virtualConnection, string virtualUser)
{
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
string jsonPath = virtualUser + "\\trash.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<TrashContents> DeletedFiles = JsonConvert.DeserializeObject<List<TrashContents>>(jsonData) ?? new List<TrashContents>();
PhysicalFileProvider trashOperation = new PhysicalFileProvider();
string root = this.basePath + "\\wwwroot";
string root = virtualConnection + "\\" + userId;
trashOperation.RootFolder(root);
List<FileManagerDirectoryContent> deletedFiles = new List<FileManagerDirectoryContent>();
foreach (FileManagerDirectoryContent data in dataArray)
@ -158,59 +206,6 @@ namespace DocumentExplorer.Controllers
System.IO.File.WriteAllText(jsonPath, jsonData);
return new FileManagerResponse() { Files = deletedFiles };
}
public string AddStarDetails(FileManagerResponse value)
{
string jsonPath = this.basePath + "\\wwwroot\\User\\star.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<string> starredFiles = JsonConvert.DeserializeObject<List<string>>(jsonData) ?? new List<string>();
FileResponse readResponse = new FileResponse();
readResponse.CWD = value.CWD;
readResponse.Files = JsonConvert.DeserializeObject<IEnumerable<FileManagerCustomContent>>(JsonConvert.SerializeObject(value.Files));
foreach (FileManagerCustomContent file in readResponse.Files)
{
file.FilterPath = file.FilterPath.Replace(Path.DirectorySeparatorChar, '/');
file.Starred = starredFiles.Contains(file.FilterPath + file.Name);
}
readResponse.Details = value.Details;
readResponse.Error = value.Error;
return JsonConvert.SerializeObject(readResponse, new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } });
}
public string FilterStarred(FileManagerResponse value)
{
string jsonPath = this.basePath + "\\wwwroot\\User\\star.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<string> starredFiles = JsonConvert.DeserializeObject<List<string>>(jsonData) ?? new List<string>();
FileResponse readResponse = new FileResponse();
readResponse.CWD = value.CWD;
List<FileManagerCustomContent> files = new List<FileManagerCustomContent>();
List<FileManagerCustomContent> allFiles = JsonConvert.DeserializeObject<List<FileManagerCustomContent>>(JsonConvert.SerializeObject(value.Files));
foreach (FileManagerCustomContent file in allFiles)
{
file.FilterPath = file.FilterPath.Replace(Path.DirectorySeparatorChar, '/');
if (starredFiles.Contains(file.FilterPath + file.Name))
{
file.Starred = true;
files.Add(file);
}
}
readResponse.Files = files;
readResponse.Details = value.Details;
readResponse.Error = value.Error;
return JsonConvert.SerializeObject(readResponse, new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } });
}
public void RemoveStarred(string filePath)
{
string jsonPath = this.basePath + "\\wwwroot\\User\\star.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<string> starredFiles = JsonConvert.DeserializeObject<List<string>>(jsonData) ?? new List<string>();
string path = filePath.Replace(Path.DirectorySeparatorChar, '/');
if (starredFiles.Contains(path))
{
starredFiles.Remove(path);
}
jsonData = JsonConvert.SerializeObject(starredFiles);
System.IO.File.WriteAllText(jsonPath, jsonData);
}
[Route("Upload")]
public IActionResult Upload(string path, IList<IFormFile> uploadFiles, string action)
{
@ -220,9 +215,14 @@ namespace DocumentExplorer.Controllers
Response.ContentType = "application/json; charset=utf-8";
Response.StatusCode = 403;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "The upload functionality is restricted in this online demo. To test this demo application with upload functionality, please download the source code from the GitHub location (https://github.com/syncfusion/blazor-showcase-document-explorer) and run it.";
return Content("The upload functionality is restricted in this online demo. To test this demo application with upload functionality, please download the source code from the GitHub location (https://github.com/syncfusion/blazor-showcase-document-explorer) and run it.");
#else
FileManagerResponse uploadResponse;
uploadResponse = operation.Upload(path, uploadFiles, action, null);
PhysicalFileProvider uploadOperation = new PhysicalFileProvider();
string basePath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id;
string userID = this.basePath + "wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\Files";
uploadOperation.RootFolder(userID);
uploadResponse = operation.Upload(path, uploadFiles, action, basePath, null);
if (uploadResponse.Error != null)
{
Response.Clear();
@ -230,8 +230,8 @@ namespace DocumentExplorer.Controllers
Response.StatusCode = Convert.ToInt32(uploadResponse.Error.Code);
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;
}
#endif
return Content("");
#endif
}
[Route("Download")]
@ -250,7 +250,8 @@ namespace DocumentExplorer.Controllers
[Route("ToggleStarred")]
public IActionResult ToggleStarred([FromBody] FileManagerCustomContent args)
{
string jsonPath = this.basePath + "\\wwwroot\\User\\star.json";
string basePath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id +"\\User";
string jsonPath = basePath + "\\star.json";
StreamReader reader = new StreamReader(jsonPath);
string jsonData = reader.ReadToEnd();
reader.Dispose();
@ -275,6 +276,26 @@ namespace DocumentExplorer.Controllers
return this.operation.GetImage(args.Path, args.Id, false, null, null);
}
private void CopyFolder(string source, string destination)
{
if (!Directory.Exists(destination))
{
Directory.CreateDirectory(destination);
}
foreach (var file in Directory.EnumerateFiles(source))
{
var dest = Path.Combine(destination, Path.GetFileName(file));
System.IO.File.Copy(file, dest);
}
foreach (var folder in Directory.EnumerateDirectories(source))
{
var dest = Path.Combine(destination, Path.GetFileName(folder));
CopyFolder(folder, dest);
}
}
public class FileManagerCustomContent : FileManagerDirectoryContent
{
public string RootType { get; set; }

Просмотреть файл

@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using DocumentExplorer.Models.FileManager;
using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationToPdfConverter;
using Syncfusion.PresentationRenderer;
namespace DocumentExplorer.Controllers
{

Просмотреть файл

@ -15,6 +15,7 @@ using Syncfusion.Blazor.PdfViewer;
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;
using DocumentExplorer.Models;
using SkiaSharp;
namespace DocumentExplorer.Controllers
{
@ -28,13 +29,14 @@ namespace DocumentExplorer.Controllers
{
basePath = hostingEnvironment.ContentRootPath;
operation = new PhysicalFileProvider();
operation.RootFolder(this.basePath + "\\wwwroot\\Files"); // Data\\Files denotes in which files and folders are available.
operation.RootFolder(this.basePath + "\\wwwroot\\VirtualConnections\\"); // Data\\Files denotes in which files and folders are available.
}
[Route("GetPreview")]
public string GetPreview([FromBody] FileManagerDirectoryContent args)
{
string baseFolder = this.basePath + "\\wwwroot\\Files";
string baseFolder = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\Files";
this.operation.RootFolder(baseFolder);
try
{
String fullPath = baseFolder + args.Path;
@ -49,9 +51,20 @@ namespace DocumentExplorer.Controllers
//Loads the PDF document
pdfExportImage.Load(fileStream);
//Exports the PDF document pages into images
Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
imageStream = new MemoryStream();
bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
SkiaSharp.SKBitmap[] skBitmaps = pdfExportImage.ExportAsImage(0, 0);
System.Drawing.Bitmap[] bitmapImages = new System.Drawing.Bitmap[skBitmaps.Length];
for (int i = 0; i < skBitmaps.Length; i++)
{
using (SKImage skImage = SKImage.FromBitmap(skBitmaps[i]))
using (SKData skData = skImage.Encode(SKEncodedImageFormat.Png, 100))
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(skData.ToArray()))
{
bitmapImages[i] = new System.Drawing.Bitmap(stream);
}
}
imageStream = new MemoryStream();
bitmapImages[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
imageStream.Position = 0;
pdfExportImage.Dispose();
fileStream.Close();
@ -87,9 +100,21 @@ namespace DocumentExplorer.Controllers
//Loads the PDF document
pdfExportImage.Load(outputStream);
//Exports the PDF document pages into images
Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
SKBitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
Bitmap[] bitmapImages = new Bitmap[bitmapimage.Length];
for (int i = 0; i < bitmapimage.Length; i++)
{
using (SKImage skImage = SKImage.FromBitmap(bitmapimage[i]))
using (SKData skData = skImage.Encode(SKEncodedImageFormat.Png, 100))
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(skData.ToArray()))
{
bitmapImages[i] = new Bitmap(stream);
}
}
imageStream = new MemoryStream();
bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
bitmapImages[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
imageStream.Position = 0;
fileStream.Close();

Просмотреть файл

@ -22,6 +22,7 @@ using Syncfusion.PresentationRenderer;
using System.Drawing;
using Microsoft.AspNetCore.Cors;
using DocumentExplorer.Models;
using SkiaSharp;
namespace DocumentExplorer.Controllers
{
@ -106,9 +107,20 @@ namespace DocumentExplorer.Controllers
//Loads the PDF document
pdfExportImage.Load(fileStream);
//Exports the PDF document pages into images
Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
SkiaSharp.SKBitmap[] skBitmaps = pdfExportImage.ExportAsImage(0, 0);
System.Drawing.Bitmap[] bitmapImages = new System.Drawing.Bitmap[skBitmaps.Length];
for (int i = 0; i < skBitmaps.Length; i++)
{
using (SKImage skImage = SKImage.FromBitmap(skBitmaps[i]))
using (SKData skData = skImage.Encode(SKEncodedImageFormat.Png, 100))
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(skData.ToArray()))
{
bitmapImages[i] = new System.Drawing.Bitmap(stream);
}
}
imageStream = new MemoryStream();
bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
bitmapImages[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
imageStream.Position = 0;
pdfExportImage.Dispose();
fileStream.Close();
@ -137,9 +149,20 @@ namespace DocumentExplorer.Controllers
//Loads the PDF document
pdfExportImage.Load(outputStream);
//Exports the PDF document pages into images
Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
SkiaSharp.SKBitmap[] skBitmaps = pdfExportImage.ExportAsImage(0, 0);
System.Drawing.Bitmap[] bitmapImages = new System.Drawing.Bitmap[skBitmaps.Length];
for (int i = 0; i < skBitmaps.Length; i++)
{
using (SKImage skImage = SKImage.FromBitmap(skBitmaps[i]))
using (SKData skData = skImage.Encode(SKEncodedImageFormat.Png, 100))
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(skData.ToArray()))
{
bitmapImages[i] = new System.Drawing.Bitmap(stream);
}
}
imageStream = new MemoryStream();
bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
bitmapImages[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
imageStream.Position = 0;
fileStream.Close();

Просмотреть файл

@ -22,11 +22,10 @@ namespace DocumentExplorer.Controllers
private string basePath;
private string baseLocation;
public TrashController(IWebHostEnvironment hostingEnvironment)
{
this.basePath = hostingEnvironment.ContentRootPath;
this.baseLocation = this.basePath + "\\wwwroot";
this.baseLocation = this.basePath + "\\wwwroot\\VirtualConnections\\";
this.operation = new PhysicalFileProvider();
}
@ -74,7 +73,7 @@ namespace DocumentExplorer.Controllers
{
FileManagerResponse readResponse = new FileManagerResponse();
FileManagerDirectoryContent cwd = new FileManagerDirectoryContent();
String fullPath = (this.baseLocation + "/Trash");
String fullPath = (this.baseLocation + HttpContext.Connection.Id + "/Trash");
DirectoryInfo directory = new DirectoryInfo(fullPath);
cwd.Name = "Trash";
cwd.Size = 0;
@ -86,7 +85,7 @@ namespace DocumentExplorer.Controllers
cwd.FilterPath = "/";
cwd.Permission = null;
readResponse.CWD = cwd;
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
string jsonPath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id +"\\User\\trash.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<TrashContents> DeletedFiles = JsonConvert.DeserializeObject<List<TrashContents>>(jsonData) ?? new List<TrashContents>();
List<FileManagerDirectoryContent> files = new List<FileManagerDirectoryContent>();
@ -99,7 +98,7 @@ namespace DocumentExplorer.Controllers
}
public FileManagerResponse GetDetails(FileManagerDirectoryContent[] files)
{
this.operation.RootFolder(this.baseLocation + "\\Trash");
this.operation.RootFolder(this.baseLocation + HttpContext.Connection.Id + "\\Trash");
FileManagerResponse response;
string[] names = new string[files.Length];
string responseName = "";
@ -117,8 +116,8 @@ namespace DocumentExplorer.Controllers
}
public FileManagerResponse DeleteFiles(FileManagerDirectoryContent[] files)
{
this.operation.RootFolder(this.baseLocation);
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
this.operation.RootFolder(this.baseLocation + HttpContext.Connection.Id);
string jsonPath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\User\\trash.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<FileManagerDirectoryContent> responseFiles =new List<FileManagerDirectoryContent>();
List<TrashContents> DeletedFiles = JsonConvert.DeserializeObject<List<TrashContents>>(jsonData) ?? new List<TrashContents>();
@ -126,7 +125,7 @@ namespace DocumentExplorer.Controllers
{
TrashContents trashFile = DeletedFiles.Find(x => (x.Container.Equals(file.Id)));
string trashPath = "/Trash/" + trashFile.Container;
DeleteDirectory(this.baseLocation + trashPath);
DeleteDirectory(this.baseLocation + HttpContext.Connection.Id + trashPath);
responseFiles.Add(trashFile.Data);
DeletedFiles.Remove(trashFile);
}
@ -137,9 +136,9 @@ namespace DocumentExplorer.Controllers
[Route("EmptyTrash")]
public IActionResult EmptyTrash()
{
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
string jsonPath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\User\\trash.json";
string jsonData ="";
string[] dirs = Directory.GetDirectories(this.baseLocation);
string[] dirs = Directory.GetDirectories(this.baseLocation + HttpContext.Connection.Id);
foreach (string dir in dirs)
{
DeleteDirectory(dir);
@ -151,8 +150,8 @@ namespace DocumentExplorer.Controllers
[Route("Restore")]
public IActionResult Restore([FromBody] FileManagerDirectoryContent[] files)
{
this.operation.RootFolder(this.baseLocation);
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
this.operation.RootFolder(this.baseLocation + HttpContext.Connection.Id);
string jsonPath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\User\\trash.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
string responseString = "";
List<TrashContents> DeletedFiles = JsonConvert.DeserializeObject<List<TrashContents>>(jsonData) ?? new List<TrashContents>();
@ -164,7 +163,7 @@ namespace DocumentExplorer.Controllers
FileManagerResponse response = this.operation.Move(trashPath, fileLocation, new string[] { trashFile.Name }, new string[] { trashFile.Name }, null, null);
if ((response.Error == null))
{
DeleteDirectory(this.baseLocation + trashPath);
DeleteDirectory(this.baseLocation + HttpContext.Connection.Id + trashPath);
DeletedFiles.Remove(trashFile);
responseString = "Restored";
}
@ -180,8 +179,8 @@ namespace DocumentExplorer.Controllers
public FileManagerResponse SearchFiles(string value, bool caseSensitive)
{
this.operation.RootFolder(this.baseLocation);
string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
this.operation.RootFolder(this.baseLocation + HttpContext.Connection.Id);
string jsonPath = this.basePath + "\\wwwroot\\VirtualConnections\\" + HttpContext.Connection.Id + "\\User\\trash.json";
string jsonData = System.IO.File.ReadAllText(jsonPath);
List<TrashContents> DeletedFiles = JsonConvert.DeserializeObject<List<TrashContents>>(jsonData) ?? new List<TrashContents>();
List<TrashContents> searchFiles = DeletedFiles.FindAll(x => new Regex(WildcardToRegex(value), (caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase)).IsMatch(x.Name));

Просмотреть файл

@ -617,13 +617,21 @@ namespace DocumentExplorer.Data
// Moves file(s) or folder(s).
public virtual FileManagerResponse Move(string path, string targetPath, string[] names, string[] renameFiles, FileManagerDirectoryContent targetData, params FileManagerDirectoryContent[] data)
{
{
FileManagerResponse moveResponse = new FileManagerResponse();
try
{
string validatePath;
validatePath = Path.Combine(contentRootPath + path);
if (Path.GetFullPath(validatePath) != GetFilePath(validatePath))
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
string result = String.Empty;
if (renameFiles == null)
{
renameFiles = new string[0];
}
string physicalPath = GetPath(path);
for (int i = 0; i < names.Length; i++)
{
@ -641,6 +649,7 @@ namespace DocumentExplorer.Data
accessMessage = PathPermission.Message;
throw new UnauthorizedAccessException("'" + this.getFileNameFromPath(this.rootName + targetPath) + "' is not accessible. You need permission to perform the writeContents action.");
}
List<string> existFiles = new List<string>();
List<string> missingFiles = new List<string>();
List<FileManagerDirectoryContent> movedFiles = new List<FileManagerDirectoryContent>();
@ -654,20 +663,38 @@ namespace DocumentExplorer.Data
path = tempPath + names[i].Substring(0, name + 1);
names[i] = names[i].Substring(name + 1);
}
else path = tempPath;
else
{
path = tempPath;
}
string itemPath = Path.Combine(contentRootPath + path, names[i]);
if (Path.GetFullPath(itemPath) != GetFilePath(itemPath) + names[i])
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
if (Directory.Exists(itemPath) || File.Exists(itemPath))
{
if ((File.GetAttributes(itemPath) & FileAttributes.Directory) == FileAttributes.Directory)
{
string directoryName = names[i];
string oldPath = Path.Combine(contentRootPath + path, directoryName);
if (Path.GetFullPath(oldPath) != GetFilePath(oldPath) + directoryName)
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
string newPath = Path.Combine(contentRootPath + targetPath, directoryName);
if (Path.GetFullPath(newPath) != GetFilePath(newPath) + directoryName)
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
bool exist = Directory.Exists(newPath);
if (exist)
{
int index = -1;
if (renameFiles.Length > 0) index = Array.FindIndex(renameFiles, row => row.Contains(directoryName));
if (renameFiles.Length > 0)
{
index = Array.FindIndex(renameFiles, row => row.Contains(directoryName));
}
if ((newPath == oldPath) || (index != -1))
{
newPath = DirectoryRename(newPath);
@ -683,7 +710,10 @@ namespace DocumentExplorer.Data
detail.PreviousName = names[i];
movedFiles.Add(detail);
}
else existFiles.Add(fullName);
else
{
existFiles.Add(fullName);
}
}
else
{
@ -694,7 +724,6 @@ namespace DocumentExplorer.Data
{
result = DeleteDirectory(oldPath);
if (result != String.Empty) { break; }
}
FileManagerDirectoryContent detail = GetFileDetails(newPath);
detail.PreviousName = names[i];
@ -705,7 +734,15 @@ namespace DocumentExplorer.Data
{
string fileName = names[i];
string oldPath = Path.Combine(contentRootPath + path, fileName);
if (Path.GetFullPath(oldPath) != GetFilePath(oldPath) + fileName)
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
string newPath = Path.Combine(contentRootPath + targetPath, fileName);
if (Path.GetFullPath(newPath) != GetFilePath(newPath) + fileName)
{
throw new UnauthorizedAccessException("Access denied for Directory-traversal");
}
bool fileExist = File.Exists(newPath);
try
{
@ -714,24 +751,35 @@ namespace DocumentExplorer.Data
{
int index = -1;
if (renameFiles.Length > 0)
{
index = Array.FindIndex(renameFiles, row => row.Contains(fileName));
}
if ((newPath == oldPath) || (index != -1))
{
newPath = FileRename(newPath, fileName);
File.Copy(oldPath, newPath);
bool isExist = File.Exists(oldPath);
if (isExist) File.Delete(oldPath);
if (isExist)
{
File.Delete(oldPath);
}
FileManagerDirectoryContent detail = GetFileDetails(newPath);
detail.PreviousName = names[i];
movedFiles.Add(detail);
}
else existFiles.Add(fullName);
else
{
existFiles.Add(fullName);
}
}
else
{
File.Copy(oldPath, newPath);
bool isExist = File.Exists(oldPath);
if (isExist) File.Delete(oldPath);
if (isExist)
{
File.Delete(oldPath);
}
FileManagerDirectoryContent detail = GetFileDetails(newPath);
detail.PreviousName = names[i];
movedFiles.Add(detail);
@ -742,13 +790,20 @@ namespace DocumentExplorer.Data
{
if (e.GetType().Name == "UnauthorizedAccessException")
{
result = newPath; break;
result = newPath;
break;
}
else
{
throw e;
}
else throw e;
}
}
}
else missingFiles.Add(names[i]);
else
{
missingFiles.Add(names[i]);
}
}
moveResponse.Files = movedFiles;
if (result != String.Empty)
@ -768,11 +823,17 @@ namespace DocumentExplorer.Data
er.Message = "File Already Exists";
moveResponse.Error = er;
}
if (missingFiles.Count == 0) return moveResponse;
if (missingFiles.Count == 0)
{
return moveResponse;
}
else
{
string namelist = missingFiles[0];
for (int k = 1; k < missingFiles.Count; k++) { namelist = namelist + ", " + missingFiles[k]; }
for (int k = 1; k < missingFiles.Count; k++)
{
namelist = namelist + ", " + missingFiles[k];
}
throw new FileNotFoundException(namelist + " not found in given location.");
}
}
@ -783,7 +844,7 @@ namespace DocumentExplorer.Data
Message = e.Message.ToString(),
Code = e.Message.ToString().Contains("is not accessible. You need permission") ? "401" : "417",
FileExists = moveResponse.Error?.FileExists
};
};
if ((er.Code == "401") && !string.IsNullOrEmpty(accessMessage)) { er.Message = accessMessage; }
moveResponse.Error = er;
return moveResponse;
@ -908,7 +969,7 @@ namespace DocumentExplorer.Data
}
// Uploads the file(s) to the files system.
public virtual FileManagerResponse Upload(string path, IList<IFormFile> uploadFiles, string action, params FileManagerDirectoryContent[] data)
public virtual FileManagerResponse Upload(string path, IList<IFormFile> uploadFiles, string action,string basePath, params FileManagerDirectoryContent[] data)
{
FileManagerResponse uploadResponse = new FileManagerResponse();
try
@ -925,7 +986,7 @@ namespace DocumentExplorer.Data
if (uploadFiles != null)
{
string name = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
string fullName = Path.Combine((this.contentRootPath + path), name);
string fullName = Path.Combine((basePath + "\\Files\\"), name);
if (action == "save")
{
if (!System.IO.File.Exists(fullName))

Просмотреть файл

@ -0,0 +1,66 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>DocumentExplorer</RootNamespace>
<Configurations>Debug;Release;Publish</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|AnyCPU'">
<DefineConstants>TRACE;Publish</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Components\Layout\**" />
<Compile Remove="Components\Pages\**" />
<Compile Remove="DocumentExplorer\**" />
<Content Remove="Components\Layout\**" />
<Content Remove="Components\Pages\**" />
<Content Remove="DocumentExplorer\**" />
<EmbeddedResource Remove="Components\Layout\**" />
<EmbeddedResource Remove="Components\Pages\**" />
<EmbeddedResource Remove="DocumentExplorer\**" />
<None Remove="Components\Layout\**" />
<None Remove="Components\Pages\**" />
<None Remove="DocumentExplorer\**" />
</ItemGroup>
<ItemGroup>
<Content Remove="Components\Routes.razor" />
<Content Remove="Components\_Imports.razor" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Syncfusion.Blazor.ImageEditor" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.Navigations" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.Inputs" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.FileManager" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.Buttons" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.Popups" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.PdfViewerServer.Windows" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.Themes" Version="26.1.35" />
<PackageReference Include="Syncfusion.Blazor.WordProcessor" Version="26.1.35" />
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="26.1.35" />
<PackageReference Include="Syncfusion.Licensing" Version="26.1.35" />
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="26.1.35" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<Content Update="web.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="SyncfusionLicense.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

Просмотреть файл

@ -34,7 +34,7 @@ namespace DocumentExplorer.Models.FileManager
#if EJ2_DNX
FileManagerResponse Upload(string path, IList<System.Web.HttpPostedFileBase> uploadFiles, string action, params FileManagerDirectoryContent[] data);
#else
FileManagerResponse Upload(string path, IList<IFormFile> uploadFiles, string action, params FileManagerDirectoryContent[] data);
FileManagerResponse Upload(string path, IList<IFormFile> uploadFiles, string action, string basePath, params FileManagerDirectoryContent[] data);
#endif
FileStreamResult GetImage(string path, string id, bool allowCompress, ImageSize size, params FileManagerDirectoryContent[] data);

18
server-app/NuGet.config Normal file
Просмотреть файл

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<config>
<add key="dependencyVersion" value="Highest" />
</config>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>

Просмотреть файл

Просмотреть файл

@ -0,0 +1,34 @@
@page "/image-viewer"
@using Syncfusion.Blazor
@using Syncfusion.Blazor.ImageEditor
<div class="toolbar">
<TopToolbar @ref="_topToolbar" BackClick="BackClickHandler"></TopToolbar>
</div>
<div class="control-section">
<SfImageEditor @ref="_imageEditor" Height="500px">
<ImageEditorEvents Created="created"></ImageEditorEvents>
</SfImageEditor>
</div>
@code {
SfImageEditor _imageEditor;
TopToolbar _topToolbar;
Index _indexDetails;
private void created()
{
var data = QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query);
if (data.TryGetValue("fileName", out var fileName))
{
_topToolbar.RootName = fileName.ToString();
}
if (data.TryGetValue("imageUrl", out var imageUrl))
{
string imageUrlString = imageUrl.ToString(); // Convert to string explicitly
_imageEditor.OpenAsync(imageUrlString);
}
}
private void BackClickHandler()
{
NavigationManager.NavigateTo(NavigationManager.BaseUri);
}
}

Просмотреть файл

@ -0,0 +1,622 @@
@page "/"
@using Syncfusion.Blazor.FileManager
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Popups
@using System.Text
<div class="loading_indicator @OverlayStyle">
<div class="e-de-spinner-pane">
</div>
<div class="e-de-spinner-inner">
<svg class="e-de-spin-bootstrap4" viewBox="0 0 36 36">
<path class="e-de-path-circle" d="M18,1.8A16.2,16.2 0 1 1 1.8,18"></path>
</svg>
</div>
</div>
<div class="control-section">
<div id="fullLayout" class="e-full-layout">
@*Header Section*@
<div id="LayoutHeader" class="e-Header">
<SfToolbar Height="54px" CssClass="e-HeaderToolbar">
<ToolbarItems>
<ToolbarItem TooltipText="Menu" Align="@ItemAlign.Left" CssClass="e-hamburger" OnClick="HamburgerClick">
<Template>
<span class="e-icons e-hamburger-icon"></span>
</Template>
</ToolbarItem>
<ToolbarItem TooltipText="Menu" Align="@ItemAlign.Left" CssClass="e-logo">
<Template>
<span class="e-folder-logo e-header-icon"></span>
</Template>
</ToolbarItem>
<ToolbarItem Align="@ItemAlign.Left">
<Template>
<div class="e-header-title">Document Explorer</div>
</Template>
</ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" Id="User" OnClick="ToolbarClick" CssClass="@(_popupVisibility == "e-hide-popup" ? "e-user-icon" : "e-user-icon select-highlight")">
<Template>
<span id="User-Img" class='e-user-img e-avatar e-avatar-circle'> </span>
</Template>
</ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" Id="GitHub" TooltipText="https://github.com/syncfusion/blazor-showcase-document-explorer" OnClick="ToolbarClick">
<Template>
<span class='sf-icon-Github'></span>
</Template>
</ToolbarItem>
</ToolbarItems>
</SfToolbar>
</div>
@*Content section*@
<div id="LayoutContent" class="e-mainLayout-content">
@*sidebar content*@
<SfSidebar @ref="_sidebar" Animate="false" @bind-IsOpen="SidebarToggle" Target=".e-mainLayout-content" MediaQuery="(min-width: 600px)" Width="260px" Type=SidebarType.Over EnableGestures="false"
OnClose="SidebarClose" OnOpen="SidebarOpen">
<ChildContent>
@*user icon for resolution < 600px*@
<div class="e-card e-side-card">
<div class="e-card-header">
<div id="User-Img" class="e-user-img e-avatar e-avatar-circle"> </div>
<div class="e-card-header-caption e-user-name">
<div class="e-card-header-title"> Angellina</div>
<div class="e-card-sub-title"><a href="">Change Picture</a></div>
</div>
</div>
</div>
@*new folder button for resolution > 600px*@
<div id="LeftButtonContainer" class="e-left-button-contain">
<SfButton CssClass="e-new-button" IconCss="e-icons e-add-new" Content="New Folder" IsPrimary="true" OnClick="NewClick"></SfButton>
</div>
@*sidebar options*@
<div id="LeftTreeContainer" class="e-left-tree-contain">
<SfTreeView @ref="_treeObj" CssClass="e-left-tree" TValue="OptionsDataModel" SelectedNodes="@_selectedTreeItem">
<TreeViewFieldsSettings Id="Id" TValue="OptionsDataModel" DataSource=@_optionsData IconCss="Icon" Selected="Select" Text="Name"></TreeViewFieldsSettings>
<TreeViewEvents TValue="OptionsDataModel" NodeSelected="TreeSelect"></TreeViewEvents>
</SfTreeView>
@*Storage details*@
<div class="e-storage-container" title="Storage status">
<div class="e-storage-header">
<div class="e-storage-icon sf-icon-Storage"></div>
<div class="e-storage-title">Storage </div>
</div>
<div class="e-storage-content">
<div class="e-storage-progress progress">
<div class="progress-bar" style="width:@_storageRatio">
</div>
</div>
<div class="e-storage-value">@_storageValue</div>
</div>
</div>
</div>
@*user options for resolution < 600px*@
<div class="e-card e-side-card e-side-bottom-card">
<div class="e-card-content"><a class="e-empty-link" href="">My Profile</a></div>
<div class="e-card-content"><a class="e-empty-link" href="">Settings</a></div>
<div class="e-card-content"><a class="e-empty-link" href="">Sign Out</a></div>
</div>
</ChildContent>
</SfSidebar>
<div id="RightLayout" class="e-right-layout">
@*file manager*@
<SfFileManager @ref="_fileManager" TValue="FileManagerDirectoryContent" Height="100%" ShowThumbnail="@(Field!="Trash")" PopupTarget="BODY">
<FileManagerAjaxSettings Url=@(NavigationManager.BaseUri + "api/"+ (Field=="Shared"?"SharedFiles":(Field=="Trash"?"Trash":"FileManager"))+"/FileOperations")
GetImageUrl=@(NavigationManager.BaseUri + "api/"+(Field=="Shared"?"SharedFiles":(Field=="Trash"?"Trash":"FileManager"))+"/GetImage")
DownloadUrl=@(NavigationManager.BaseUri + "api/"+(Field=="Shared"?"SharedFiles":(Field=="Trash"?"Trash":"FileManager"))+"/Download")
UploadUrl=@(NavigationManager.BaseUri + "api/"+(Field=="Shared"?"SharedFiles":(Field=="Trash"?"Trash":"FileManager"))+"/Upload")>
</FileManagerAjaxSettings>
<FileManagerToolbarSettings Items="@_toolItems"></FileManagerToolbarSettings>
<FileManagerContextMenuSettings File="@_fileMenu" Folder="@_folderMenu" Layout="@_layoutMenu"></FileManagerContextMenuSettings>
<FileManagerNavigationPaneSettings Visible="false"></FileManagerNavigationPaneSettings>
<FileManagerEvents OnSend="BeforeSend" TValue="FileManagerDirectoryContent" ToolbarItemClicked="UploadClick" ToolbarCreated="ToolbarCreate" MenuOpened="MenuOpen" OnMenuClick="MenuClick"
OnFileOpen="FileOpen" OnFileLoad="FileLoad" BeforePopupOpen="PopupBefore" BeforeImageLoad="ImageLoadBefore" PopupClosed="PopupClosed"></FileManagerEvents>
</SfFileManager>
<div id="file-overlay" class="e-file-overlay @_fileOverlayDisplay"></div>
</div>
</div>
</div>
@*popup containing user options like profile, sign out/in*@
<div id="user-Popup" class="e-notch e-icons e-user-Popup @_popupVisibility">
<div tabindex="0" class="e-card">
<div class="e-card-header">
<div id="User-Img" class="e-user-img e-avatar e-avatar-circle"> </div>
<div class="e-card-header-caption e-user-name">
<div class="e-card-header-title"> Angellina</div>
<div class="e-card-sub-title"><a href="">Change Picture</a></div>
</div>
</div>
<div class="e-card-content">
<div class="e-storage-progress progress">
<div class="progress-bar" style="width:@_storageRatio">
</div>
</div>
<div class="e-storage-value">@_storageValue</div>
</div>
<div class="e-card-content"><a class="e-empty-link" href="">My Profile</a></div>
<div class="e-card-content"><a class="e-empty-link" href="">Settings</a></div>
<div class="e-card-content"><a class="e-empty-link" href="">Sign Out</a></div>
</div>
</div>
<SfDialog Width="335px" @ref="_dialog" Target="#target" IsModal="true" @bind-Visible="_isUnSupported">
<DialogTemplates>
<Header>@_fileName</Header>
<Content>
<p>This type of file cannot be previewed.</p>
</Content>
</DialogTemplates>
<DialogEvents Closed="@DlgClose"></DialogEvents>
<DialogButtons>
<DialogButton Content="OK" IsPrimary="true" OnClick="@DlgButtonClick" />
</DialogButtons>
<DialogAnimationSettings Effect="@DialogEffect.None"></DialogAnimationSettings>
</SfDialog>
</div>
@code {
public string _currentImageUrl { get; set; }
public string _imageFileName { get; set; }
private SfFileManager<FileManagerDirectoryContent> _fileManager;
private SfTreeView<OptionsDataModel> _treeObj;
private SfSidebar _sidebar;
private SfDialog _dialog;
public bool SidebarToggle = false;
private bool ShowThumbnail = true;
private bool _isThumbNailChange = false;
private string[] _selectedTreeItem = new string[] { "1" };
private int _dialogCount = 0;
private string _popupVisibility = "e-hide-popup";
private string _fileOverlayDisplay = "e-file-hide-overlay";
private string _storageRatio = "70%";
private string _storageValue = "70% storage used";
private string SelectedFilename { get; set; }
private string SelectedPath { get; set; }
private string FileManagerId { get; set; }
private string MenuTargetData { get; set; }
private string MenuTargetId { get; set; }
private bool _isUnSupported = false;
private string OverlayStyle { get; set; } = "overlayShow";
private string _fileName = "";
private List<OptionsDataModel> _optionsData = new List<OptionsDataModel>() {
new OptionsDataModel(){Name= "All Files", Id= "1", Select= true, Icon= "sf-icon-Allfiles"},
new OptionsDataModel(){Name= "Recent Files", Id= "2", Select= false, Icon= "sf-icon-RecentFiles" },
new OptionsDataModel(){Name= "Shared With Me", Select= false, Id= "3", Icon= "e-icons e-shared" },
new OptionsDataModel(){Name= "Trash", Select= false, Id= "4", Icon= "sf-icon-Delete" },
new OptionsDataModel(){Name= "About", Select= false, Id= "5", Icon= "sf-icon-About" }
};
private class OptionsDataModel
{
public string Id { get; set; }
public string Name { get; set; }
public bool Select { get; set; }
public string Icon { get; set; }
}
private string Field { get; set; } = null;
private string Path { get; set; }
//private string[] SelectedItems { get; set; }
private bool _treeSelectFlag = false;
private string _treeNode = "1";
private string[] _toolItems = new string[] {
#if !Publish
"Upload",
#endif
"Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details" };
private string[] _fileMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
private string[] _folderMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
private string[] _layoutMenu = new string[] { "SortBy", "View", "Refresh", "|", "NewFolder",
#if !Publish
"Upload",
#endif
"|", "Details", "SelectAll" };
private bool isImageOpen = false;
protected override void OnInitialized()
{
_fileOverlayDisplay = "e-file-show-overlay";
Path = "/";
if (QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query).TryGetValue("path", out var pathparam))
{
string tempPath = pathparam.First();
if (tempPath.StartsWith("Files"))
{
tempPath = tempPath.Replace("Files", "");
}
else
{
if (tempPath.StartsWith("SharedFiles"))
{
tempPath = tempPath.Replace("SharedFiles", "");
}
}
SelectedPath = tempPath;
Path = SelectedPath;
}
if (QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query).TryGetValue("preview", out var param))
{
SelectedFilename = param.First();
}
}
protected override void OnAfterRender(bool firstRender)
{
OverlayStyle = "overlayHide";
if (!firstRender)
{
if (_fileManager.EnableRtl && SelectedPath != null & SelectedFilename != null)
{
SelectedPath = SelectedFilename = null;
_fileOverlayDisplay = "e-file-hide-overlay";
}
}
}
private void DlgButtonClick()
{
_isUnSupported = false;
}
private void DlgClose(Object args)
{
_isUnSupported = false;
}
public async void Refresh()
{
await _fileManager.RefreshFilesAsync();
}
private async void TreeSelect(NodeSelectEventArgs args)
{
_selectedTreeItem[0] = _treeNode = args.NodeData.Id;
//To avoid file refreshing if the selection change involves shared Trash as showThumbNail change triggers which refreshFiles.
_isThumbNailChange = (_treeNode == "5") || (args.NodeData.Id == "5");
ShowThumbnail = args.NodeData.Id != "5";
//To avoid manual refreshing if the selection change involves shared files/Trash as ajax setting change triggered which refresh.
bool flag = false;
if (_treeSelectFlag) { _treeSelectFlag = false; return; }
switch (_treeNode)
{
//Recent Files
case "2":
_toolItems = new string[] { "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details" };
_fileMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
_folderMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
_layoutMenu = new string[] { "SortBy", "View", "Refresh", "|", "NewFolder",
#if !Publish
"Upload",
#endif
"|", "Details", "SelectAll" };
Field = "Recent";
break;
//Shared With Me
case "3":
_toolItems = new string[] { "Download", "SortBy", "Refresh", "Selection", "View", "Details" };
_fileMenu = new string[] { "Open", "|", "Download", "|", "Details" };
_folderMenu = new string[] { "Open", "|", "Download", "|", "Details" };
_layoutMenu = new string[] { "SortBy", "|", "View", "|", "Refresh", "|", "Details", "|", "SelectAll" };
Field = "Shared";
break;
//Trash
case "4":
_toolItems = new string[] { "Delete", "SortBy", "Refresh", "Selection", "View", "Details" };
_fileMenu = new string[] { "Delete", "|", "Details", "|", "Restore", "EmptyTrash", "|", "SelectAll" };
_folderMenu = new string[] { "Download", "|", "Details", "|", "Restore", "EmptyTrash", "|", "SelectAll" };
_layoutMenu = new string[] { "SortBy", "View", "Refresh", "|", "Details", "SelectAll", "|", "Restore", "EmptyTrash" };
Field = "Trash";
break;
//About page
case "5":
NavigationManager.NavigateTo(NavigationManager.BaseUri + "about");
break;
//All Files
default:
_toolItems = new string[] {
#if !Publish
"Upload",
#endif
"Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details" };
_fileMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
_folderMenu = new string[] { "Open", "|", "Delete", "Download", "Rename", "|", "Details" };
_layoutMenu = new string[] { "SortBy", "View", "Refresh", "|", "NewFolder",
#if !Publish
"Upload",
#endif
"|", "Details", "SelectAll" };
Field = "AllFiles";
break;
}
if (!flag)
{
//Reset the path to make the filter work from route path
Path = "/";
_fileManager.Path = "/";
await _fileManager.RefreshFilesAsync();
}
}
private void BeforeSend(BeforeSendEventArgs args)
{
if (_isThumbNailChange)
{
_isThumbNailChange = false;
}
if (args.Action != "Upload")
{
if (args.HttpClientInstance.DefaultRequestHeaders.Contains("RootType"))
{
args.HttpClientInstance.DefaultRequestHeaders.Remove("RootType");
}
//Pass the user token through FileManager HTTP client instance.
args.HttpClientInstance.DefaultRequestHeaders.Add("RootType", Field);
}
}
private async Task UploadClick(ToolbarClickEventArgs<FileManagerDirectoryContent> args)
{
if (args.Item.Text == "Upload" && (!args.Cancel))
{
await JSRuntime.InvokeVoidAsync("alert", "This is an security purpose alert message.");
}
}
private void HamburgerClick()
{
SidebarToggle = !SidebarToggle;
}
private void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
switch (args.Item.Id)
{
case "User":
_popupVisibility = _popupVisibility == "e-hide-popup" ? "e-show-popup" : "e-hide-popup";
break;
case "GitHub":
NavigationManager.NavigateTo("https://github.com/syncfusion/blazor-showcase-document-explorer");
break;
}
}
private async void NewClick()
{
await _fileManager.CreateFolderAsync();
}
private void SidebarOpen()
{
_popupVisibility = "e-hide-popup";
_fileOverlayDisplay = "e-file-show-overlay";
}
private void SidebarClose()
{
_popupVisibility = "e-hide-popup";
_fileOverlayDisplay = "e-file-hide-overlay";
}
private void PopupBefore(BeforePopupOpenCloseEventArgs args)
{
if (args.PopupName == "Image Preview")
{
args.Cancel = true;
}
else
{
_dialogCount++;
_popupVisibility = "e-hide-popup";
}
}
private void ImageLoadBefore(BeforeImageLoadEventArgs<FileManagerDirectoryContent> args)
{
if (isImageOpen)
{
string uri = NavigationManager.BaseUri;
_currentImageUrl = args.ImageUrl;
_imageFileName = args.FileDetails.Name;
Dictionary<string, string> imageUrl = new Dictionary<string, string> { { "imageUrl", _currentImageUrl }, { "fileName", _imageFileName } };
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(uri + "image-viewer/", imageUrl));
isImageOpen = false;
}
}
private async void PopupOpened(PopupOpenCloseEventArgs args)
{
// await JSRuntime.InvokeVoidAsync("setDialogDrag", args.Element.ID);
}
private void PopupClosed()
{
_dialogCount--;
}
private async void MenuOpen(MenuOpenEventArgs<FileManagerDirectoryContent> args)
{
if ((Field != "Shared") && (Field != "Trash"))
{
MenuTargetData = JsonConvert.SerializeObject(args.FileDetails);
}
else if (Field == "Trash" && !args.IsSubMenu)
{
foreach (Syncfusion.Blazor.FileManager.MenuItemModel menu in args.Items)
{
switch (menu.Text)
{
case "Restore":
menu.IconCss = "e-icons e-restore";
break;
case "EmptyTrash":
menu.IconCss = "sf-icon-Delete";
menu.Text = "Delete Permanently";
break;
}
}
}
}
private async void MenuClick(MenuClickEventArgs<FileManagerDirectoryContent> args)
{
if (args.Item.Id == _fileManager.ID + "_cm_restore")
{
List<Syncfusion.Blazor.FileManager.FileManagerDirectoryContent> files = _fileManager.GetSelectedFiles();
if (files.Count != 0) { Restore(args.FileDetails); }
}
if (args.Item.Id == _fileManager.ID + "_cm_restoreall")
{
EmptyTrash();
}
}
private void ToolbarCreate(ToolbarCreateEventArgs args)
{
List<Syncfusion.Blazor.FileManager.ToolBarItemModel> items = args.Items;
foreach (Syncfusion.Blazor.FileManager.ToolBarItemModel item in items)
{
if (item.Id == _fileManager.ID + "_tb_newfolder") { item.CssClass = "e-FM-newfolder"; }
#if !Publish
if (item.Id == _fileManager.ID + "_tb_upload") { item.CssClass = "e-FM-upload"; }
#endif
}
}
private async void FileOpen(FileOpenEventArgs<FileManagerDirectoryContent> args)
{
if (args.FileDetails.Type == ".jpg" || args.FileDetails.Type == ".png" || args.FileDetails.Type == ".dib" || args.FileDetails.Type == ".jpeg"
|| args.FileDetails.Type == ".jpe" || args.FileDetails.Type == ".jfif" || args.FileDetails.Type == ".gif" || args.FileDetails.Type == ".tif"
|| args.FileDetails.Type == ".tiff" || args.FileDetails.Type == ".ico")
isImageOpen = true;
if (Field == "Trash") { args.Cancel = true; return; }
string dataString = JsonConvert.SerializeObject(args.FileDetails);
Dictionary<string, dynamic> fileDetails = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(dataString);
if (fileDetails["IsFile"])
{
string filePath = (Field == "Shared" ? "SharedFiles" : "Files") + (fileDetails["FilterPath"]);
Dictionary<string, string> query = new Dictionary<string, string> { { "preview", fileDetails["Name"] }, { "path", filePath } };
Dictionary<string, string> imageUrl = new Dictionary<string, string> { { "imageUrl", _currentImageUrl } };
string uri = NavigationManager.BaseUri;
switch (fileDetails["Type"])
{
case Constants.Zip:
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(uri + "zip-viewer/", query));
break;
case Constants.Pptx:
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(uri + "presentation-viewer/", query));
break;
case Constants.Pdf:
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(uri + "pdf-viewer/", query));
break;
case Constants.Docx:
case Constants.Doc:
case Constants.Rtf:
case Constants.Txt:
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(uri + "word-viewer/", query));
break;
case Constants.Dib:
case Constants.Jpg:
case Constants.Jpeg:
case Constants.Jpe:
case Constants.Jfif:
case Constants.Gif:
case Constants.Tif:
case Constants.Tiff:
case Constants.Png:
case Constants.Ico:
break;
default:
_fileName = fileDetails["Name"];
_isUnSupported = true;
break;
}
}
else
{
if ((_treeNode != "1") && (_treeNode != "3"))
{
_treeSelectFlag = true;
_selectedTreeItem = new string[] { "1" };
args.Cancel = true;
}
string newPath = (fileDetails["FilterPath"] + fileDetails["Name"] + "/");
Path = newPath.Replace('\\', '/');
await _fileManager.RefreshFilesAsync();
}
}
private async void FileLoad(FileLoadEventArgs<FileManagerDirectoryContent> args)
{
string dataString = JsonConvert.SerializeObject(args.FileDetails);
Dictionary<string, dynamic> fileDetails = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(dataString);
//Check the module name and type of the file to set Preview
if (args.Module == "LargeIconsView" && (Field != "Trash") && (fileDetails["type"] == Constants.Pptx || fileDetails["type"] == Constants.Docx
|| fileDetails["type"] == Constants.Doc || fileDetails["type"] == Constants.Rtf || fileDetails["type"] == Constants.Txt || fileDetails["type"] == Constants.Pdf))
{
string url = GetImageUrl(fileDetails);
@* DOM ele = args.Element; *@
@* string val = Convert.ToString((await ele.GetAttribute<string>("data-uid")));
await ele.AddClass(new string[] { "e-file-preview-image" }); *@
@* await JSRuntime.InvokeVoidAsync("setSpinnerPreview", val); *@
string anm = fileDetails["name"];
string previewImage = await JSRuntime.InvokeAsync<string>("getLocalCacheImage", anm);
if (previewImage != null)
{
@* await JSRuntime.InvokeVoidAsync("setPreview", val, previewImage); *@
}
else
{
HttpRequestMessage docrequest = new HttpRequestMessage(HttpMethod.Post, NavigationManager.BaseUri + "api/Preview/GetPreview");
docrequest.Content = new StringContent(JsonConvert.SerializeObject(new { Path = (fileDetails["filterPath"] + fileDetails["name"]) }), Encoding.UTF8, "application/json");
HttpResponseMessage docresponse = await Http.SendAsync(docrequest);
if (docresponse.IsSuccessStatusCode)
{
string output = await docresponse.Content.ReadAsStringAsync();
if (output != "Error")
{
string name = fileDetails["name"];
await JSRuntime.InvokeVoidAsync("setLocalCacheImage", name, output);
@* await JSRuntime.InvokeVoidAsync("setPreview", val, output); *@
}
else
{
//revertToIconPreview
var iconCss = "";
switch (fileDetails["type"])
{
case Constants.Docx:
iconCss = "e-fe-docx";
break;
case Constants.Doc:
iconCss = "e-fe-doc";
break;
case Constants.Rtf:
iconCss = "e-fe-rtf";
break;
case Constants.Pdf:
iconCss = "e-fe-pdf";
break;
case Constants.Pptx:
iconCss = "e-fe-pptx";
break;
}
@* await JSRuntime.InvokeVoidAsync("revertToIconPreview", val, iconCss); *@
}
}
}
}
}
private async void Restore(object files)
{
string url = NavigationManager.BaseUri + "api/Trash/Restore";
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Content = new StringContent(JsonConvert.SerializeObject(files), Encoding.UTF8, "application/json");
HttpResponseMessage response = await Http.SendAsync(request);
if (response.IsSuccessStatusCode)
{
await _fileManager.ClearSelectionAsync();
await _fileManager.RefreshFilesAsync();
}
}
private async void EmptyTrash()
{
string url = NavigationManager.BaseUri + "api/Trash/EmptyTrash";
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
HttpResponseMessage response = await Http.SendAsync(request);
if (response.IsSuccessStatusCode)
{
await _fileManager.ClearSelectionAsync();
await _fileManager.RefreshFilesAsync();
}
}
private string GetImageUrl(Dictionary<string, dynamic> data)
{
//Specify your controller action name
string baseUrl = "/api/FileManager/GetPreviewImage";
string imgUrl = baseUrl + "?path=" + data["filterPath"] + data["name"];
return imgUrl;
}
}

Просмотреть файл

@ -17,13 +17,11 @@
<div class="toolbar">
<TopToolbar @ref="_topToolbar" BackClick="BackClickHandler"></TopToolbar>
</div>
<div class="file-viewer" @onmousemove="@ToogleBottomToolBarVisibility">
<SfPdfViewerServer @ref="_viewer" ID="PdfView" EnableToolbar="false" EnableBookmarkPanel="false" DocumentPath="@DocumentPath" ZoomValue="@Zoom" Height="100%">
<div class="file-viewer">
<SfPdfViewerServer @ref="_viewer" ID="PdfView"DocumentPath="@DocumentPath" Height="500px" Width="100%">
<PdfViewerEvents DocumentLoaded="@OnDocumentLoaded" PageChanged="@OnPageChanged">
</PdfViewerEvents>
</SfPdfViewerServer>
<BottomToolbar @ref="_bottomToolbar" ShowHidePane="ShowHideThumbnail" ToolBarAction="FileToolBar" GotoPage="Goto">
</BottomToolbar>
</div>
</div>
@ -39,10 +37,8 @@
private string ThumbnailStyle { get; set; } = "thumbnailShow";
private string DeMarginStyle { get; set; } = "e-word-right-layout";
private int Zoom { get; set; }
private bool _isThumbnailVisible = true;
private SfPdfViewerServer _viewer;
private TopToolbar _topToolbar;
private BottomToolbar _bottomToolbar;
protected override void OnInitialized()
{
@ -81,18 +77,16 @@
protected async void OnDocumentLoaded(LoadEventArgs args)
{
await _viewer.OpenThumbnailPane();
_bottomToolbar.TotalPages = await _viewer.GetPageCount();
DocumentName = "";
OverlayStyle = "overlayHide";
StateHasChanged();
}
private void BackClickHandler()
private async void BackClickHandler()
{
if (_viewer != null)
{
_viewer.Unload();
await _viewer.UnloadAsync();
}
if (SubPath != null)
{
@ -107,80 +101,12 @@
}
}
private async void ToogleBottomToolBarVisibility()
{
await JSRuntime.InvokeVoidAsync("toggleBottomToolbarVisibility", "PdfView", _isThumbnailVisible);
}
private async void ShowHideThumbnail()
{
await _viewer.OpenThumbnailPane();
_isThumbnailVisible = !_isThumbnailVisible;
ToogleBottomToolBarVisibility();
}
private async void Goto(int args)
{
await _viewer.GoToPage(args);
await _viewer.GoToPageAsync(args);
}
private async void FileToolBar(string action)
{
switch (action)
{
case "PreviousPage":
await _viewer.GoToPreviousPage();
break;
case "NextPage":
await _viewer.GoToNextPage();
break;
case "ZoomIn":
await _viewer.ZoomIn();
Zoom = await _viewer.GetZoomPercentage();
if (_viewer.ZoomValue >= 400)
{
_bottomToolbar.ZoomInDisable = true;
}
_bottomToolbar.ZoomOutDisable = false;
StateHasChanged();
break;
case "ZoomOut":
await _viewer.ZoomOut();
Zoom = await _viewer.GetZoomPercentage();
if (_viewer.ZoomValue <= 10)
{
_bottomToolbar.ZoomOutDisable = true;
}
_bottomToolbar.ZoomInDisable = false;
StateHasChanged();
break;
case "FullScreen":
await JSRuntime.InvokeVoidAsync("fullScreen", "PdfView_pageViewContainer");
break;
case "Print":
await _viewer.Print();
break;
}
}
private void OnPageChanged(PageChangeEventArgs args)
{
_bottomToolbar.CurrentPageNumber = (int)args.CurrentPageNumber;
if (args.CurrentPageNumber == _bottomToolbar.TotalPages)
{
_bottomToolbar.NextPageDisable = true;
_bottomToolbar.PreviousPageDisable = false;
}
if (args.CurrentPageNumber < _bottomToolbar.TotalPages && args.CurrentPageNumber != 1)
{
_bottomToolbar.NextPageDisable = false;
_bottomToolbar.PreviousPageDisable = false;
}
if (args.CurrentPageNumber == 1)
{
_bottomToolbar.PreviousPageDisable = true;
_bottomToolbar.NextPageDisable = false;
}
StateHasChanged();
}
}

Просмотреть файл

@ -17,12 +17,11 @@
<div class="toolbar">
<TopToolbar @ref="_topToolbar" BackClick="BackClickHandler"></TopToolbar>
</div>
<div class="file-viewer" @onmousemove="@ToogleBottomToolBarVisibility">
<SfPdfViewerServer @ref="_viewer" ID="PptView" EnableToolbar="false" Height="100%" EnableBookmarkPanel="false" ZoomMode="ZoomMode.FitToPage" ZoomValue="@Zoom">
<div class="file-viewer">
<SfPdfViewerServer @ref="_viewer" ID="PptView" EnableToolbar="true" Height="100%" EnableBookmarkPanel="false" ZoomMode="ZoomMode.FitToPage" ZoomValue="@Zoom">
<PdfViewerEvents DocumentLoaded="@OnDocumentLoaded" PageChanged="@OnPageChanged">
</PdfViewerEvents>
</SfPdfViewerServer>
<BottomToolbar @ref="_bottomToolbar" ShowHidePane="ShowHideThumbnail" ToolBarAction="FileToolBar" GotoPage="Goto"></BottomToolbar>
</div>
</div>
@ -34,10 +33,8 @@
private string SubPath { get; set; }
private string Path { get; set; }
private int Zoom { get; set; }
private bool _isThumbnailVisible = true;
private SfPdfViewerServer _viewer;
private TopToolbar _topToolbar;
private BottomToolbar _bottomToolbar;
protected override void OnInitialized()
{
@ -87,25 +84,23 @@
{
Newtonsoft.Json.Linq.JArray jArray = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(output);
string sfdt = ((JValue)jArray[0]).Value.ToString();
await _viewer.Load(sfdt, null);
await _viewer.LoadAsync(sfdt, null);
}
}
}
protected async void OnDocumentLoaded(LoadEventArgs args)
{
await _viewer.OpenThumbnailPane();
_bottomToolbar.TotalPages = await _viewer.GetPageCount();
DocumentName = "";
OverlayStyle = "overlayHide";
StateHasChanged();
}
private void BackClickHandler()
private async void BackClickHandler()
{
if (_viewer != null)
{
_viewer.Unload();
await _viewer.UnloadAsync();
}
if (SubPath != null)
{
@ -120,80 +115,13 @@
}
}
private async void ToogleBottomToolBarVisibility()
{
await JSRuntime.InvokeVoidAsync("toggleBottomToolbarVisibility", "PptView", _isThumbnailVisible);
}
private async void ShowHideThumbnail(bool args)
{
await _viewer.OpenThumbnailPane();
_isThumbnailVisible = !_isThumbnailVisible;
ToogleBottomToolBarVisibility();
}
private async void Goto(int args)
{
await _viewer.GoToPage(args);
}
private async void FileToolBar(string action)
{
switch (action)
{
case "PreviousPage":
await _viewer.GoToPreviousPage();
break;
case "NextPage":
await _viewer.GoToNextPage();
break;
case "ZoomIn":
await _viewer.ZoomIn();
Zoom = await _viewer.GetZoomPercentage();
if (_viewer.ZoomValue >= 400)
{
_bottomToolbar.ZoomInDisable = true;
}
_bottomToolbar.ZoomOutDisable = false;
StateHasChanged();
break;
case "ZoomOut":
await _viewer.ZoomOut();
Zoom = await _viewer.GetZoomPercentage();
if (_viewer.ZoomValue <= 10)
{
_bottomToolbar.ZoomOutDisable = true;
}
_bottomToolbar.ZoomInDisable = false;
StateHasChanged();
break;
case "FullScreen":
await JSRuntime.InvokeVoidAsync("fullScreen", "PptView_pageViewContainer");
break;
case "Print":
await _viewer.Print();
break;
}
await _viewer.GoToPageAsync(args);
}
private void OnPageChanged(PageChangeEventArgs args)
{
_bottomToolbar.CurrentPageNumber = (int)args.CurrentPageNumber;
if (args.CurrentPageNumber == _bottomToolbar.TotalPages)
{
_bottomToolbar.NextPageDisable = true;
_bottomToolbar.PreviousPageDisable = false;
}
if (args.CurrentPageNumber < _bottomToolbar.TotalPages && args.CurrentPageNumber != 1)
{
_bottomToolbar.NextPageDisable = false;
_bottomToolbar.PreviousPageDisable = false;
}
if (args.CurrentPageNumber == 1)
{
_bottomToolbar.PreviousPageDisable = true;
_bottomToolbar.NextPageDisable = false;
}
StateHasChanged();
}
}

Просмотреть файл

@ -24,8 +24,8 @@
@code{
public string RootName{get; set;}
@code {
public string RootName { get; set; }
private async void CallBackClick()
{
@ -34,4 +34,4 @@
[Parameter]
public EventCallback<string> BackClick { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,109 @@
@page "/word-viewer"
@using Syncfusion.Blazor.DocumentEditor
<div class="zip-container" id="zipContainer">
<div class="loading_indicator @OverlayStyle">
<div class="e-de-spinner-pane">
</div>
<div class="e-de-loading-text">@DocumentName</div>
<div class="e-de-spinner-inner">
<svg class="e-de-spin-bootstrap4" viewBox="0 0 36 36">
<path class="e-de-path-circle" d="M18,1.8A16.2,16.2 0 1 1 1.8,18"></path>
</svg>
</div>
</div>
<div class="toolbar">
<TopToolbar @ref="_topToolbar" BackClick="BackClickHandler"></TopToolbar>
</div>
<div class="file-viewer">
<div id="RightLayout">
<SfDocumentEditorContainer @ref="_documenteditorcontainer" ID="DocEdit" Height="540px" Width="100%">
<DocumentEditorContainerEvents Created="AfterCreated"></DocumentEditorContainerEvents>
</SfDocumentEditorContainer>
</div>
</div>
</div>
@code {
private string OverlayStyle { get; set; } = "overlayShow";
private string DocumentName { get; set; }
private string PreviewPath { get; set; }
private string FileName { get; set; }
private string SubPath { get; set; }
private string Path { get; set; }
private string ThumbnailStyle { get; set; } = "thumbnailShow";
private double ZoomFactor { get; set; } = 1;
private SfDocumentEditorContainer _documenteditorcontainer;
private TopToolbar _topToolbar;
protected override async void OnInitialized()
{
if (QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query).TryGetValue("path", out var pathparam))
{
Path = pathparam.First();
}
if (QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query).TryGetValue("preview", out var param))
{
FileName = param.First();
DocumentName = "File is loading...";
PreviewPath = Path + FileName;
}
if (QueryHelpers.ParseQuery(NavigationManager.ToAbsoluteUri(NavigationManager.Uri).Query).TryGetValue("subpath", out var subPathparam))
{
SubPath = subPathparam.First();
}
}
#region TopToolBar Interaction
private void BackClickHandler()
{
if (SubPath != null)
{
string file = IO.Path.GetFileName(PreviewPath);
Dictionary<string, string> query = new Dictionary<string, string> { { "preview", file }, { "path", PreviewPath.Replace((file), "") } };
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(NavigationManager.BaseUri + "zip-viewer/", query));
}
else
{
Dictionary<string, string> query = new Dictionary<string, string> { { "preview", FileName }, { "path", Path } };
NavigationManager.NavigateTo(QueryHelpers.AddQueryString(NavigationManager.BaseUri, query));
}
}
#endregion
#region DocumentEditor Event
private async void AfterCreated()
{
await _documenteditorcontainer.ResizeAsync();
HttpResponseMessage docresponse;
if (SubPath != null)
{
_topToolbar.RootName = IO.Path.GetFileName(SubPath);
string rooturl = NavigationManager.BaseUri + "api/ZipViewer/Root";
string docpath = "";
HttpResponseMessage rootresponse = await Http.GetAsync(rooturl);
string root = await rootresponse.Content.ReadAsStringAsync();
if (rootresponse.IsSuccessStatusCode)
{
docpath = (root + SubPath);
}
HttpRequestMessage docrequest = new HttpRequestMessage(HttpMethod.Post, NavigationManager.BaseUri + "api/DocumentEditor/OpenFromZip");
docrequest.Content = new StringContent(JsonConvert.SerializeObject(new { Path = docpath }), Encoding.UTF8, "application/json");
docresponse = await Http.SendAsync(docrequest);
}
else
{
_topToolbar.RootName = IO.Path.GetFileName(PreviewPath);
HttpRequestMessage docrequest = new HttpRequestMessage(HttpMethod.Post, NavigationManager.BaseUri + "api/DocumentEditor/Import");
docrequest.Content = new StringContent(JsonConvert.SerializeObject(new { Path = PreviewPath }), Encoding.UTF8, "application/json");
docresponse = await Http.SendAsync(docrequest);
}
string output = await docresponse.Content.ReadAsStringAsync();
await _documenteditorcontainer.DocumentEditor.OpenAsync(output);
await _documenteditorcontainer.ResizeAsync();
DocumentName = "";
OverlayStyle = "overlayHide";
StateHasChanged();
}
#endregion
}

Просмотреть файл

@ -11,22 +11,20 @@
<TopToolbar @ref="_topToolbar" BackClick="BackClickHandler"></TopToolbar>
</div>
<div class="file-viewer">
<SfFileManager @ref="_zipManager" CssClass="e-zip" View="ViewType.Details" Path="@ViewerPath" RootAliasName="@RootName" Height="100%" AllowMultiSelection="false">
<SfFileManager @ref="_zipManager" TValue="FileManagerDirectoryContent" CssClass="e-zip" View="ViewType.Details" Path="@ViewerPath" RootAliasName="@RootName" Height="100%" AllowMultiSelection="false">
<FileManagerAjaxSettings Url=@(NavigationManager.BaseUri + "api/ZipViewer/FileOperations")
GetImageUrl=@(NavigationManager.BaseUri + "api/ZipViewer/GetImage")>
</FileManagerAjaxSettings>
<FileManagerNavigationPaneSettings Visible="false"></FileManagerNavigationPaneSettings>
<FileManagerEvents Created="AfterCreated" OnSend="BeforeSend" OnFileOpen="FileOpen"></FileManagerEvents>
<FileManagerEvents Created="AfterCreated" TValue="FileManagerDirectoryContent" OnSend="BeforeSend" OnFileOpen="@FileOpen"></FileManagerEvents>
<FileManagerToolbarSettings Visible="false"></FileManagerToolbarSettings>
<FileManagerContextMenuSettings Visible="false"></FileManagerContextMenuSettings>
<FileManagerDetailsViewSettings ColumnResizing="false">
<FileManagerColumns>
@*Default column for file name*@
<FileManagerColumn Field="name" HeaderText="Name" Width="120" Template="<span class='e-fe-text'>${name}</span>" HeaderTextAlign=TextAlign.Left TextAlign=TextAlign.Left CustomAttributes="@(new { @class = "e-fe-grid-name" } )"></FileManagerColumn>
@*Default column for file size*@
@*<FileManagerDetailsViewSettings ColumnResizing=false>
<FileManagerColumns>
<FileManagerColumn Field="name" HeaderText="Name" Width="120" Template="<span class='e-fe-text'>${name}</span>" HeaderTextAlign=TextAlign.Left TextAlign=TextAlign.Left CustomAttributes="@(new { @class = "e-fe-grid-name" } )"></FileManagerColumn>
<FileManagerColumn Field="size" HeaderText="Size" Width="auto" Template="<span class='e-fe-size'>${size}</span>" HeaderTextAlign=TextAlign.Left TextAlign=TextAlign.Left></FileManagerColumn>
</FileManagerColumns>
</FileManagerDetailsViewSettings>
</FileManagerDetailsViewSettings>*@
</SfFileManager>
</div>
</div>
@ -40,7 +38,7 @@
private string SubPath { get; set; }
private string Path { get; set; }
public string OverlayStyle { get; set; } = "overlayHide";
private SfFileManager _zipManager;
private SfFileManager<FileManagerDirectoryContent> _zipManager;
private TopToolbar _topToolbar;
private string SpinnerTarget { get; set; } = "#zipContainer";
public bool isRootNameChange = true;
@ -76,7 +74,7 @@
HttpResponseMessage response = await Http.SendAsync(request);
if (response.IsSuccessStatusCode)
{
_zipManager.Refresh();
await _zipManager.RefreshFilesAsync();
}
}
private void BackClickHandler()
@ -106,10 +104,10 @@
string modifiedDataString = JsonConvert.SerializeObject(data);
AjaxSettings["data"] = modifiedDataString;
string returnString = JsonConvert.SerializeObject(AjaxSettings);
args.AjaxSettings = JsonConvert.DeserializeObject<object>(returnString);
//args.AjaxSettings = JsonConvert.DeserializeObject<object>(returnString);
}
}
private void FileOpen(FileOpenEventArgs args)
private void FileOpen(Syncfusion.Blazor.FileManager.FileOpenEventArgs<FileManagerDirectoryContent?> args)
{
string dataString = JsonConvert.SerializeObject(args.FileDetails);
Dictionary<string, dynamic> fileDetails = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(dataString);

Просмотреть файл

@ -12,19 +12,37 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Blazor Document Explorer Showcase example | Syncfusion Demos</title>
<meta name="description" content="The showcase for Blazor Document Explorer, allows users to manage the file system, perform common file operations, and opens Word, RTF & Power Point documents." />
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-WLQL39J');</script>
<!-- End Google Tag Manager -->
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap4.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
<script src="_content/Syncfusion.Blazor.PdfViewer/scripts/syncfusion-blazor-pdfviewer.min.js" type="text/javascript"></script>
<script src="_content/Syncfusion.Blazor.WordProcessor/scripts/syncfusion-blazor-documenteditor.min.js" type="text/javascript"></script>
<script src="~/Script/JsInteropHelper.js"></script>
<link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js"></script>
<script src="https://cdn.syncfusion.com/ej2/18.2.44/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
@*<link href="https://cdn.syncfusion.com/blazor/18.2.44/styles/bootstrap4.css" rel="stylesheet" />
<script src="~/Script/blazor-document-explorer.min.js"></script>
<script src="https://cdn.syncfusion.com/blazor/18.2.44/syncfusion-blazor.min.js"></script>*@
<script src="~/Script/blazor-document-explorer.min.js"></script>
<script src="https://cdn.syncfusion.com/blazor/18.2.44/syncfusion-blazor.min.js"></script>*@
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src=https://www.googletagmanager.com/ns.html?id=GTM-WLQL39J height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div hidden id="sync-analytics" data-queue="EJ2 - Showcase - Blazor - DocumentExplorer"></div>
@*<app>*@
<component type="typeof(App)" render-mode="ServerPrerendered" />
@*</app>*@

Просмотреть файл

Просмотреть файл

@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60851/",
"applicationUrl": "http://localhost:6085/",
"sslPort": 0
}
},
@ -21,7 +21,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:60851/"
"applicationUrl": "http://localhost:6085/"
}
}
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 49 KiB

После

Ширина:  |  Высота:  |  Размер: 49 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 50 KiB

После

Ширина:  |  Высота:  |  Размер: 50 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 48 KiB

После

Ширина:  |  Высота:  |  Размер: 48 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 45 KiB

После

Ширина:  |  Высота:  |  Размер: 45 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 65 KiB

После

Ширина:  |  Высота:  |  Размер: 65 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 61 KiB

После

Ширина:  |  Высота:  |  Размер: 61 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 99 KiB

После

Ширина:  |  Высота:  |  Размер: 99 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 98 KiB

После

Ширина:  |  Высота:  |  Размер: 98 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 97 KiB

После

Ширина:  |  Высота:  |  Размер: 97 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 98 KiB

После

Ширина:  |  Высота:  |  Размер: 98 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 92 KiB

После

Ширина:  |  Высота:  |  Размер: 92 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 100 KiB

После

Ширина:  |  Высота:  |  Размер: 100 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 95 KiB

После

Ширина:  |  Высота:  |  Размер: 95 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 94 KiB

После

Ширина:  |  Высота:  |  Размер: 94 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 73 KiB

После

Ширина:  |  Высота:  |  Размер: 73 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 96 KiB

После

Ширина:  |  Высота:  |  Размер: 96 KiB

Просмотреть файл

@ -35,65 +35,6 @@ window.revertToIconPreview = (val, iconClass) => {
image.parentElement.insertBefore(iconDiv, image);
image.remove();
};
window.setDialogDrag = (val) => {
var dialog = document.getElementById(val).ej2_instances[0];
dialog.allowDragging = false;
}
window.showStar = (val, isGrid) => {
var element = document.querySelector("[data-starid='" + val + "']");
if ((element === null) || (element.querySelector('.star') !== null)) { return; }
var rowDiv = document.createElement('span');
rowDiv.className += 'star sf-icon-Starred';
if (isGrid) {
element.querySelector('.e-fe-text').appendChild(rowDiv);
}
else {
if (!element.querySelector('.e-list-icon')) {
rowDiv.className += ' img';
element.querySelector('.e-text-content').prepend(rowDiv);
}
else {
element.querySelector('.e-list-icon').appendChild(rowDiv);
}
}
};
window.toggleStar = (val, isGrid) => {
var element = document.querySelector("[data-mapId='" + val + "']");
if ((element === null)) { return "Not Found"; }
var rowDiv = document.createElement('span');
rowDiv.className += 'star sf-icon-Starred';
if (isGrid) {
var containerEle = ej.base.closest(element, '.e-row');
if (containerEle.querySelector('.star') === null) {
containerEle.querySelector('.e-fe-text').appendChild(rowDiv);
ej.base.addClass([containerEle], ['e-file-star']);
return "Add";
} else {
ej.base.removeClass([containerEle], ['e-file-star']);
ej.base.remove(containerEle.querySelector('.star'));
return "Remove";
}
}
else {
var containerEle = ej.base.closest(element, '.e-large-icon');
if (containerEle.querySelector('.star') === null) {
if (!containerEle.querySelector('.e-list-icon')) {
rowDiv.className += ' img';
containerEle.querySelector('.e-text-content').prepend(rowDiv);
}
else {
containerEle.querySelector('.e-list-icon').appendChild(rowDiv);
}
ej.base.addClass([containerEle], ['e-file-star']);
return "Add";
} else {
ej.base.removeClass([containerEle], ['e-file-star']);
ej.base.remove(containerEle.querySelector('.star'));
return "Remove";
}
}
};
window.toggleZipFileManagerVisibility = (id, val) => {
var element = document.getElementById(id);
if (val) {

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 61 KiB

После

Ширина:  |  Высота:  |  Размер: 61 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 61 KiB

После

Ширина:  |  Высота:  |  Размер: 61 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 54 KiB

После

Ширина:  |  Высота:  |  Размер: 54 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 43 KiB

После

Ширина:  |  Высота:  |  Размер: 43 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 61 KiB

После

Ширина:  |  Высота:  |  Размер: 61 KiB

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 54 KiB

После

Ширина:  |  Высота:  |  Размер: 54 KiB

Просмотреть файл

@ -906,10 +906,6 @@ html, body, .zip-container {
display: none;
}
.e-pv-sidebar-toolbar {
display: none !important;
}
.thumbnailShow {
display: none;
}
@ -966,10 +962,6 @@ html, body, .zip-container {
left: 0;
}
.e-pv-sidebar-toolbar {
display: none !important;
}
.thumbnailShow {
display: none;
}

Просмотреть файл

@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>DocumentExplorer</RootNamespace>
<Configurations>Debug;Release;Publish</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|AnyCPU'">
<DefineConstants>TRACE;Publish</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Syncfusion.Blazor" Version="18.2.0.44" />
<PackageReference Include="Syncfusion.Blazor.PdfViewerServer.Windows" Version="18.2.0.44" />
<PackageReference Include="Syncfusion.Blazor.WordProcessor" Version="18.2.0.44" />
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="18.2.0.44" />
<PackageReference Include="Syncfusion.Licensing" Version="18.2.0.44" />
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="18.2.0.44" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview9.19424.4" />
</ItemGroup>
<ItemGroup>
<Content Update="web.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="SyncfusionLicense.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,28 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29521.150
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentExplorer", "DocumentExplorer.csproj", "{097B67E7-41B9-479E-B1D3-8B8939534FCF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Publish|Any CPU = Publish|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Publish|Any CPU.Build.0 = Publish|Any CPU
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{097B67E7-41B9-479E-B1D3-8B8939534FCF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EB60F3A9-EB50-4F29-8AEF-414D8B206DC7}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,154 +0,0 @@
@*@page "/bottomToolbar"*@
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Inputs
<div id="bottom_toolbar_container" class="bootom-tlbr-holder" style="display:none">
<SfToolbar Height="50px" CssClass="e-file-view-bottom-toolbar">
<ToolbarItems>
@*Show/Hide Thumbnail pane*@
<ToolbarItem TooltipText="Show or hide pages" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="ShowHidePages">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-show-hide e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Previous Page *@
<ToolbarItem TooltipText="Previous page" Disabled="@PreviousPageDisable" CssClass="disable-item" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="PreviousPage">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-previous e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Current Page Number *@
<ToolbarItem TooltipText="Current page number" Align="@ItemAlign.Left" Id="CurrentPageNumberItem" Type="ItemType.Input">
<Template>
<SfNumericTextBox Max="@TotalPages" CssClass="e-current-page-num" Width="50px" TValue="int" Format="###.##" Value="@CurrentPageNumber" ShowSpinButton=false>
<NumericTextBoxEvents TValue="int" ValueChange="Goto"></NumericTextBoxEvents>
</SfNumericTextBox>
</Template>
</ToolbarItem>
@* Total Page Number *@
<ToolbarItem TooltipText="Total pages" Align="@ItemAlign.Left" Id="total-pges">
<Template>
<span class="e-padding-toolbar-item e-bottom-toolbar-total-pages">of @TotalPages</span>
</Template>
</ToolbarItem>
@* Next Page *@
<ToolbarItem TooltipText="Next page" Disabled="@NextPageDisable" CssClass="disable-item" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="NextPage">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-next e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Zoom in *@
<ToolbarItem TooltipText="Zoom in" Disabled="@ZoomInDisable" CssClass="disable-item" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="ZoomIn">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-zoom-in e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Zoom out *@
<ToolbarItem TooltipText="Zoom out" Disabled="@ZoomOutDisable" CssClass="disable-item" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="ZoomOut">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-zoom-out e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Full Screen *@
<ToolbarItem TooltipText="Full screen" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="FullScreen">
<Template>
<span class="e-padding-toolbar-item e-icons e-bottom-toolbar-full-screen e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
@* Print *@
<ToolbarItem TooltipText="Print" Align="@ItemAlign.Left" OnClick="ToolbarClick" Id="Print">
<Template>
<span class="e-padding-toolbar-item e-icons sf-icon-Print e-bottom-tool-item"></span>
</Template>
</ToolbarItem>
</ToolbarItems>
</SfToolbar>
</div>
@code{
public int TotalPages { get; set; } = 0;
private bool NxtShowIcon { get; set; }
private bool PrevShowIcon { get; set; }
public int CurrentPageNumber { get; set; } = 1;
private string PrevItemDisable { get; set; } = "";
private string NxtItemDisable { get; set; } = "";
private string PreviousPageID { get; set; } = "";
public bool ZoomInDisable { get; set; }
public bool ZoomOutDisable { get; set; }
public bool PreviousPageDisable { get; set; } = true;
public bool NextPageDisable { get; set; }
public void Refresh()
{
StateHasChanged();
}
public async void Goto(Syncfusion.Blazor.Inputs.ChangeEventArgs<int> args)
{
if (args.IsInteracted)
{
int page;
int.TryParse(args.Value.ToString(), out page);
await GotoPage.InvokeAsync(page);
}
}
private async void ToolbarClick(ClickEventArgs args)
{
switch (args.Item.Id)
{
case "ShowHidePages":
await ShowHidePane.InvokeAsync(true);
break;
case "PreviousPage":
if (CurrentPageNumber > 1)
{
PreviousPageDisable = false;
NextPageDisable = false;
CurrentPageNumber--;
await GotoPage.InvokeAsync(CurrentPageNumber);
if (CurrentPageNumber == 1)
{
PreviousPageDisable = true;
}
}
break;
case "NextPage":
if (CurrentPageNumber < TotalPages)
{
NextPageDisable = false;
PreviousPageDisable = false;
CurrentPageNumber++;
await GotoPage.InvokeAsync(CurrentPageNumber);
if (CurrentPageNumber == TotalPages)
{
NextPageDisable = true;
}
}
break;
case "ZoomIn":
await ToolBarAction.InvokeAsync("ZoomIn");
break;
case "ZoomOut":
await ToolBarAction.InvokeAsync("ZoomOut");
break;
case "FullScreen":
await ToolBarAction.InvokeAsync("FullScreen");
break;
case "Print":
await ToolBarAction.InvokeAsync("Print");
break;
}
}
[Parameter]
public EventCallback<bool> ShowHidePane { get; set; }
[Parameter]
public EventCallback<int> GotoPage { get; set; }
[Parameter]
public EventCallback<string> ToolBarAction { get; set; }
}

Просмотреть файл

@ -1,69 +0,0 @@
@*@page "/thumbnail"*@
@using DocumentExplorer.Models
<div class="e-pv-sidebar-content" id="pdfViewer_sideBarContent" tabindex="0" aria-label="Thumbnail View Panel" style="top:52px;">
<div class="e-pv-thumbnail-view e-pv-thumbnail-row" id="pdfViewer_thumbnail_view" style="display: flex;">
@foreach (var item in ThumbnailImages)
{
<a tabindex="-1" role="link">
<div class="e-pv-thumbnail e-pv-thumbnail-column">
<div class="e-de-thumbnail-selection @UpdateSelectionClass(item.PageNumber)" @onclick="@(()=>Select(item.PageNumber))">
<img class="e-pv-thumbnail-image" src="@item.Src">
</div>
<div class="e-pv-thumbnail-number" style="font-size: 12px;padding-left:0px;padding-right:0px;text-align: center;">@item.PageNumber</div>
</div>
</a>
}
</div>
</div>
@code{
private List<ThumbnailImage> ThumbnailImages { get; set; }
private int _previousImageIndex = 1;
private int _selectedPage = 1;
public bool ShowThumbnail { get; set; } = true;
protected override void OnInitialized()
{
ThumbnailImages = new List<ThumbnailImage>();
}
private string UpdateSelectionClass(int pageNumber)
{
if (pageNumber == _selectedPage)
{
return "e-de-thumbnail-active-selection";
}
else
{
return "";
}
}
public void RenderThumbnail(string[] images)
{
ThumbnailImages = new List<ThumbnailImage>();
for (int i = 1; i <= images.Length; i++)
{
ThumbnailImages.Add(new ThumbnailImage(i, images[(i - 1)]));
}
StateHasChanged();
}
public void GotoPage(int pageNumber)
{
_previousImageIndex = pageNumber;
_selectedPage = pageNumber;
}
private async void Select(int pageNumber)
{
_selectedPage = pageNumber;
_previousImageIndex = pageNumber;
StateHasChanged();
await GotoSelectedThumbnailPage.InvokeAsync(pageNumber);
}
public void SelectFirstPage()
{
_selectedPage = 1;
StateHasChanged();
}
[Parameter]
public EventCallback<int> GotoSelectedThumbnailPage { get; set; }
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше