mirror of
https://github.com/Stone-Red-Code/Markdowser.git
synced 2026-09-04 09:06:15 +02:00
Add tabs and info panels
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CS0067: The event 'HomeCommand.CanExecuteChanged' is never used
|
||||
dotnet_diagnostic.CS0067.severity = none
|
||||
+6
-1
@@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34616.47
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markdowser", "Markdowser\Markdowser.csproj", "{98C02B25-7D7D-4F83-892D-5503FFF3D108}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Markdowser", "Markdowser\Markdowser.csproj", "{98C02B25-7D7D-4F83-892D-5503FFF3D108}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99E8E3C0-9FF5-4665-98DC-BD0C00FA8569}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -3,7 +3,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Styling;
|
||||
|
||||
using Markdowser.Utilities;
|
||||
using Markdowser.Models;
|
||||
using Markdowser.ViewModels;
|
||||
using Markdowser.Views;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 172 KiB |
@@ -1,6 +1,7 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Styling;
|
||||
|
||||
using Markdowser.Models;
|
||||
using Markdowser.Utilities;
|
||||
|
||||
using System;
|
||||
@@ -10,8 +11,12 @@ namespace Markdowser.Commands;
|
||||
|
||||
internal class ChangeThemeCommand : ICommand
|
||||
{
|
||||
#pragma warning disable CS0067 // The event 'ChangeThemeCommand.CanExecuteChanged' is never used
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
|
||||
#pragma warning restore CS0067 // The event 'ChangeThemeCommand.CanExecuteChanged' is never used
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Markdowser.Utilities;
|
||||
using Markdowser.Models;
|
||||
using Markdowser.Utilities;
|
||||
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
@@ -7,8 +8,12 @@ namespace Markdowser.Commands;
|
||||
|
||||
internal class HomeCommand : ICommand
|
||||
{
|
||||
#pragma warning disable CS0067 // The event 'HomeCommand.CanExecuteChanged' is never used
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
|
||||
#pragma warning restore CS0067 // The event 'HomeCommand.CanExecuteChanged' is never used
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -8,8 +8,12 @@ namespace Markdowser.Commands;
|
||||
|
||||
public class HyperlinkCommand : ICommand
|
||||
{
|
||||
#pragma warning disable CS0067 // The event 'HyperlinkCommand.CanExecuteChanged' is never used
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
|
||||
#pragma warning restore CS0067 // The event 'HyperlinkCommand.CanExecuteChanged' is never used
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
|
||||
[assembly: SuppressMessage("Minor Code Smell", "CS0067:The event 'ChangeThemeCommand.CanExecuteChanged' is never used", Justification = "<Pending>", Scope = "member", Target = "~N:Markdowser.Commands")]
|
||||
[assembly: SuppressMessage("Minor Code Smell", "CS0067:The event 'ChangeThemeCommand.CanExecuteChanged' is never used", Justification = "<Pending>", Scope = "member", Target = "~N:Markdowser.Commands")]
|
||||
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>")]
|
||||
@@ -13,8 +13,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Markdowser-Dark-Transparent.ico" />
|
||||
<None Remove="Assets\Markdowser-Dark-Transparent.png" />
|
||||
<None Remove="Assets\Markdowser-Dark.png" />
|
||||
<None Remove="Assets\Markdowser-Light-Transparent.ico" />
|
||||
<None Remove="Assets\Markdowser-Light-Transparent.png" />
|
||||
<None Remove="Assets\Markdowser-Light.png" />
|
||||
</ItemGroup>
|
||||
@@ -35,8 +37,4 @@
|
||||
<PackageReference Include="ReverseMarkdown" Version="4.3.0" />
|
||||
<PackageReference Include="Semi.Avalonia" Version="11.0.7.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.IO;
|
||||
using Markdowser.Utilities;
|
||||
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Markdowser.Utilities;
|
||||
namespace Markdowser.Models;
|
||||
|
||||
internal class Settings
|
||||
public class Settings
|
||||
{
|
||||
public static Settings Current { get; set; } = LoadSettings();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Avalonia;
|
||||
|
||||
namespace Markdowser.Utilities;
|
||||
|
||||
internal static class ColumnDefinition
|
||||
{
|
||||
public static readonly AttachedProperty<bool> IsVisibleProperty = AvaloniaProperty.RegisterAttached<Avalonia.Controls.ColumnDefinition, bool>("IsVisible", typeof(ColumnDefinition), true, coerce: (element, visibility) =>
|
||||
{
|
||||
Avalonia.Controls.GridLength? lastWidth = element.GetValue(LastWidthProperty!);
|
||||
if (visibility && lastWidth is { })
|
||||
{
|
||||
_ = element.SetValue(Avalonia.Controls.ColumnDefinition.WidthProperty, lastWidth);
|
||||
}
|
||||
else if (!visibility)
|
||||
{
|
||||
_ = element.SetValue(LastWidthProperty, element.GetValue(Avalonia.Controls.ColumnDefinition.WidthProperty));
|
||||
_ = element.SetValue(Avalonia.Controls.ColumnDefinition.WidthProperty, ZeroWidth);
|
||||
}
|
||||
return visibility;
|
||||
});
|
||||
|
||||
private static readonly Avalonia.Controls.GridLength ZeroWidth = new Avalonia.Controls.GridLength(0, Avalonia.Controls.GridUnitType.Pixel);
|
||||
|
||||
private static readonly AttachedProperty<Avalonia.Controls.GridLength?> LastWidthProperty = AvaloniaProperty.RegisterAttached<Avalonia.Controls.ColumnDefinition, Avalonia.Controls.GridLength?>("LastWidth", typeof(ColumnDefinition), default);
|
||||
|
||||
public static bool GetIsVisible(Avalonia.Controls.ColumnDefinition columnDefinition)
|
||||
{
|
||||
return columnDefinition.GetValue(IsVisibleProperty);
|
||||
}
|
||||
|
||||
public static void SetIsVisible(Avalonia.Controls.ColumnDefinition columnDefinition, bool visibility)
|
||||
{
|
||||
_ = columnDefinition.SetValue(IsVisibleProperty, visibility);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Markdowser.Utilities;
|
||||
@@ -33,6 +36,8 @@ internal static class GlobalState
|
||||
}
|
||||
}
|
||||
|
||||
public static ObservableCollection<TabItem> Tabs { get; internal set; } = [new TabItem() { Header = "New Tab" }];
|
||||
|
||||
internal static void SetUrl(object sender, string url)
|
||||
{
|
||||
GlobalState.url = url;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Avalonia.Platform;
|
||||
|
||||
using Markdown.Avalonia.Utils;
|
||||
|
||||
using Markdowser.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
using Markdowser.Utilities;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using HtmlAgilityPack;
|
||||
|
||||
using Markdowser.Models;
|
||||
using Markdowser.Utilities;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
@@ -21,13 +28,33 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
private readonly HttpClient httpClient = new(new HttpClientHandler() { AllowAutoRedirect = true });
|
||||
private readonly ReverseMarkdown.Converter markdownConverter = new();
|
||||
|
||||
private readonly StringBuilder html = new();
|
||||
private StringBuilder? content;
|
||||
|
||||
private int currentTabIndex;
|
||||
private bool showSidePanel;
|
||||
private bool isBusy;
|
||||
|
||||
private int progress;
|
||||
public ObservableCollection<TabItem> Tabs => GlobalState.Tabs;
|
||||
public string Title => $"{nameof(Markdowser)} - {Assembly.GetExecutingAssembly().GetName().Version?.ToString()}";
|
||||
|
||||
public int CurrentTabIndex
|
||||
{
|
||||
get => currentTabIndex;
|
||||
set
|
||||
{
|
||||
if (CurrentTab is not null)
|
||||
{
|
||||
CurrentTab.Tag = Url;
|
||||
}
|
||||
|
||||
_ = this.RaiseAndSetIfChanged(ref currentTabIndex, value);
|
||||
|
||||
Url = CurrentTab?.Tag?.ToString() ?? string.Empty;
|
||||
|
||||
FetchUrl();
|
||||
}
|
||||
}
|
||||
|
||||
public StringBuilder Content
|
||||
{
|
||||
get => content ?? DefaultContent;
|
||||
@@ -40,6 +67,12 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
set => GlobalState.SetUrl(this, value);
|
||||
}
|
||||
|
||||
public bool ShowSidePanel
|
||||
{
|
||||
get => showSidePanel;
|
||||
set => this.RaiseAndSetIfChanged(ref showSidePanel, value);
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => isBusy;
|
||||
@@ -56,12 +89,13 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsViewModel SettingsViewModel => new SettingsViewModel();
|
||||
public RawHtmlViewModel RawHtmlViewModel => new RawHtmlViewModel(html);
|
||||
public RawMarkdownViewModel RawMarkdownViewModel => new RawMarkdownViewModel(() => Content);
|
||||
public bool CloseTabEnabled => Tabs.Count > 1;
|
||||
public bool BackEnabled => GlobalState.BackHistory.Count > 0;
|
||||
|
||||
public bool ForwardEnabled => GlobalState.ForwardHistory.Count > 0;
|
||||
|
||||
public bool ProgressIndeterminate => Progress == 0;
|
||||
|
||||
public ICommand Browse => ReactiveCommand.Create(FetchUrl);
|
||||
|
||||
public ICommand Back => ReactiveCommand.Create(() =>
|
||||
@@ -90,6 +124,27 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
});
|
||||
|
||||
public ICommand ToggleSidePanel => ReactiveCommand.Create(() => ShowSidePanel = !ShowSidePanel);
|
||||
|
||||
public ICommand CloseTab => ReactiveCommand.Create(() =>
|
||||
{
|
||||
if (Tabs.Count > 1 && Tabs.Remove(CurrentTab))
|
||||
{
|
||||
CurrentTabIndex = Math.Max(0, CurrentTabIndex - 1);
|
||||
this.RaisePropertyChanged(nameof(CloseTabEnabled));
|
||||
}
|
||||
});
|
||||
|
||||
public ICommand NewTab => ReactiveCommand.Create(() =>
|
||||
{
|
||||
TabItem tab = new() { Header = "New Tab", Name = Guid.NewGuid().ToString() };
|
||||
Tabs.Add(tab);
|
||||
CurrentTabIndex = Tabs.Count - 1;
|
||||
this.RaisePropertyChanged(nameof(CloseTabEnabled));
|
||||
});
|
||||
|
||||
private TabItem CurrentTab => Tabs[CurrentTabIndex];
|
||||
|
||||
private StringBuilder DefaultContent => new StringBuilder()
|
||||
.AppendLine($"}-Transparent.png)")
|
||||
.AppendLine()
|
||||
@@ -139,8 +194,10 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
if (string.IsNullOrWhiteSpace(Url))
|
||||
{
|
||||
content = null;
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
_ = html.Clear();
|
||||
ContentChanged();
|
||||
Debug.WriteLine("URL is empty.");
|
||||
CurrentTab.Header = "New Tab";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,6 +209,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
|
||||
content ??= new StringBuilder();
|
||||
_ = content.Clear();
|
||||
_ = html.Clear();
|
||||
|
||||
IsBusy = true;
|
||||
Progress = 0;
|
||||
@@ -160,8 +218,6 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
Debug.WriteLine("Fetching URL...");
|
||||
|
||||
StringBuilder html = new();
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(Url);
|
||||
@@ -173,7 +229,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
IsBusy = false;
|
||||
_ = content.AppendLine($"# {(int)httpResponseMessage.StatusCode} {httpResponseMessage.StatusCode}");
|
||||
_ = content.AppendLine($"Failed to fetch URL: {httpResponseMessage.ReasonPhrase}");
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
ContentChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,6 +243,15 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
_ = html.AppendLine(await streamReader.ReadLineAsync());
|
||||
Progress = (int)((double)contentStream.Position / length * 100);
|
||||
}
|
||||
|
||||
HtmlDocument htmlDoc = new HtmlDocument();
|
||||
htmlDoc.LoadHtml(html.ToString());
|
||||
string title = htmlDoc.DocumentNode.SelectSingleNode("html/head/title")?.InnerText ?? Url;
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
CurrentTab.Header = title?.Trim() ?? Url;
|
||||
});
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
@@ -199,16 +264,18 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
|
||||
_ = content.AppendLine($"# {e.HttpRequestError}");
|
||||
_ = content.AppendLine($"Failed to fetch URL: {e.Message}");
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
ContentChanged();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
IsBusy = false;
|
||||
_ = content.AppendLine($"# {e.GetType().Name}");
|
||||
_ = content.AppendLine($"Failed to fetch URL: {e.Message}");
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
ContentChanged();
|
||||
}
|
||||
|
||||
Progress = 0;
|
||||
|
||||
Debug.WriteLine("Converting HTML to markdown...");
|
||||
|
||||
string markdown = markdownConverter.Convert(html.ToString());
|
||||
@@ -240,14 +307,18 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
_ = content.AppendLine(trimmedLine);
|
||||
|
||||
//this.RaisePropertyChanged(nameof(Content));
|
||||
}
|
||||
|
||||
Debug.WriteLine("Done processing.");
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
ContentChanged();
|
||||
|
||||
IsBusy = false;
|
||||
});
|
||||
}
|
||||
|
||||
private void ContentChanged()
|
||||
{
|
||||
this.RaisePropertyChanged(nameof(Content));
|
||||
this.RaisePropertyChanged(nameof(RawHtmlViewModel));
|
||||
this.RaisePropertyChanged(nameof(RawMarkdownViewModel));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Markdowser.ViewModels;
|
||||
|
||||
public class RawHtmlViewModel(StringBuilder html) : ViewModelBase
|
||||
{
|
||||
public StringBuilder Html => html;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Markdowser.ViewModels;
|
||||
|
||||
public class RawMarkdownViewModel(Func<StringBuilder> markdown) : ViewModelBase
|
||||
{
|
||||
public StringBuilder Markdown => markdown();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Markdowser.Models;
|
||||
|
||||
namespace Markdowser.ViewModels;
|
||||
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
public string? HomeUrl
|
||||
{
|
||||
get => Settings.Current.HomeUrl;
|
||||
set => Settings.Current.HomeUrl = value;
|
||||
}
|
||||
|
||||
public bool DarkMode
|
||||
{
|
||||
get => Settings.Current.DarkMode;
|
||||
set => Settings.Current.DarkMode = value;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Markdowser.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Icon="/Assets/Markdowser-Light-Transparent.ico"
|
||||
Title="{Binding Title}">
|
||||
|
||||
<Design.DataContext>
|
||||
@@ -33,15 +33,21 @@
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid RowDefinitions="Auto, *, Auto">
|
||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto">
|
||||
<TabControl Grid.Column="0" Theme="{DynamicResource ScrollTabControl}" SelectedIndex="{Binding CurrentTabIndex, Mode=TwoWay}" ItemsSource="{Binding Tabs}" />
|
||||
<Button Grid.Column="1" Command="{Binding CloseTab}" IsEnabled="{Binding CloseTabEnabled}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="32" i:Attached.Icon="fa-solid fa-xmark" />
|
||||
<Button Grid.Column="2" Command="{Binding NewTab}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="32" i:Attached.Icon="fa-solid fa-plus" />
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*, 4, *" Grid.Row="1">
|
||||
<md:MarkdownScrollViewer Margin="10" IsEnabled="{Binding !IsBusy}" Markdown="{Binding Content}">
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" utils:ColumnDefinition.IsVisible="{Binding ShowSidePanel}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<md:MarkdownScrollViewer Margin="10 0 10 10" IsEnabled="{Binding !IsBusy}" Markdown="{Binding Content}">
|
||||
<md:MarkdownScrollViewer.Styles>
|
||||
<Style Selector="ctxt|CTextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}" />
|
||||
@@ -83,29 +89,34 @@
|
||||
<md:MdAvPlugins PathResolver="{StaticResource HttpPathResolver}" HyperlinkCommand="{StaticResource HyperlinkCommand}" />
|
||||
</md:MarkdownScrollViewer.Plugins>
|
||||
</md:MarkdownScrollViewer>
|
||||
<GridSplitter Grid.Column="1" Background="{DynamicResource SemiColorTertiary}" ResizeDirection="Columns" />
|
||||
<ScrollViewer Grid.Column="2" Margin="10">
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Content}" />
|
||||
</ScrollViewer>
|
||||
<GridSplitter Grid.Column="1" IsVisible="{Binding ShowSidePanel}" Background="{DynamicResource SemiColorTertiary}" ResizeDirection="Columns" />
|
||||
<TabControl Grid.Column="2" IsVisible="{Binding ShowSidePanel}" Margin="10">
|
||||
<TabItem Header="Settings">
|
||||
<ScrollViewer>
|
||||
<ContentControl Margin="0 10 0 0" Content="{Binding SettingsViewModel}" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="Markdown">
|
||||
<ScrollViewer>
|
||||
<ContentControl Margin="0 10 0 0" Content="{Binding RawMarkdownViewModel}" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="HTML">
|
||||
<ScrollViewer>
|
||||
<ContentControl Margin="0 10 0 0" Content="{Binding RawHtmlViewModel}" />
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="2" BorderThickness="0 2 0 0" CornerRadius="0" BorderBrush="{DynamicResource SemiColorTertiary}">
|
||||
<Grid>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid ColumnDefinitions="Auto, Auto, Auto, Auto, *, Auto">
|
||||
<Button Grid.Column="0" i:Attached.Icon="fa-solid fa-caret-left" IsEnabled="{Binding BackEnabled}" Command="{Binding Back}" />
|
||||
<Button Grid.Column="1" i:Attached.Icon="fa-solid fa-caret-right" IsEnabled="{Binding ForwardEnabled}" Command="{Binding Forward}" />
|
||||
<Button Grid.Column="2" i:Attached.Icon="fa-solid fa-house" Command="{StaticResource HomeCommand}" />
|
||||
<Button Grid.Column="2" i:Attached.Icon="fa-solid fa-rotate-right" Command="{Binding Browse}" />
|
||||
<Button Grid.Column="3" i:Attached.Icon="fa-solid fa-house" Command="{StaticResource HomeCommand}" />
|
||||
|
||||
<Grid Grid.Column="3">
|
||||
<Grid Grid.Column="4">
|
||||
<TextBox x:Name="urlBar" IsVisible="{Binding !IsBusy}" Watermark="Search DuckDuckGo or type a URL" Text="{Binding Url}" BorderThickness="0">
|
||||
<TextBox.KeyBindings>
|
||||
<KeyBinding Gesture="Enter" Command="{Binding Browse}" />
|
||||
@@ -120,8 +131,7 @@
|
||||
<ProgressBar IsVisible="{Binding IsBusy}" IsIndeterminate="{Binding ProgressIndeterminate}" ShowProgressText="{Binding !ProgressIndeterminate}" Maximum="100" Height="32" Grid.Row="2" Value="{Binding Progress}" />
|
||||
</Grid>
|
||||
|
||||
<Button Grid.Column="4" Command="{StaticResource ChangeThemeCommand}" i:Attached.Icon="fa-solid fa-moon" />
|
||||
<Button Grid.Column="5" HorizontalAlignment="Right" i:Attached.Icon="fa-solid fa-cog" />
|
||||
<Button Grid.Column="5" Command="{Binding ToggleSidePanel}" HorizontalAlignment="Right" i:Attached.Icon="fa-solid fa-table-columns" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Markdowser.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:DataType="vm:RawHtmlViewModel"
|
||||
x:Class="Markdowser.Views.RawHtmlView">
|
||||
<SelectableTextBlock Text="{Binding Html}" TextWrapping="Wrap" />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Markdowser.Views;
|
||||
|
||||
public partial class RawHtmlView : UserControl
|
||||
{
|
||||
public RawHtmlView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Markdowser.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:DataType="vm:RawMarkdownViewModel"
|
||||
x:Class="Markdowser.Views.RawMarkdownView">
|
||||
<SelectableTextBlock Text="{Binding Markdown}" TextWrapping="Wrap" />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Markdowser.Views;
|
||||
|
||||
public partial class RawMarkdownView : UserControl
|
||||
{
|
||||
public RawMarkdownView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:vm="using:Markdowser.ViewModels"
|
||||
xmlns:cmd="using:Markdowser.Commands"
|
||||
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"
|
||||
xmlns:i="https://github.com/projektanker/icons.avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:DataType="vm:SettingsViewModel"
|
||||
x:Class="Markdowser.Views.SettingsView">
|
||||
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<cmd:ChangeThemeCommand x:Key="ChangeThemeCommand" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Dark Mode" />
|
||||
<ToggleSwitch IsChecked="{Binding DarkMode}" Command="{StaticResource ChangeThemeCommand}" />
|
||||
|
||||
<TextBlock Text="Home URL" />
|
||||
<TextBox Text="{Binding HomeUrl}" Watermark="URL, or leave empty to use default" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Markdowser.Views;
|
||||
|
||||
public partial class SettingsView : UserControl
|
||||
{
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user