Skip to content

Commit

Permalink
Merge branch 'iExt11-11-#1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tajbender authored Nov 13, 2024
2 parents 6305987 + d4aa67f commit b3df96b
Show file tree
Hide file tree
Showing 101 changed files with 1,788 additions and 1,672 deletions.
6 changes: 6 additions & 0 deletions src/electrifier/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml;
using System.Diagnostics;
using electrifier.Controls.Vanara.Services;
using WinUIEx;
using static Microsoft.Extensions.Hosting.Host;
using UnhandledExceptionEventArgs = Microsoft.UI.Xaml.UnhandledExceptionEventArgs;
Expand Down Expand Up @@ -38,6 +39,11 @@ public IHost Host
}
public static WindowEx MainWindow { get; } = new MainWindow();

public static ShellNamespaceService NamespaceService
{
get;
} = new() { };

public App()
{
InitializeComponent();
Expand Down
Binary file added src/electrifier/Assets/LargeTile.scale-100.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/electrifier/Assets/LargeTile.scale-125.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/electrifier/Assets/LargeTile.scale-150.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/electrifier/Assets/LargeTile.scale-200.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/electrifier/Assets/LargeTile.scale-400.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/electrifier/Assets/SmallTile.scale-100.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/electrifier/Assets/SmallTile.scale-125.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/electrifier/Assets/SmallTile.scale-150.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/electrifier/Assets/SmallTile.scale-200.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/electrifier/Assets/SmallTile.scale-400.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 removed src/electrifier/Assets/SplashScreen.png
Binary file not shown.
Binary file added src/electrifier/Assets/SplashScreen.scale-100.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/electrifier/Assets/SplashScreen.scale-125.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/electrifier/Assets/SplashScreen.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/electrifier/Assets/StoreLogo.scale-100.png
Binary file added src/electrifier/Assets/StoreLogo.scale-125.png
Binary file modified src/electrifier/Assets/StoreLogo.scale-150.png
Binary file added src/electrifier/Assets/StoreLogo.scale-200.png
Binary file added src/electrifier/Assets/StoreLogo.scale-400.png
Binary file modified src/electrifier/Assets/app.ico
Binary file not shown.
46 changes: 46 additions & 0 deletions src/electrifier/Controls/Vanara/Contracts/AbstractBrowserItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using Vanara.PInvoke;
using Vanara.Windows.Shell;
using static Vanara.PInvoke.ComCtl32;
using static Vanara.PInvoke.Shell32;

namespace electrifier.Controls.Vanara.Contracts;

[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
public abstract class AbstractBrowserItem<T>(bool isFolder, List<T> childItems)
{
public readonly bool IsFolder = isFolder;
public readonly List<T> ChildItems = childItems;
public new string ToString() => $"AbstractBrowserItem(<{typeof(T)}>(isFolder {isFolder}, childItems {childItems})";
}

[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
public abstract class AbstractBrowserItemCollection<T> : IEnumerable<AbstractBrowserItem<T>>, IList<AbstractBrowserItem<T>>
{
protected readonly IList<AbstractBrowserItem<T>> Collection = [];
//protected readonly ShellItem? _parentItem;

AbstractBrowserItem<T> IList<AbstractBrowserItem<T>>.this[int index] { get => Collection[index]; set => Collection[index] = value; }
int ICollection<AbstractBrowserItem<T>>.Count => Collection.Count;
bool ICollection<AbstractBrowserItem<T>>.IsReadOnly => false;
void ICollection<AbstractBrowserItem<T>>.Add(AbstractBrowserItem<T> item) => Collection.Add(item);
void ICollection<AbstractBrowserItem<T>>.Clear() => Collection.Clear();
bool ICollection<AbstractBrowserItem<T>>.Contains(AbstractBrowserItem<T> item) => Collection.Contains(item);
void ICollection<AbstractBrowserItem<T>>.CopyTo(AbstractBrowserItem<T>[] array, int arrayIndex) => Collection.CopyTo(array, arrayIndex);
IEnumerator<AbstractBrowserItem<T>> IEnumerable<AbstractBrowserItem<T>>.GetEnumerator() => Collection.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => Collection.GetEnumerator();
int IList<AbstractBrowserItem<T>>.IndexOf(AbstractBrowserItem<T> item) => Collection.IndexOf(item);
void IList<AbstractBrowserItem<T>>.Insert(int index, AbstractBrowserItem<T> item) => Collection.Insert(index, item);
bool ICollection<AbstractBrowserItem<T>>.Remove(AbstractBrowserItem<T> item) => Collection.Remove(item);
void IList<AbstractBrowserItem<T>>.RemoveAt(int index) => Collection.RemoveAt(index);

public new string ToString() => $"AbstractBrowserItemCollection(<{typeof(T)}>(number of child items: {Collection.Count})";
}
192 changes: 192 additions & 0 deletions src/electrifier/Controls/Vanara/ExplorerBrowser.NavigationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Vanara.PInvoke.Shell32;
using Vanara.Windows.Shell;

namespace electrifier.Controls.Vanara;

public sealed partial class ExplorerBrowser
{

/*
/// <summary>The navigation log is a history of the locations visited by the explorer browser.</summary>
public class NavigationLog
{
private readonly ExplorerBrowser? parent = null;
/// <summary>The pending navigation log action. null if the user is not navigating via the navigation log.</summary>
private PendingNavigation? pendingNavigation;
internal NavigationLog(ExplorerBrowser parent)
{
// Hook navigation events from the parent to distinguish between navigation log induced navigation, and other navigations.
this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
this.parent.Navigated += OnNavigated;
this.parent.NavigationFailed += OnNavigationFailed;
}
/// <summary>Fires when the navigation log changes or the current navigation position changes</summary>
public event EventHandler<NavigationLogEventArgs>? NavigationLogChanged;
/// <summary>Indicates the presence of locations in the log that can be reached by calling Navigate(Backward)</summary>
public bool CanNavigateBackward => CurrentLocationIndex > 0;
/// <summary>Indicates the presence of locations in the log that can be reached by calling Navigate(Forward)</summary>
public bool CanNavigateForward => CurrentLocationIndex < Locations.Count - 1;
/// <summary>Gets the shell object in the Locations collection pointed to by CurrentLocationIndex.</summary>
public ShellItem? CurrentLocation => CurrentLocationIndex < 0 ? null : Locations[CurrentLocationIndex];
/// <summary>
/// An index into the Locations collection. The ShellItem pointed to by this index is the current location of the ExplorerBrowser.
/// </summary>
public int CurrentLocationIndex { get; set; } = -1;
/// <summary>The navigation log</summary>
public List<ShellItem> Locations { get; } = new List<ShellItem>();
/// <summary>Clears the contents of the navigation log.</summary>
public void Clear()
{
if (Locations.Count == 0) return;
var oldCanNavigateBackward = CanNavigateBackward;
var oldCanNavigateForward = CanNavigateForward;
Locations.Clear();
CurrentLocationIndex = -1;
var args = new NavigationLogEventArgs
{
LocationsChanged = true,
CanNavigateBackwardChanged = oldCanNavigateBackward != CanNavigateBackward,
CanNavigateForwardChanged = oldCanNavigateForward != CanNavigateForward
};
NavigationLogChanged?.Invoke(this, args);
}
internal bool NavigateLog(NavigationLogDirection direction)
{
// determine proper index to navigate to
int locationIndex;
switch (direction)
{
case NavigationLogDirection.Backward when CanNavigateBackward:
locationIndex = CurrentLocationIndex - 1;
break;
case NavigationLogDirection.Forward when CanNavigateForward:
locationIndex = CurrentLocationIndex + 1;
break;
default:
return false;
}
// initiate traversal request
var location = Locations[locationIndex];
pendingNavigation = new PendingNavigation(location, locationIndex);
parent?.Navigate(location);
return true;
}
internal bool NavigateLog(int index)
{
// can't go anywhere
if (index >= Locations.Count || index < 0) return false;
// no need to re navigate to the same location
if (index == CurrentLocationIndex) return false;
// initiate traversal request
var location = Locations[index];
pendingNavigation = new PendingNavigation(location, index);
parent?.Navigate(location);
return true;
}
private void OnNavigated(object? sender, NavigatedEventArgs args)
{
var eventArgs = new NavigationLogEventArgs();
var oldCanNavigateBackward = CanNavigateBackward;
var oldCanNavigateForward = CanNavigateForward;
if (pendingNavigation != null)
{
// navigation log traversal in progress
// determine if new location is the same as the traversal request
var shellItemsEqual = pendingNavigation.Location.IShellItem.Compare(args.NewLocation?.IShellItem, SICHINTF.SICHINT_ALLFIELDS, out var i).Succeeded && i == 0;
if (!shellItemsEqual)
{
// new location is different than traversal request, behave is if it never happened! remove history following
// currentLocationIndex, append new item
if (CurrentLocationIndex < Locations.Count - 1)
{
Locations.RemoveRange(CurrentLocationIndex + 1, Locations.Count - (CurrentLocationIndex + 1));
}
if (args.NewLocation is not null) Locations.Add(args.NewLocation);
CurrentLocationIndex = Locations.Count - 1;
eventArgs.LocationsChanged = true;
}
else
{
// log traversal successful, update index
CurrentLocationIndex = pendingNavigation.Index;
eventArgs.LocationsChanged = false;
}
pendingNavigation = null;
}
else
{
// remove history following currentLocationIndex, append new item
if (CurrentLocationIndex < Locations.Count - 1)
{
Locations.RemoveRange(CurrentLocationIndex + 1, Locations.Count - (CurrentLocationIndex + 1));
}
if (args.NewLocation is not null) Locations.Add(args.NewLocation);
CurrentLocationIndex = Locations.Count - 1;
eventArgs.LocationsChanged = true;
}
// update event args
eventArgs.CanNavigateBackwardChanged = oldCanNavigateBackward != CanNavigateBackward;
eventArgs.CanNavigateForwardChanged = oldCanNavigateForward != CanNavigateForward;
NavigationLogChanged?.Invoke(this, eventArgs);
}
private void OnNavigationFailed(object? sender, NavigationFailedEventArgs args) => pendingNavigation = null;
/// <summary>A navigation traversal request</summary>
private class PendingNavigation
{
internal PendingNavigation(ShellItem location, int index)
{
Location = location;
Index = index;
}
internal int Index { get; set; }
internal ShellItem Location { get; set; }
}
}
/// <summary>The event argument for NavigationLogChangedEvent</summary>
public class NavigationLogEventArgs : EventArgs
{
/// <summary>Indicates CanNavigateBackward has changed</summary>
public bool CanNavigateBackwardChanged { get; set; }
/// <summary>Indicates CanNavigateForward has changed</summary>
public bool CanNavigateForwardChanged { get; set; }
/// <summary>Indicates the Locations collection has changed</summary>
public bool LocationsChanged { get; set; }
}
*/
}
Loading

0 comments on commit b3df96b

Please sign in to comment.