Skip to content

Commit

Permalink
FileManagerPage: Fix default icon paths; gui
Browse files Browse the repository at this point in the history
  • Loading branch information
tajbender committed Mar 22, 2023
1 parent dbce2c4 commit 24c652b
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 135 deletions.
22 changes: 12 additions & 10 deletions src/electrifier/Models/DosShell/DosShellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,37 @@
using Microsoft.UI;
using Microsoft.UI.Xaml;

namespace electrifier.Services;
namespace electrifier.Models.DosShell;

public class DosShellItem : INotifyPropertyChanged, IEquatable<DosShellItem?>
{

public string FileName => (StorageItem != null ? StorageItem?.Name : "[Not Initialized]");
public string FileName => StorageItem != null ? StorageItem.Name : "[Not Initialized]";



public string FileType => (StorageItem != null ? StorageItem?.Name : "[Not Initialized]");
public string FileType => StorageItem != null ? StorageItem.Name : "[Not Initialized]";


public override int GetHashCode()
{
return StorageItem.GetHashCode();
}

public bool IsFolder
public IconId IconId
{
get; private set;
}

public bool IsFile => !IsFolder;

public IconId IconId
public bool IsFolder
{
get; private set;
}
public ImageIcon ShellIcon


public ImageIcon ShellImageIcon
{
get; private set;
}
Expand All @@ -46,15 +48,15 @@ public IStorageItem StorageItem

public DosShellItem()
{
IconId = IconId = new IconId((ulong)(IsFolder ? 0x0 : 0x1));
IconId = new IconId((ulong)(IsFolder ? 0x0 : 0x1));
}

public DosShellItem(IStorageItem storageItem)
{
StorageItem = storageItem;
IsFolder = storageItem.IsOfType(StorageItemTypes.Folder);
IconId = new IconId((ulong)(IsFolder ? 0x0 : 0x1));
ShellIcon = new ImageIcon();
ShellImageIcon = new ImageIcon();
}


Expand All @@ -66,10 +68,10 @@ private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
image.ImageFailed += Image_ImageFailed;

var imageIcon = new ImageIcon();
ShellIcon = imageIcon;
ShellImageIcon = imageIcon;

OnPropertyChanged(nameof(IconId));
OnPropertyChanged(nameof(ShellIcon));
OnPropertyChanged(nameof(ShellImageIcon));
}

#region events
Expand Down
84 changes: 41 additions & 43 deletions src/electrifier/Views/FileManagerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,55 @@
x:Class="electrifier.Views.FileManagerPage"
xmlns:behaviors="using:electrifier.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dosshell="using:electrifier.Models.DosShell"
xmlns:local="using:electrifier.Services"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<Grid
x:Name="ContentArea">
<StackPanel
Orientation="Vertical">
<MenuBar Name="MenuBar">
<MenuBarItem
Title="File">
<MenuFlyoutItem
Text="New Tab" />
<MenuFlyoutItem
Text="New" />
<MenuFlyoutItem
Text="Open" />
</MenuBarItem>
<MenuBarItem
Title="Edit">
<MenuFlyoutItem
Text="Undo" />
<MenuFlyoutItem
Text="Cut" />
<MenuFlyoutItem
Text="Copy" />
<MenuFlyoutItem
Text="Paste" />
</MenuBarItem>
<MenuBarItem
Title="Help">
<MenuFlyoutItem
Text="About" />
</MenuBarItem>
</MenuBar>
<AppBar>
<AppBarButton>Cut</AppBarButton>
<!--<AppBarButton>Copy</AppBarButton>
<AppBarButton>Paste</AppBarButton>
<AppBarButton>Paste As</AppBarButton>-->
</AppBar>
<CommandBar
Background="Transparent"
HorizontalAlignment="Stretch"
DefaultLabelPosition="Right">
<AppBarButton
Icon="Add"
Label="Add"
IsEnabled="False">
</AppBarButton>
<AppBarSeparator />
<AppBarButton
Icon="Cut"
Label="Cut"
IsEnabled="False" />
<AppBarButton
Icon="Copy"
Label="Copy"
IsEnabled="False" />
<AppBarButton
Icon="Paste"
Label="Paste"
IsEnabled="False" />
<AppBarSeparator />
<CommandBar.SecondaryCommands>
<AppBarButton
Icon="Setting"
Label="Settings">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator
Modifiers="Control"
Key="I" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
</CommandBar.SecondaryCommands>
</CommandBar>
<Grid>
<Grid.Resources>
<DataTemplate
x:DataType="local:DosShellItem"
x:DataType="dosshell:DosShellItem"
x:Key="ImageGridViewItemTemplate">
<Grid
Height="150"
Expand All @@ -60,20 +64,16 @@
<RowDefinition
Height="45" />
</Grid.RowDefinitions>


<ImageIcon
x:Name="ImageGridView_ItemTemplate_DefaultFolderIcon"
Visibility="{x:Bind IsFolder}"
Source="..\Assets\Views\Workbench\Shell32 Default Folder.ico"
Source="..\Assets\Views\Workbench\Icons\Shell32 Default Folder.ico"
Grid.Row="0" />

<ImageIcon
x:Name="ImageGridView_ItemTemplate_DefaultFileIcon"
Visibility="{x:Bind IsFile}"
Source="..\Assets\Views\Workbench\Shell32 Default unknown File.ico"
Source="..\Assets\Views\Workbench\Icons\Shell32 Default unknown File.ico"
Grid.Row="0" />

<TextBlock
Grid.Row="1"
Text="{x:Bind FileName}"
Expand All @@ -82,7 +82,6 @@
Style="{StaticResource SubtitleTextBlockStyle}" />
</Grid>
</DataTemplate>

<Style
x:Key="ImageGridViewItemContainerStyle"
TargetType="GridViewItem">
Expand All @@ -91,7 +90,6 @@
Value="3" />
</Style>
</Grid.Resources>

<GridView
x:Name="ImageGridView"
ItemTemplate="{StaticResource ImageGridViewItemTemplate}"
Expand Down
6 changes: 3 additions & 3 deletions src/electrifier/Views/FileManagerPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using electrifier.Services;
using electrifier.Models.DosShell;
using electrifier.ViewModels;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using System.Collections.ObjectModel;
using Windows.Storage;
using Microsoft.UI.Xaml.Media.Imaging;

namespace electrifier.Views;

Expand Down Expand Up @@ -101,7 +101,7 @@ private async void ShowImage(
bitmapImage.UriSource = new Uri(img.BaseUri,"Assets/StoreLogo.png");
img.Source = bitmapImage;*/

//imageElement.Source = new ImageSource(item.ShellIcon);
//imageElement.Source = new ImageSource(item.ShellImageIcon);

//var task = item?.GetImageThumbnailAsync();

Expand Down
Loading

0 comments on commit 24c652b

Please sign in to comment.