Skip to content

Commit

Permalink
Refactoring and bug fixes
Browse files Browse the repository at this point in the history
- Removed the Design project
- Removed the VS2017 project files
- Removed .NETCore 3.0
- Removed DotnetProjects namespaces, simplified the namespaces
- Removed the Attribute class, since it is the same as StyleItem class
- Added DocFX projects for building documentations
- Updates to the Nuget package: included Xml-docs, readme etc.
- Fixed null exception in the ViewBoxToSizeNoStretch support when using Drawing sources.
NOTE: The changes will results in breakings changes in the API, but there is no breaking change in Binary, and any current project using only the controls will work as usual.
  • Loading branch information
paulushub committed Oct 28, 2023
1 parent f5e41f4 commit 8c2104d
Show file tree
Hide file tree
Showing 96 changed files with 1,621 additions and 25,518 deletions.
9 changes: 9 additions & 0 deletions Docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
23 changes: 23 additions & 0 deletions Docs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## SVGImage
This is an SVG Image View Control for WPF applications.

Initially forked from: [SVGImage Control - CodeProject Article](https://www.codeproject.com/Articles/92434/SVGImage-Control)

Besides the bug fixes, new features are added including the following:
- Mask/Clip support
- Support of styles.
- Simple Animation support.

## Framework support
The SVGImage control library targets the following frameworks
* .NET Framework, Version 4.0
* .NET Framework, Version 4.5
* .NET Framework, Version 4.6
* .NET Framework, Version 4.7
* .NET Framework, Version 4.8
* .NET Core, Version 3.1
* .NET 6 ~ 7

## License
The SVGImage control library is relicensed under [MIT License](https://github.com/dotnetprojects/SVGImage/blob/master/LICENSE),
with permission from the original author.
5 changes: 5 additions & 0 deletions Docs/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###############
# temp file #
###############
*.yml
.manifest
21 changes: 21 additions & 0 deletions Docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SVGImage API Reference

### [](#namespaces)Namespaces

#### [SVGImage.SVG](xref:SVGImage.SVG)
The namespace containing the SVG controls.

#### [SVGImage.SVG.Animation](xref:SVGImage.SVG.Animation)
The SVG animation elements namespace.

#### [SVGImage.SVG.FileLoaders](xref:SVGImage.SVG.FileLoaders)
A namespace defining interfaces for loading external documents and resources.

#### [SVGImage.SVG.Filters](xref:SVGImage.SVG.Filters)
A namespace defining some of the SVG filters/

#### [SVGImage.SVG.PaintServers](xref:SVGImage.SVG.PaintServers)
The namespace defining SVG paint servers.

#### [SVGImage.SVG.Shapes](xref:SVGImage.SVG.Shapes)
The namespace defining the geometric and related SVG shapes.
28 changes: 28 additions & 0 deletions Docs/articles/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Introduction

SVG (Scalable Vector Graphic) is an XML based graphic format.

This little project started out as a simple `SVG` to `XAML` converter. I looked at some simple SVG files and noticed
the similarity to `XAML` defined graphic, and decided to write a converter. However, I soon realized that SVG is a
very complex format, and at the same time, I found no good reason for converting to `XAML` just to show the image
on the screen, so instead, I started working on the `SVG`, `SVGRender` and the `SVGImage` classes.

* The `SVG` class is the class that reads and parses the XML file.
* `SVGRender` is the class that creates the WPF Drawing object based on the information from the SVG class.
* `SVGImage` is the image control. The image control can either
- load the image from a filename `SetImage(filename)`
- or by setting the Drawing object through `SetImage(Drawing)`,
which allows multiple controls to share the same drawing instance.

The control only has a couple of properties, `SizeType` and `ImageSource`.

* `SizeType` - controls how the image is stretched to fill the control
- `None`: The image is not scaled. The image location is translated so the top left corner of the image bounding box is moved to the top left corner of the image control.
- `ContentToSizeNoStretch`: The image is scaled to fit the control without any stretching. Either X or Y direction will be scaled to fill the entire width or height.
- `ContentToSizeStretch`: The image will be stretched to fill the entire width and height.
- `SizeToContent`: The control will be resized to fit the un-scaled image. If the image is larger than the max size for the control, the control is set to max size and the image is scaled.
- `ViewBoxToSizeNoStretch`: Not the content of the image but its viewbox is scaled to fit the control without any stretching.Either `X` or `Y` direction will be scaled to fill the entire width or height.

For `None` and `ContentToSizeNoStretch`, the Horizontal/VerticalContentAlignment properties can be used to position the image within the control.

* `ImageSource` - This property is the same as `SetImage(drawing)`, and is exposed to allow for the source to be set through binding.
2 changes: 2 additions & 0 deletions Docs/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Introduction
href: intro.md
77 changes: 77 additions & 0 deletions Docs/docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"metadata": [
{
"src": [
{
"files": [
"SVGImage/DotNetProjects.SVGImage.csproj"
],
"src": "../Source/",
"properties": {
"TargetFramework": "netcoreapp3.1"
}
}
],
"dest": "api",
"outputFormat": "mref",
"includePrivateMembers": false,
"disableGitFeatures": false,
"disableDefaultFilter": false,
"noRestore": false,
"namespaceLayout": "flattened",
"memberLayout": "samePage",
"enumSortOrder": "alphabetic",
"allowCompilationErrors": false
}
],
"build": {
"content": [
{
"files": [
"api/**.yml",
"api/index.md"
]
},
{
"files": [
"articles/**.md",
"articles/**/toc.yml",
"toc.yml",
"*.md"
]
}
],
"resource": [
{
"files": [
"images/**"
]
}
],
"globalMetadata": {
"_appName": "SVGImage",
"_appTitle": "SVGImage Documentation",
"_appLogoPath": "images/dotnetprojects.png",
"_appFaviconPath": "images/dotnetprojects.png",
"_enableDiagrams": true,
"_enableSearch": true,
"_appFooter": "<div class=\"d-flex flex-column flex-sm-row justify-content-between pt-1\"><p> &copy; 2010 - 2023 DotNetProjects</p><p>Made with <a href=\"https://dotnet.github.io/docfx\">DocFX</a></p></div>",
"_gitContribute": {
"repo": "https://github.com/dotnetprojects/SVGImage",
"branch": "master"
},
"_gitUrlPattern": "github"
},
"output": "_site",
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": [
"default",
"modern",
"template"
],
"postProcessors": [],
"keepFileLink": false,
"disableGitFeatures": false
}
}
Binary file added Docs/images/dotnetprojects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
26 changes: 26 additions & 0 deletions Docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## SVGImage
This is an SVG Image View Control for WPF applications.

