Skip to content

Commit 66ac78f

Browse files
committed
Thread safety fixes and text rendering improvements
- 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
1 parent 55db68e commit 66ac78f

File tree

61 files changed

+1658
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1658
-582
lines changed
0 Bytes
Binary file not shown.

Output/SharpVectors.Core.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Css.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Dom.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Model.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Rendering.Gdi.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Rendering.Wpf.dll

0 Bytes
Binary file not shown.

Output/SharpVectors.Runtime.Wpf.dll

0 Bytes
Binary file not shown.

Samples/WpfSvgTestBox/DebugPage.xaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
67
xmlns:local="clr-namespace:WpfSvgTestBox"
78
mc:Ignorable="d"
89
d:DesignHeight="450" d:DesignWidth="800" Title="DebugPage">
910
<DockPanel LastChildFill="True">
10-
<RichTextBox x:Name="debugBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" IsReadOnly="True" AllowDrop="False" VerticalScrollBarVisibility="Auto" IsUndoEnabled="False" HorizontalScrollBarVisibility="Auto">
11+
<!--<RichTextBox x:Name="debugBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10"
12+
IsReadOnly="True" AllowDrop="False" VerticalScrollBarVisibility="Auto"
13+
IsUndoEnabled="False" HorizontalScrollBarVisibility="Auto">
1114
<local:TraceDocument x:Name="traceDocument"/>
12-
</RichTextBox>
15+
</RichTextBox>-->
16+
17+
<avalonEdit:TextEditor x:Name="textEditor" FontFamily="Consolas" FontSize="12pt"/>
1318
</DockPanel>
1419
</Page>
+55-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
using System.Windows.Controls;
45

@@ -7,28 +8,77 @@ namespace WpfSvgTestBox
78
/// <summary>
89
/// Interaction logic for DebugPage.xaml
910
/// </summary>
10-
public partial class DebugPage : Page
11+
public partial class DebugPage : Page, ITraceTextSink
1112
{
13+
private delegate void AppendTextDelegate(string msg, string style);
14+
15+
private TraceListener _listener;
16+
1217
public DebugPage()
1318
{
1419
InitializeComponent();
20+
21+
textEditor.IsReadOnly = true;
22+
23+
Trace.UseGlobalLock = true;
24+
25+
_listener = new TraceTextSource(this);
26+
Trace.Listeners.Add(_listener);
1527
}
1628

1729
public void Startup()
1830
{
19-
if (traceDocument != null)
31+
if (_listener == null)
2032
{
21-
traceDocument.Startup();
33+
_listener = new TraceTextSource(this);
34+
Trace.Listeners.Add(_listener);
2235
}
36+
37+
Trace.WriteLine("Startup");
2338
}
2439

2540
public void Shutdown()
2641
{
27-
if (traceDocument != null)
42+
Trace.WriteLine("Shutdown");
43+
if (_listener != null)
2844
{
29-
traceDocument.Shutdown();
45+
Trace.Listeners.Remove(_listener);
46+
_listener.Dispose();
47+
_listener = null;
3048
}
3149
}
3250

51+
public void Event(string msg, TraceEventType eventType)
52+
{
53+
Append(msg, eventType.ToString());
54+
}
55+
56+
public void Fail(string msg)
57+
{
58+
Append(msg, "Fail");
59+
}
60+
61+
private void Append(string msg, string style)
62+
{
63+
if (Dispatcher.CheckAccess())
64+
{
65+
if (!this.IsLoaded)
66+
{
67+
return;
68+
}
69+
if (string.IsNullOrWhiteSpace(style))
70+
{
71+
textEditor.AppendText(msg + Environment.NewLine);
72+
}
73+
else
74+
{
75+
textEditor.AppendText(style + ": " + msg + Environment.NewLine);
76+
}
77+
}
78+
else
79+
{
80+
Dispatcher.Invoke(new AppendTextDelegate(Append), msg, style);
81+
}
82+
}
3383
}
3484
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

