Skip to content

Commit

Permalink
Thread safety fixes and text rendering improvements
Browse files Browse the repository at this point in the history
- Renamed some long name folders
- Added support for textArea element for Tiny 1.2 specs
- WPF Rendering: Fixed thread safety issues as reported in #115
- Added WpfTestThreadSafety to test threading support. Codes by @astarche @atmgrifter00
  • Loading branch information
paulushub committed Oct 26, 2019
1 parent 55db68e commit 66ac78f
Show file tree
Hide file tree
Showing 61 changed files with 1,658 additions and 582 deletions.
Binary file modified Output/SharpVectors.Converters.Wpf.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Core.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Css.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Dom.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Model.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Rendering.Gdi.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Rendering.Wpf.dll
Binary file not shown.
Binary file modified Output/SharpVectors.Runtime.Wpf.dll
Binary file not shown.
9 changes: 7 additions & 2 deletions Samples/WpfSvgTestBox/DebugPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:local="clr-namespace:WpfSvgTestBox"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Title="DebugPage">
<DockPanel LastChildFill="True">
<RichTextBox x:Name="debugBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" IsReadOnly="True" AllowDrop="False" VerticalScrollBarVisibility="Auto" IsUndoEnabled="False" HorizontalScrollBarVisibility="Auto">
<!--<RichTextBox x:Name="debugBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10"
IsReadOnly="True" AllowDrop="False" VerticalScrollBarVisibility="Auto"
IsUndoEnabled="False" HorizontalScrollBarVisibility="Auto">
<local:TraceDocument x:Name="traceDocument"/>
</RichTextBox>
</RichTextBox>-->

<avalonEdit:TextEditor x:Name="textEditor" FontFamily="Consolas" FontSize="12pt"/>
</DockPanel>
</Page>
60 changes: 55 additions & 5 deletions Samples/WpfSvgTestBox/DebugPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;

using System.Windows.Controls;

Expand All @@ -7,28 +8,77 @@ namespace WpfSvgTestBox
/// <summary>
/// Interaction logic for DebugPage.xaml
/// </summary>
public partial class DebugPage : Page
public partial class DebugPage : Page, ITraceTextSink
{
private delegate void AppendTextDelegate(string msg, string style);

private TraceListener _listener;

public DebugPage()
{
InitializeComponent();

textEditor.IsReadOnly = true;

Trace.UseGlobalLock = true;

_listener = new TraceTextSource(this);
Trace.Listeners.Add(_listener);
}

public void Startup()
{
if (traceDocument != null)
if (_listener == null)
{
traceDocument.Startup();
_listener = new TraceTextSource(this);
Trace.Listeners.Add(_listener);
}

Trace.WriteLine("Startup");
}

public void Shutdown()
{
if (traceDocument != null)
Trace.WriteLine("Shutdown");
if (_listener != null)
{
traceDocument.Shutdown();
Trace.Listeners.Remove(_listener);
_listener.Dispose();
_listener = null;
}
}

public void Event(string msg, TraceEventType eventType)
{
Append(msg, eventType.ToString());
}

public void Fail(string msg)
{
Append(msg, "Fail");
}

private void Append(string msg, string style)
{
if (Dispatcher.CheckAccess())
{
if (!this.IsLoaded)
{
return;
}
if (string.IsNullOrWhiteSpace(style))
{
textEditor.AppendText(msg + Environment.NewLine);
}
else
{
textEditor.AppendText(style + ": " + msg + Environment.NewLine);
}
}
else
{
Dispatcher.Invoke(new AppendTextDelegate(Append), msg, style);
}
}
}
}
6 changes: 6 additions & 0 deletions Samples/WpfTestThreadSafety/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Binary file added Samples/WpfTestThreadSafety/App.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions Samples/WpfTestThreadSafety/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="WpfTestThreadSafety.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfTestThreadSafety"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions Samples/WpfTestThreadSafety/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace WpfTestThreadSafety
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
66 changes: 66 additions & 0 deletions Samples/WpfTestThreadSafety/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<Window x:Class="WpfTestThreadSafety.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:WpfTestThreadSafety"
mc:Ignorable="d"
Title="SharpVectors: WpfTestThreadSafety" Height="860" Width="900" WindowStartupLocation="CenterScreen" Closed="OnWindowClosed" Closing="OnWindowClosing" Loaded="OnWindowLoaded" Icon="App.ico">
<DockPanel LastChildFill="True" Margin="6">
<DockPanel LastChildFill="True" DockPanel.Dock="Top" HorizontalAlignment="Stretch">
<Label DockPanel.Dock="Left">Svg Files Source: </Label>
<Button x:Name="btnStart" Width="60" DockPanel.Dock="Right" Click="OnStartClick">Start</Button>
<TextBox x:Name="txtSvgSource" HorizontalAlignment="Stretch" Margin="4 0 4 0"></TextBox>
</DockPanel>
<DockPanel LastChildFill="True">
<CheckBox x:Name="chkVerbose" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="6">Verbose</CheckBox>
<TextBox x:Name="txtDebug" Margin="4" IsReadOnly="True" Height="150" HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto" Background="White" DockPanel.Dock="Bottom"></TextBox>

<ListView x:Name="ImageView" ItemsSource="{Binding Path=ImageList}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Background="LightGray" ScrollViewer.HorizontalScrollBarVisibility="Disabled" VerticalContentAlignment="Center" Margin="4">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Background="White"
CornerRadius="8"
BorderThickness="6"
x:Name="IconBorder"
Margin="8,4,8,4" >
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="IconBorder" Property="BitmapEffect">
<Setter.Value>
<OuterGlowBitmapEffect GlowSize="10" GlowColor="DeepSkyBlue"/>
</Setter.Value>
</Setter>
<Setter TargetName="IconBorder" Property="BorderBrush" Value="DeepSkyBlue"/>
<Setter TargetName="IconBorder" Property="BorderThickness" Value="6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="8,8,8,8" Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Image Source="{Binding Path=Image}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" Width="120" Height="120" />
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="120" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DockPanel>
</DockPanel>
</Window>
Loading

0 comments on commit 66ac78f

Please sign in to comment.