From c2ea626c4d3de70606ce6ce281f1224b38c3b431 Mon Sep 17 00:00:00 2001 From: Diaskhan Date: Tue, 1 Oct 2024 03:25:02 +0500 Subject: [PATCH 01/12] Added plugins options --- src/SmartCommander/Models/OptionsModel.cs | 3 + .../ViewModels/OptionsViewModel.cs | 76 +++++++++-- src/SmartCommander/Views/OptionsWindow.axaml | 120 ++++++++++-------- 3 files changed, 130 insertions(+), 69 deletions(-) diff --git a/src/SmartCommander/Models/OptionsModel.cs b/src/SmartCommander/Models/OptionsModel.cs index 78b346a..379a808 100644 --- a/src/SmartCommander/Models/OptionsModel.cs +++ b/src/SmartCommander/Models/OptionsModel.cs @@ -1,4 +1,6 @@ using Newtonsoft.Json; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using static System.Environment; @@ -56,5 +58,6 @@ static OptionsModel() public bool AllowOnlyOneInstance { get; set; } = true; public string Language { get; set; } = "en-US"; + public List ListerPlugins { get; set; }= new List(); } } diff --git a/src/SmartCommander/ViewModels/OptionsViewModel.cs b/src/SmartCommander/ViewModels/OptionsViewModel.cs index 890e9b6..4b4ce4f 100644 --- a/src/SmartCommander/ViewModels/OptionsViewModel.cs +++ b/src/SmartCommander/ViewModels/OptionsViewModel.cs @@ -1,13 +1,20 @@ -using Avalonia.Controls; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Interactivity; +using Avalonia.Platform.Storage; +using AvaloniaEdit.Utils; using ReactiveUI; using SmartCommander.Assets; using SmartCommander.Models; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; +using System.IO; using System.Linq; using System.Reactive; using System.Resources; +using System.Threading.Tasks; namespace SmartCommander.ViewModels { @@ -18,6 +25,15 @@ public class OptionsViewModel : ViewModelBase public CultureInfo SelectedCulture { get; set; } + + public ObservableCollection? ListerPlugins { get; set; } + private string _selectedPlugin = string.Empty; + public string SelectedPlugin + { + get => _selectedPlugin; + set => this.RaiseAndSetIfChanged(ref _selectedPlugin, value); + } + private static IEnumerable GetAvailableCultures() { List result = new List(); @@ -26,14 +42,15 @@ private static IEnumerable GetAvailableCultures() foreach (CultureInfo culture in cultures) { - if (culture.Equals(CultureInfo.InvariantCulture)) { - result.Add(new CultureInfo("en-US")); - continue; - } - - ResourceSet? rs = rm?.GetResourceSet(culture, true, false); - if (rs != null) - result.Add(culture); + if (culture.Equals(CultureInfo.InvariantCulture)) + { + result.Add(new CultureInfo("en-US")); + continue; + } + + ResourceSet? rs = rm?.GetResourceSet(culture, true, false); + if (rs != null) + result.Add(culture); } return result; } @@ -42,7 +59,7 @@ public OptionsViewModel() { OKCommand = ReactiveCommand.Create(SaveClose); CancelCommand = ReactiveCommand.Create(Close); - + IsCurrentDirectoryDisplayed = Model.IsCurrentDirectoryDisplayed; IsFunctionKeysDisplayed = Model.IsFunctionKeysDisplayed; IsCommandLineDisplayed = Model.IsCommandLineDisplayed; @@ -56,9 +73,12 @@ public OptionsViewModel() AvailableCultures = new ObservableCollection(GetAvailableCultures()); var lang = AvailableCultures.First(x => x.Name == Model.Language); SelectedCulture = lang ?? AvailableCultures.First(); + ListerPlugins.AddRange(Model.ListerPlugins); + AddFileCommand = ReactiveCommand.Create(AddFileAsync); + RemoveFileCommand = ReactiveCommand.Create(RemoveFile); } - public bool IsCurrentDirectoryDisplayed { get; set; } + public bool IsCurrentDirectoryDisplayed { get; set; } public bool IsFunctionKeysDisplayed { get; set; } @@ -72,11 +92,39 @@ public OptionsViewModel() public bool SaveWindowPositionSize { get; set; } - public bool IsDarkThemeEnabled { get; set; } - public bool AllowOnlyOneInstance { get; set; } + public bool IsDarkThemeEnabled { get; set; } + public bool AllowOnlyOneInstance { get; set; } public ReactiveCommand OKCommand { get; } public ReactiveCommand CancelCommand { get; } + public ReactiveCommand AddFileCommand { get; } + public ReactiveCommand RemoveFileCommand { get; } + private void RemoveFile(Window window) + { + if (!string.IsNullOrWhiteSpace(SelectedPlugin)) + { + ListerPlugins?.Remove(SelectedPlugin); + } + } + + private void AddFileAsync(Window window) + { + var desktop = (IClassicDesktopStyleApplicationLifetime?)Application.Current?.ApplicationLifetime; + var topLevel = TopLevel.GetTopLevel(desktop?.MainWindow); + + // Start async operation to open the dialog. + var files = topLevel?.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + { + Title = "Open Text File", + AllowMultiple = false, + }); + + if (files?.Result.Count >= 1) + { + //hie + } + + } public void SaveClose(Window window) { @@ -93,7 +141,7 @@ public void SaveClose(Window window) Model.Save(); window?.Close(this); - + } public void Close(Window window) diff --git a/src/SmartCommander/Views/OptionsWindow.axaml b/src/SmartCommander/Views/OptionsWindow.axaml index d267cdc..ad19519 100644 --- a/src/SmartCommander/Views/OptionsWindow.axaml +++ b/src/SmartCommander/Views/OptionsWindow.axaml @@ -2,70 +2,80 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="350" - Width="600" Height="350" + mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="400" + Width="600" Height="400" x:Class="SmartCommander.Views.OptionsWindow" ShowInTaskbar="False" Icon="/Assets/main.ico" - WindowStartupLocation="CenterOwner" + WindowStartupLocation="CenterOwner" xmlns:assets="clr-namespace:SmartCommander.Assets" Title="{x:Static assets:Resources.Options}"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + From 2085ef7784f3ef61954c96380724cfbd0171a1ec Mon Sep 17 00:00:00 2001 From: Diaskhan Date: Tue, 1 Oct 2024 03:33:09 +0500 Subject: [PATCH 02/12] finnaly --- src/SmartCommander/ViewModels/OptionsViewModel.cs | 3 ++- src/SmartCommander/Views/OptionsWindow.axaml | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SmartCommander/ViewModels/OptionsViewModel.cs b/src/SmartCommander/ViewModels/OptionsViewModel.cs index 4b4ce4f..4b15bcb 100644 --- a/src/SmartCommander/ViewModels/OptionsViewModel.cs +++ b/src/SmartCommander/ViewModels/OptionsViewModel.cs @@ -73,6 +73,7 @@ public OptionsViewModel() AvailableCultures = new ObservableCollection(GetAvailableCultures()); var lang = AvailableCultures.First(x => x.Name == Model.Language); SelectedCulture = lang ?? AvailableCultures.First(); + ListerPlugins = new ObservableCollection(); ListerPlugins.AddRange(Model.ListerPlugins); AddFileCommand = ReactiveCommand.Create(AddFileAsync); RemoveFileCommand = ReactiveCommand.Create(RemoveFile); @@ -121,7 +122,7 @@ private void AddFileAsync(Window window) if (files?.Result.Count >= 1) { - //hie + ListerPlugins.Add(files.Result.FirstOrDefault().Name); } } diff --git a/src/SmartCommander/Views/OptionsWindow.axaml b/src/SmartCommander/Views/OptionsWindow.axaml index ad19519..4a6621c 100644 --- a/src/SmartCommander/Views/OptionsWindow.axaml +++ b/src/SmartCommander/Views/OptionsWindow.axaml @@ -61,12 +61,13 @@ - - - From 53955a7c7f5337c6b535ec3ce844fdff858aa749 Mon Sep 17 00:00:00 2001 From: Diaskhan_Imanberdiyev Date: Tue, 1 Oct 2024 19:43:02 +0500 Subject: [PATCH 09/12] added try excpet if 32 bit libraries --- src/SmartCommander/Views/ViewerWindow.axaml.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/SmartCommander/Views/ViewerWindow.axaml.cs b/src/SmartCommander/Views/ViewerWindow.axaml.cs index 3c25246..45b88c1 100644 --- a/src/SmartCommander/Views/ViewerWindow.axaml.cs +++ b/src/SmartCommander/Views/ViewerWindow.axaml.cs @@ -69,11 +69,19 @@ public EmbedSample(string Filename) { listerPluginWrapper?.Dispose(); - listerPluginWrapper = PluginManager.CreateListerWrapper(ListerFileName); - listerWindowHandle = listerPluginWrapper.CreateListerWindow(IntPtr.Zero, Filename); + try + { + listerPluginWrapper = PluginManager.CreateListerWrapper(ListerFileName); + listerWindowHandle = listerPluginWrapper.CreateListerWindow(IntPtr.Zero, Filename); + + if (listerWindowHandle != IntPtr.Zero) + return; + } + catch (BadImageFormatException ex) + { + Console.WriteLine($"we cannot load 32bit libraries: {ex.Message}"); + } - if (listerWindowHandle != IntPtr.Zero) - return; } } From 6facfdde63380babd01b1578c890c43a272fa5db Mon Sep 17 00:00:00 2001 From: Diaskhan_Imanberdiyev Date: Tue, 1 Oct 2024 19:45:07 +0500 Subject: [PATCH 10/12] supporting only 64bit extensions --- src/SmartCommander/ViewModels/OptionsViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SmartCommander/ViewModels/OptionsViewModel.cs b/src/SmartCommander/ViewModels/OptionsViewModel.cs index 9529ffb..16a0c02 100644 --- a/src/SmartCommander/ViewModels/OptionsViewModel.cs +++ b/src/SmartCommander/ViewModels/OptionsViewModel.cs @@ -109,9 +109,9 @@ private void RemoveFile(Window window) } } - public static FilePickerFileType ListerPluginsFilter { get; } = new("Lister Plugins") + public static FilePickerFileType ListerPluginsFilter { get; } = new("Lister Plugins (64bit)") { - Patterns = new[] { "*.wlx", "*.wlx64" } + Patterns = new[] { /*"*.wlx",*/ "*.wlx64" } }; private void AddFileAsync(Window window) { From ef0de8588e570d239a2d96d97e266b1947ea816c Mon Sep 17 00:00:00 2001 From: Diaskhan_Imanberdiyev Date: Tue, 1 Oct 2024 19:46:13 +0500 Subject: [PATCH 11/12] clean usings --- src/SmartCommander/ViewModels/OptionsViewModel.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/SmartCommander/ViewModels/OptionsViewModel.cs b/src/SmartCommander/ViewModels/OptionsViewModel.cs index 16a0c02..84aebf0 100644 --- a/src/SmartCommander/ViewModels/OptionsViewModel.cs +++ b/src/SmartCommander/ViewModels/OptionsViewModel.cs @@ -1,7 +1,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Interactivity; using Avalonia.Platform.Storage; using AvaloniaEdit.Utils; using ReactiveUI; @@ -10,12 +9,9 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; -using System.IO; -using System.IO.Enumeration; using System.Linq; using System.Reactive; using System.Resources; -using System.Threading.Tasks; namespace SmartCommander.ViewModels { From 63db2c2e27cbc7844393652d90e7ef1a587375c5 Mon Sep 17 00:00:00 2001 From: Diaskhan_Imanberdiyev Date: Tue, 1 Oct 2024 19:50:32 +0500 Subject: [PATCH 12/12] added label for 64 bit --- src/SmartCommander/Views/OptionsWindow.axaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SmartCommander/Views/OptionsWindow.axaml b/src/SmartCommander/Views/OptionsWindow.axaml index 9eb8a2a..d264c03 100644 --- a/src/SmartCommander/Views/OptionsWindow.axaml +++ b/src/SmartCommander/Views/OptionsWindow.axaml @@ -67,6 +67,7 @@