mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
ux: use AvaloniaEdit.TextEditor
to display release update detail info
Some checks failed
Some checks failed
This commit is contained in:
parent
c6afc6a205
commit
8ebf4d76d6
2 changed files with 69 additions and 7 deletions
|
@ -52,13 +52,13 @@
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBox IsReadOnly="True"
|
<Border Width="500" MaxHeight="400"
|
||||||
TextWrapping="Wrap"
|
Margin="0,8"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
Background="{DynamicResource Brush.Contents}"
|
||||||
MaxWidth="500" MaxHeight="400"
|
BorderThickness="1"
|
||||||
Margin="0,8" Padding="0"
|
BorderBrush="{DynamicResource Brush.Border2}">
|
||||||
VerticalContentAlignment="Top"
|
<v:UpdateInfoView/>
|
||||||
Text="{Binding Body}"/>
|
</Border>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
<Button Classes="flat primary"
|
<Button Classes="flat primary"
|
||||||
|
|
|
@ -1,8 +1,70 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
|
||||||
|
using AvaloniaEdit.Document;
|
||||||
|
using AvaloniaEdit.Editing;
|
||||||
|
using AvaloniaEdit.TextMate;
|
||||||
|
using AvaloniaEdit;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
|
public class UpdateInfoView : TextEditor
|
||||||
|
{
|
||||||
|
protected override Type StyleKeyOverride => typeof(TextEditor);
|
||||||
|
|
||||||
|
public UpdateInfoView() : base(new TextArea(), new TextDocument())
|
||||||
|
{
|
||||||
|
IsReadOnly = true;
|
||||||
|
ShowLineNumbers = false;
|
||||||
|
WordWrap = true;
|
||||||
|
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
|
||||||
|
VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||||
|
|
||||||
|
TextArea.TextView.Margin = new Thickness(4, 0);
|
||||||
|
TextArea.TextView.Options.EnableHyperlinks = false;
|
||||||
|
TextArea.TextView.Options.EnableEmailHyperlinks = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnLoaded(RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnLoaded(e);
|
||||||
|
|
||||||
|
if (_textMate == null)
|
||||||
|
{
|
||||||
|
_textMate = Models.TextMateHelper.CreateForEditor(this);
|
||||||
|
Models.TextMateHelper.SetGrammarByFileName(_textMate, "README.md");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnUnloaded(RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnUnloaded(e);
|
||||||
|
|
||||||
|
if (_textMate != null)
|
||||||
|
{
|
||||||
|
_textMate.Dispose();
|
||||||
|
_textMate = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
GC.Collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDataContextChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDataContextChanged(e);
|
||||||
|
|
||||||
|
if (DataContext is Models.Version ver)
|
||||||
|
Text = ver.Body;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextMate.Installation _textMate = null;
|
||||||
|
}
|
||||||
|
|
||||||
public partial class SelfUpdate : ChromelessWindow
|
public partial class SelfUpdate : ChromelessWindow
|
||||||
{
|
{
|
||||||
public SelfUpdate()
|
public SelfUpdate()
|
||||||
|
|
Loading…
Reference in a new issue