Initially forked from: [SVGImage Control - CodeProject Article](https://www.codeproject.com/Articles/92434/SVGImage-Control)

Besides the bug fixes, new features are added including the following:
- Mask/Clip support
- Support of styles.
- Simple Animation support.

## Framework support
The SVGImage control library targets the following frameworks
* .NET Framework, Version 4.0
* .NET Framework, Version 4.5
* .NET Framework, Version 4.6
* .NET Framework, Version 4.7
* .NET Framework, Version 4.8
* .NET Core, Version 3.1

## License
The SVGImage control library is relicensed under [MIT License](https://github.com/dotnetprojects/SVGImage/blob/master/LICENSE),
with permission from the original author.

## Sample Application

![](images/sample.png)
9 changes: 9 additions & 0 deletions Docs/template/public/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Checkout https://getbootstrap.com/docs/5.3/customize/color/ for more customization options */
.navbar-brand #logo {
width: 42px;
height: 36px;
}

#navbar ul.navbar-nav {
margin-top: -3px;
}
14 changes: 14 additions & 0 deletions Docs/template/public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
iconLinks: [
{
icon: 'github',
href: 'https://github.com/dotnetprojects/SVGImage',
title: 'GitHub: SVGImage'
},
{
icon: 'filetype-svg',
href: 'https://developer.mozilla.org/en-US/docs/Web/SVG',
title: 'SVG: Scalable Vector Graphics'
}
]
}
5 changes: 5 additions & 0 deletions Docs/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Articles
href: articles/
- name: API Reference
href: api/
homepage: api/index.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ with permission from the original author.

