Skip to content

Commit 11f43c8

Browse files
committed
ClipArtViewer: restoring the original sample for directory browsing.
- Added the sample viewer, ClipArtViewer, with bug fixes and code improvements. - Added error logging to ClipArtViewer, some samples are throwing exceptions. - Modified other sample applications. Used tab control to split samples in Example.
1 parent 320daae commit 11f43c8

Some content is hidden

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

58 files changed

+1815
-29
lines changed

Docs/sample.png

-259 KB
Loading

Samples/ClipArtViewer/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="ClipArtViewer.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>

Samples/ClipArtViewer/App.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Windows;
7+
8+
namespace ClipArtViewer
9+
{
10+
/// <summary>
11+
/// Interaction logic for App.xaml
12+
/// </summary>
13+
public partial class App : Application
14+
{
15+
}
16+
}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{16D74531-7F85-4384-BF5A-3C0A9A5D4F3E}</ProjectGuid>
9+
<OutputType>WinExe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ClipArtViewer</RootNamespace>
12+
<AssemblyName>ClipArtViewer</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16+
<WarningLevel>4</WarningLevel>
17+
<SccProjectName>SAK</SccProjectName>
18+
<SccLocalPath>SAK</SccLocalPath>
19+
<SccAuxPath>SAK</SccAuxPath>
20+
<SccProvider>SAK</SccProvider>
21+
<FileUpgradeFlags>
22+
</FileUpgradeFlags>
23+
<UpgradeBackupLocation>
24+
</UpgradeBackupLocation>
25+
<OldToolsVersion>3.5</OldToolsVersion>
26+
<PublishUrl>publish\</PublishUrl>
27+
<Install>true</Install>
28+
<InstallFrom>Disk</InstallFrom>
29+
<UpdateEnabled>false</UpdateEnabled>
30+
<UpdateMode>Foreground</UpdateMode>
31+
<UpdateInterval>7</UpdateInterval>
32+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
33+
<UpdatePeriodically>false</UpdatePeriodically>
34+
<UpdateRequired>false</UpdateRequired>
35+
<MapFileExtensions>true</MapFileExtensions>
36+
<ApplicationRevision>0</ApplicationRevision>
37+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
38+
<IsWebBootstrapper>false</IsWebBootstrapper>
39+
<UseApplicationTrust>false</UseApplicationTrust>
40+
<BootstrapperEnabled>true</BootstrapperEnabled>
41+
<TargetFrameworkProfile />
42+
</PropertyGroup>
43+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
44+
<DebugSymbols>true</DebugSymbols>
45+
<DebugType>full</DebugType>
46+
<Optimize>false</Optimize>
47+
<OutputPath>Output\</OutputPath>
48+
<DefineConstants>DEBUG;TRACE</DefineConstants>
49+
<ErrorReport>prompt</ErrorReport>
50+
<WarningLevel>4</WarningLevel>
51+
</PropertyGroup>
52+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
53+
<DebugType>pdbonly</DebugType>
54+
<Optimize>true</Optimize>
55+
<OutputPath>Output\</OutputPath>
56+
<DefineConstants>TRACE</DefineConstants>
57+
<ErrorReport>prompt</ErrorReport>
58+
<WarningLevel>4</WarningLevel>
59+
</PropertyGroup>
60+
<PropertyGroup>
61+
<ApplicationIcon>ClipArtViewer.ico</ApplicationIcon>
62+
</PropertyGroup>
63+
<ItemGroup>
64+
<Reference Include="System" />
65+
<Reference Include="System.Core">
66+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
67+
</Reference>
68+
<Reference Include="System.Drawing" />
69+
<Reference Include="System.Windows.Forms" />
70+
<Reference Include="System.Xaml" />
71+
<Reference Include="System.Xml.Linq">
72+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
73+
</Reference>
74+
<Reference Include="System.Data.DataSetExtensions">
75+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
76+
</Reference>
77+
<Reference Include="System.Data" />
78+
<Reference Include="System.Xml" />
79+
<Reference Include="WindowsBase" />
80+
<Reference Include="PresentationCore" />
81+
<Reference Include="PresentationFramework" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<ApplicationDefinition Include="App.xaml">
85+
<Generator>MSBuild:Compile</Generator>
86+
<SubType>Designer</SubType>
87+
<Generator>MSBuild:Compile</Generator>
88+
<SubType>Designer</SubType>
89+
</ApplicationDefinition>
90+
<Page Include="DebugForm.xaml">
91+
<Generator>MSBuild:Compile</Generator>
92+
<SubType>Designer</SubType>
93+
</Page>
94+
<Page Include="FullSizeForm.xaml">
95+
<Generator>MSBuild:Compile</Generator>
96+
<SubType>Designer</SubType>
97+
</Page>
98+
<Page Include="MainWindow.xaml">
99+
<SubType>Designer</SubType>
100+
<Generator>MSBuild:Compile</Generator>
101+
</Page>
102+
<Page Include="SizeTypeForm.xaml">
103+
<SubType>Designer</SubType>
104+
<Generator>MSBuild:Compile</Generator>
105+
</Page>
106+
<Compile Include="App.xaml.cs">
107+
<DependentUpon>App.xaml</DependentUpon>
108+
<SubType>Code</SubType>
109+
</Compile>
110+
<Compile Include="SVGObjectTree.cs" />
111+
<Compile Include="SVGViewCanvas.cs" />
112+
<Compile Include="DebugForm.xaml.cs">
113+
<DependentUpon>DebugForm.xaml</DependentUpon>
114+
</Compile>
115+
<Compile Include="FullSizeForm.xaml.cs">
116+
<DependentUpon>FullSizeForm.xaml</DependentUpon>
117+
</Compile>
118+
<Compile Include="MainWindow.xaml.cs">
119+
<DependentUpon>MainWindow.xaml</DependentUpon>
120+
</Compile>
121+
<Compile Include="SizeTypeForm.xaml.cs">
122+
<DependentUpon>SizeTypeForm.xaml</DependentUpon>
123+
</Compile>
124+
</ItemGroup>
125+
<ItemGroup>
126+
<Compile Include="Properties\AssemblyInfo.cs">
127+
<SubType>Code</SubType>
128+
</Compile>
129+
<Compile Include="Properties\Resources.Designer.cs">
130+
<AutoGen>True</AutoGen>
131+
<DesignTime>True</DesignTime>
132+
<DependentUpon>Resources.resx</DependentUpon>
133+
</Compile>
134+
<Compile Include="Properties\Settings.Designer.cs">
135+
<AutoGen>True</AutoGen>
136+
<DependentUpon>Settings.settings</DependentUpon>
137+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
138+
</Compile>
139+
<EmbeddedResource Include="Properties\Resources.resx">
140+
<Generator>ResXFileCodeGenerator</Generator>
141+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
142+
</EmbeddedResource>
143+
<None Include="app.config" />
144+
<None Include="Properties\Settings.settings">
145+
<Generator>SettingsSingleFileGenerator</Generator>
146+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
147+
</None>
148+
<AppDesigner Include="Properties\" />
149+
</ItemGroup>
150+
<ItemGroup>
151+
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
152+
<Visible>False</Visible>
153+
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
154+
<Install>false</Install>
155+
</BootstrapperPackage>
156+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
157+
<Visible>False</Visible>
158+
<ProductName>.NET Framework 3.5 SP1</ProductName>
159+
<Install>true</Install>
160+
</BootstrapperPackage>
161+
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
162+
<Visible>False</Visible>
163+
<ProductName>Windows Installer 3.1</ProductName>
164+
<Install>true</Install>
165+
</BootstrapperPackage>
166+
</ItemGroup>
167+
<ItemGroup>
168+
<ProjectReference Include="..\..\Source\SVGImage\DotNetProjects.SVGImage.csproj">
169+
<Project>{5569522d-5c29-451e-8730-f119f0408bca}</Project>
170+
<Name>DotNetProjects.SVGImage</Name>
171+
</ProjectReference>
172+
</ItemGroup>
173+
<ItemGroup>
174+
<Resource Include="ClipArtViewer.ico" />
175+
</ItemGroup>
176+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
177+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
178+
Other similar extension points exist, see Microsoft.Common.targets.
179+
<Target Name="BeforeBuild">
180+
</Target>
181+
<Target Name="AfterBuild">
182+
</Target>
183+
-->
184+
</Project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
<PropertyGroup>
3+
<TargetFrameworks>net40;net45;net46;net47;net48;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
4+
<OutputType>WinExe</OutputType>
5+
<UseWPF>true</UseWPF>
6+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
7+
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
8+
<RootNamespace>ClipArtViewer</RootNamespace>
9+
<AssemblyName>ClipArtViewer</AssemblyName>
10+
</PropertyGroup>
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12+
<DebugType>full</DebugType>
13+
<DebugSymbols>true</DebugSymbols>
14+
<DefineConstants>DEBUG;TRACE</DefineConstants>
15+
<WarningLevel>4</WarningLevel>
16+
<OutputPath>Output\</OutputPath>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
19+
<DefineConstants>TRACE</DefineConstants>
20+
<WarningLevel>4</WarningLevel>
21+
<OutputPath>Output\</OutputPath>
22+
</PropertyGroup>
23+
<PropertyGroup>
24+
<ApplicationIcon>ClipArtViewer.ico</ApplicationIcon>
25+
</PropertyGroup>
26+
<ItemGroup>
27+
<ProjectReference Include="..\..\Source\SVGImage\DotNetProjects.SVGImage.csproj" />
28+
</ItemGroup>
29+
<ItemGroup>
30+
<Compile Update="Properties\Resources.Designer.cs">
31+
<AutoGen>True</AutoGen>
32+
<DesignTime>True</DesignTime>
33+
<DependentUpon>Resources.resx</DependentUpon>
34+
</Compile>
35+
<Compile Update="Properties\Settings.Designer.cs">
36+
<AutoGen>True</AutoGen>
37+
<DependentUpon>Settings.settings</DependentUpon>
38+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
39+
</Compile>
40+
<EmbeddedResource Update="Properties\Resources.resx">
41+
<Generator>ResXFileCodeGenerator</Generator>
42+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
43+
</EmbeddedResource>
44+
<None Update="Properties\Settings.settings">
45+
<Generator>SettingsSingleFileGenerator</Generator>
46+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
47+
</None>
48+
</ItemGroup>
49+
</Project>
172 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<UserControl x:Class="ClipArtViewer.DebugForm"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:system="clr-namespace:System;assembly=mscorlib"
7+
xmlns:local="clr-namespace:ClipArtViewer"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300" d:DesignWidth="300" Margin="3">
10+
11+
<Grid>
12+
<Grid.ColumnDefinitions>
13+
<ColumnDefinition Width="480*" />
14+
<ColumnDefinition Width="Auto" />
15+
<ColumnDefinition Width="125*" />
16+
</Grid.ColumnDefinitions>
17+
<local:SVGViewCanvas x:Name="m_canvas" Background="LightBlue"></local:SVGViewCanvas>
18+
<GridSplitter Grid.Column="1" HorizontalAlignment="Center" Name="gridSplitter1" Width="5" />
19+
<local:SVGObjectTree x:Name="m_objTree" Grid.Column="2" SelectedItemChanged="OnSelectedItemChanged" />
20+
</Grid>
21+
22+
</UserControl>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
5+
using SVGImage.SVG;
6+
using SVGImage.SVG.Shapes;
7+
8+
namespace ClipArtViewer
9+
{
10+
/// <summary>
11+
/// Interaction logic for FullSizeForm.xaml
12+
/// </summary>
13+
public partial class DebugForm : UserControl
14+
{
15+
public static DependencyProperty SVGItemSourcePoperty = DependencyProperty.Register("SVGItemSource",
16+
typeof(SVGItem),
17+
typeof(DebugForm),
18+
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnSVGItemChanged)));
19+
20+
static void OnSVGItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
21+
{
22+
((DebugForm)d).SetSVGItemSource(e.NewValue as SVGItem);
23+
}
24+
25+
public SVGItem SVGItemSource
26+
{
27+
get { return (SVGItem)GetValue(SVGItemSourcePoperty); }
28+
set { SetValue(SVGItemSourcePoperty, value); }
29+
}
30+
31+
public void SetSVGItemSource(SVGItem svg)
32+
{
33+
if (svg == null || svg.SVGImage == null)
34+
{
35+
m_canvas.SetDrawing(null);
36+
m_objTree.Populate(null);
37+
return;
38+
}
39+
40+
m_canvas.SetDrawing(svg.SVGImage);
41+
m_objTree.Populate(svg.SVGRender.SVG);
42+
}
43+
44+
public DebugForm()
45+
{
46+
InitializeComponent();
47+
48+
this.Loaded += OnDebugFormLoaded;
49+
}
50+
51+
private void OnDebugFormLoaded(object sender, RoutedEventArgs e)
52+
{
53+
this.SetSVGItemSource(this.SVGItemSource);
54+
}
55+
56+
private void OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
57+
{
58+
Shape shape = m_objTree.SelectedShape;
59+
if (shape != null)
60+
{
61+
m_canvas.ClearHighligh();
62+
m_canvas.AddHighlight(SVGItemSource.SVGRender.CreateDrawing(shape));
63+
}
64+
else
65+
{
66+
m_canvas.ClearHighligh();
67+
}
68+
}
69+
}
70+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<UserControl x:Class="ClipArtViewer.FullSizeForm"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:svgc="clr-namespace:SVGImage.SVG;assembly=DotNetProjects.SVGImage"
7+
xmlns:system="clr-namespace:System;assembly=mscorlib"
8+
xmlns:local="clr-namespace:ClipArtViewer"
9+
mc:Ignorable="d"
10+
d:DesignHeight="300" d:DesignWidth="300">
11+
12+
<Grid Grid.Row="0" Grid.Column="0" Margin="3">
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="Auto" />
15+
<RowDefinition />
16+
</Grid.RowDefinitions>
17+
<StackPanel Grid.Row="0" >
18+
<StackPanel Orientation="Horizontal" FlowDirection="RightToLeft" Margin="5" >
19+
<ComboBox MinWidth="180" HorizontalAlignment="Right" FlowDirection="LeftToRight" x:Name="m_sizeTypeCombo"
20+
SelectedValue="{Binding ElementName=m_canvas1, Path=SizeType}" HorizontalContentAlignment="Left">
21+
<system:String>None</system:String>
22+
<system:String>ContentToSizeNoStretch</system:String>
23+
<system:String>ContentToSizeStretch</system:String>
24+
<system:String>SizeToContent</system:String>
25+
</ComboBox>
26+
<Label>SizeType</Label>
27+
</StackPanel>
28+
<Line Stroke="LightGray" StrokeThickness="1" X2="1" Stretch="Fill" Margin="3"></Line>
29+
</StackPanel>
30+
<svgc:SVGImage x:Name="m_canvas1" Grid.Row="1" Margin="3"
31+
SizeType="ContentToSizeNoStretch"
32+
Padding="2" BorderThickness="0.5"></svgc:SVGImage>
33+
</Grid>
34+
35+
</UserControl>

0 commit comments

Comments
 (0)