Samples/WpfTestThreadSafety/App.ico

172 KB
Binary file not shown.

Samples/WpfTestThreadSafety/App.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="WpfTestThreadSafety.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:WpfTestThreadSafety"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace WpfTestThreadSafety
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<Window x:Class="WpfTestThreadSafety.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:WpfTestThreadSafety"
7+
mc:Ignorable="d"
8+
Title="SharpVectors: WpfTestThreadSafety" Height="860" Width="900" WindowStartupLocation="CenterScreen" Closed="OnWindowClosed" Closing="OnWindowClosing" Loaded="OnWindowLoaded" Icon="App.ico">
9+
<DockPanel LastChildFill="True" Margin="6">
10+
<DockPanel LastChildFill="True" DockPanel.Dock="Top" HorizontalAlignment="Stretch">
11+
<Label DockPanel.Dock="Left">Svg Files Source: </Label>
12+
<Button x:Name="btnStart" Width="60" DockPanel.Dock="Right" Click="OnStartClick">Start</Button>
13+
<TextBox x:Name="txtSvgSource" HorizontalAlignment="Stretch" Margin="4 0 4 0"></TextBox>
14+
</DockPanel>
15+
<DockPanel LastChildFill="True">
16+
<CheckBox x:Name="chkVerbose" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="6">Verbose</CheckBox>
17+
<TextBox x:Name="txtDebug" Margin="4" IsReadOnly="True" Height="150" HorizontalScrollBarVisibility="Auto"
18+
VerticalScrollBarVisibility="Auto" Background="White" DockPanel.Dock="Bottom"></TextBox>
19+
20+
<ListView x:Name="ImageView" ItemsSource="{Binding Path=ImageList}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
21+
Background="LightGray" ScrollViewer.HorizontalScrollBarVisibility="Disabled" VerticalContentAlignment="Center" Margin="4">
22+
<ListView.ItemContainerStyle>
23+
<Style TargetType="{x:Type ListViewItem}">
24+
<Setter Property="Template">
25+
<Setter.Value>
26+
<ControlTemplate TargetType="{x:Type ListViewItem}">
27+
<Border Background="White"
28+
CornerRadius="8"
29+
BorderThickness="6"
30+
x:Name="IconBorder"
31+
Margin="8,4,8,4" >
32+
<ContentPresenter />
33+
</Border>
34+
<ControlTemplate.Triggers>
35+
<Trigger Property="IsSelected" Value="true">
36+
<Setter TargetName="IconBorder" Property="BitmapEffect">
37+
<Setter.Value>
38+
<OuterGlowBitmapEffect GlowSize="10" GlowColor="DeepSkyBlue"/>
39+
</Setter.Value>
40+
</Setter>
41+
<Setter TargetName="IconBorder" Property="BorderBrush" Value="DeepSkyBlue"/>
42+
<Setter TargetName="IconBorder" Property="BorderThickness" Value="6"/>
43+
</Trigger>
44+
</ControlTemplate.Triggers>
45+
</ControlTemplate>
46+
</Setter.Value>
47+
</Setter>
48+
</Style>
49+
</ListView.ItemContainerStyle>
50+
<ItemsControl.ItemsPanel>
51+
<ItemsPanelTemplate>
52+
<WrapPanel Orientation="Horizontal"/>
53+
</ItemsPanelTemplate>
54+
</ItemsControl.ItemsPanel>
55+
<ListView.ItemTemplate>
56+
<DataTemplate>
57+
<StackPanel Margin="8,8,8,8" Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
58+
<Image Source="{Binding Path=Image}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" Width="120" Height="120" />
59+
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="120" />
60+
</StackPanel>
61+
</DataTemplate>
62+
</ListView.ItemTemplate>
63+
</ListView>
64+
</DockPanel>
65+
</DockPanel>
66+
</Window>

0 commit comments

Comments
 (0)