## Sample Application

![](Docs/sample.png)
![](Docs/images/sample.png)
2 changes: 1 addition & 1 deletion Samples/ClipArtViewer/ClipArtViewer.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFrameworks>net40;net45;net46;net47;net48;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net40;net45;net46;net47;net48;netcoreapp3.1</TargetFrameworks>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
1 change: 1 addition & 0 deletions Samples/ClipArtViewer/FullSizeForm.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<system:String>ContentToSizeNoStretch</system:String>
<system:String>ContentToSizeStretch</system:String>
<system:String>SizeToContent</system:String>
<system:String>ViewBoxToSizeNoStretch</system:String>
</ComboBox>
<Label>SizeType</Label>
</StackPanel>
Expand Down
84 changes: 42 additions & 42 deletions Samples/ClipArtViewer/FullSizeForm.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,54 @@

namespace ClipArtViewer
{
/// <summary>
/// Interaction logic for FullSizeForm.xaml
/// </summary>
public partial class FullSizeForm : UserControl
{
public static DependencyProperty ImageSourcePoperty = DependencyProperty.Register("ImageSource",
typeof(Drawing),
typeof(FullSizeForm),
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnImageSourceChanged)));
static void OnImageSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((FullSizeForm)d).SetImage(e.NewValue as Drawing);
}

public Drawing ImageSource
{
get { return (Drawing)GetValue(ImageSourcePoperty); }
set { SetValue(ImageSourcePoperty, value); }
}

public void SetImage(Drawing drawing)
{
m_canvas1.SetImage(drawing);
}

public FullSizeForm()
{
InitializeComponent();

this.Loaded += OnFullSizeFormLoaded;
}
/// <summary>
/// Interaction logic for FullSizeForm.xaml
/// </summary>
public partial class FullSizeForm : UserControl
{
public static DependencyProperty ImageSourcePoperty = DependencyProperty.Register("ImageSource",
typeof(Drawing),
typeof(FullSizeForm),
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnImageSourceChanged)));
static void OnImageSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((FullSizeForm)d).SetImage(e.NewValue as Drawing);
}

public Drawing ImageSource
{
get { return (Drawing)GetValue(ImageSourcePoperty); }
set { SetValue(ImageSourcePoperty, value); }
}

public void SetImage(Drawing drawing)
{
m_canvas1.SetImage(drawing);
}

public FullSizeForm()
{
InitializeComponent();

this.Loaded += OnFullSizeFormLoaded;
}

protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);

if (m_canvas1 != null && m_sizeTypeCombo != null)
if (m_canvas1 != null && m_sizeTypeCombo != null)
{
m_canvas1.SizeType = SVGImage.SVG.SVGImage.eSizeType.ContentToSizeNoStretch;
m_sizeTypeCombo.SelectedItem = m_canvas1.SizeType.ToString();
}
}
m_canvas1.SizeType = SVGImage.SVG.SVGImage.eSizeType.ContentToSizeNoStretch;
m_sizeTypeCombo.SelectedItem = m_canvas1.SizeType.ToString();
}
}

private void OnFullSizeFormLoaded(object sender, RoutedEventArgs e)
{
m_canvas1.SetImage(this.ImageSource);
m_sizeTypeCombo.SelectedItem = m_canvas1.SizeType.ToString();
}
}
{
m_canvas1.SetImage(this.ImageSource);
m_sizeTypeCombo.SelectedItem = m_canvas1.SizeType.ToString();
}
}
}
2 changes: 1 addition & 1 deletion Samples/ClipArtViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ClipArtViewer"
xmlns:svgc="clr-namespace:SVGImage.SVG;assembly=DotNetProjects.SVGImage"
Title="SVGImage - by Jesper Kristiansen" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow"
mc:Ignorable="d" Height="720" Width="1080" Margin="3">
mc:Ignorable="d" Height="960" Width="1080" Margin="3">
<Window.Resources>
<SolidColorBrush x:Key="TabItem.Static.Background" Color="White"/>
<SolidColorBrush x:Key="TabItem.Static.Border" Color="#ACACAC"/>
Expand Down
Loading

0 comments on commit 8c2104d

Please sign in to comment.