* Added icon to "Recent >" menu item. * Refactored app menu implementation, and implemented keyboard accelerators. Still doesn't work though. * Few things fixed, but still doesn't work. * Clicking menu items works. * Fixing an issue with resources. * New menu binding implemented. Still doesn't work though. * Menu displayed properly, except for "Settings". * Menu works, but it doesn't refresh. * Works. But needs to be polished. * All known issues with the new app menu solved. * Significantly simplifying app menu binding. * Removing some obsolete classes. * Menu binding mechanism additionally optimized for performances. * Removing unused translations. * Further refactoring app menu binding, in order to make it more general. * New window mechanism simplified. Terminal-launching code refactored to be more readable. A bug with "SSH Info" fixed. * Merging the latest changed.
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
namespace FluentTerminal.App.ViewModels.Menu
|
|
{
|
|
public class ExpandableMenuItemViewModel : MenuItemViewModelBase
|
|
{
|
|
public ObservableCollection<MenuItemViewModelBase> SubItems { get; }
|
|
|
|
public ExpandableMenuItemViewModel(string text, IEnumerable<MenuItemViewModelBase> subItems = null,
|
|
string description = null, object icon = null) : base(text, description, icon)
|
|
{
|
|
if (subItems == null)
|
|
{
|
|
SubItems = new ObservableCollection<MenuItemViewModelBase>();
|
|
}
|
|
else if (subItems is ObservableCollection<MenuItemViewModelBase> observableSubItems)
|
|
{
|
|
SubItems = observableSubItems;
|
|
}
|
|
else
|
|
{
|
|
SubItems = new ObservableCollection<MenuItemViewModelBase>(subItems);
|
|
}
|
|
}
|
|
|
|
public override bool EquivalentTo(MenuItemViewModelBase other)
|
|
{
|
|
if (!base.EquivalentTo(other)) return false;
|
|
|
|
if (!(other is ExpandableMenuItemViewModel otherExpandable) ||
|
|
SubItems.Count != otherExpandable.SubItems.Count)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return !SubItems.Where((t, i) => !t.EquivalentTo(otherExpandable.SubItems[i])).Any();
|
|
}
|
|
}
|
|
} |