Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added icons for several standard file types. #73

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/SmartCommander/Assets/archive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SmartCommander/Assets/document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SmartCommander/Assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SmartCommander/Assets/video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 29 additions & 3 deletions src/SmartCommander/ViewModels/FileViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
using ReactiveUI;
using SmartCommander.Assets;
using System;
using System.Collections.Generic;
using System.IO;

namespace SmartCommander.ViewModels
{
public class FileViewModel : ViewModelBase
{
private string _name = "";
public static readonly List<string> ImageExtensions = new List<string>
{ "jpg", "jpeg", "jpe", "bmp", "tiff", "gif", "png" };
public static readonly List<string> VideoExtensions = new List<string>
{ "mp4", "mov", "avi", "wmv" };
public static readonly List<string> ArchiveExtensions = new List<string>
{ "zip", "rar", "7z" };
public static readonly List<string> DocumentExtensions = new List<string>
{ "doc", "docx", "txt","xslx", "xsl", "pdf" };
public FileViewModel()
{

Expand Down Expand Up @@ -39,11 +48,28 @@
}
Size = new FileInfo(fullName).Length.ToString();
DateCreated = File.GetCreationTime(fullName);
ImageSource = "Assets/file.png";
if (ImageExtensions.Contains(Extension.ToLower()))
{
ImageSource = "Assets/image.png";
}
else if (VideoExtensions.Contains(Extension.ToLower()))
{
ImageSource = "Assets/video.png";
}
else if (ArchiveExtensions.Contains(Extension.ToLower()))
{
ImageSource = "Assets/archive.png";
}
else if (DocumentExtensions.Contains(Extension.ToLower()))
{
ImageSource = "Assets/document.png";
}
else
{
ImageSource = "Assets/file.png";
}
}

}

public string FullName { get; set; } = "";
public string Name
{
Expand All @@ -63,12 +89,12 @@
// moving here is fast since they are guaranteed to be on the same drive
if (IsFolder)
{
destination = Path.Combine(Path.GetDirectoryName(FullName), value);

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 92 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.
Directory.Move(FullName, destination);
}
else
{
destination = Path.Combine(Path.GetDirectoryName(FullName), value + "." + Extension);

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.

Check warning on line 97 in src/SmartCommander/ViewModels/FileViewModel.cs

View workflow job for this annotation

GitHub Actions / build-windows-latest

Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'.
File.Move(FullName, destination);
}
_name = value;
Expand Down
Loading