Skip to content

Commit

Permalink
Merge branch 'release/netfx40'
Browse files Browse the repository at this point in the history
  • Loading branch information
ennerperez committed Apr 26, 2016
2 parents 6803b5a + 83c26ba commit d7c791c
Show file tree
Hide file tree
Showing 18 changed files with 466 additions and 74 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.14] - 2016-04-26
### Changed
- NETFX40 Base migrated

### Fixed
- Build bug

## [1.0.12] - 2016-04-22
### Changed
- FontAwesome 4.6.1
Expand Down
189 changes: 189 additions & 0 deletions Pictograms.Forms/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;

namespace System.Windows.Forms.Pictograms
{
public static class Extensions
{

#region Generics<T>

public static void SetImage<T>(this Control @this, object type, int size = 0, Color? color = null, Brush brush = null) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetImage(@this, instance, type, size, color, brush);
}
public static void SetText<T>(this Control @this, object type, float size = 0) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetText(@this, instance, type, size);
}

public static void SetImage<T>(this Component @this, object type, int size = 0, Color? color = null, Brush brush = null) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetImage(@this, instance, type, size, color, brush);
}
public static void SetText<T>(this Component @this, object type, float size = 0) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetText(@this, instance, type, size);
}

public static void SetIcon<T>(this NotifyIcon @this, object type, int size = 0, Color? color = null, Brush brush = null) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetIcon(@this, instance, type, size, color, brush);
}
public static void SetIcon<T>(this ImageList @this, object type, int size = 0, Color? color = null, Brush brush = null) where T : Pictogram
{
var instance = Activator.CreateInstance<T>();
SetIcon(@this, instance, type, size, color, brush);
}

#endregion

public static void SetImage(this Control @this, Pictogram pictogram, object type, int size = 0, Color? color = null, Brush brush = null)
{
if (size == 0)
size = (@this.Width + @this.Height) / 2;

if (color == null)
color = @this.ForeColor;

if (brush == null)
brush = new SolidBrush(color.Value);

var image = pictogram.GetImage((int)type, size, brush);

if (typeof(ButtonBase).IsAssignableFrom(@this.GetType()))
(@this as ButtonBase).Image = image;
if (typeof(PictureBox).IsAssignableFrom(@this.GetType()))
(@this as PictureBox).Image = image;
if (typeof(Panel).IsAssignableFrom(@this.GetType()))
(@this as Panel).BackgroundImage = image;
if (typeof(GroupBox).IsAssignableFrom(@this.GetType()))
(@this as GroupBox).BackgroundImage = image;
}
public static void SetText(this Control @this, Pictogram pictogram, object type, float size = 0)
{
if (size == 0)
size = @this.Font.Size;

if (typeof(ButtonBase).IsAssignableFrom(@this.GetType()) ||
typeof(Label).IsAssignableFrom(@this.GetType()) ||
typeof(GroupBox).IsAssignableFrom(@this.GetType()) ||
typeof(TabPage).IsAssignableFrom(@this.GetType()))
{
@this.Text = pictogram.GetText((int)type);
@this.Font = new Font(pictogram.FontFamily, size, @this.Font.Style, @this.Font.Unit);
}
}

public static void SetImage(this Component @this, Pictogram pictogram, object type, int size = 0, Color? color = null, Brush brush = null)
{

if (typeof(ToolStripItem).IsAssignableFrom(@this.GetType()))
{
if (size == 0)
size = ((@this as ToolStripItem).Width + (@this as ToolStripItem).Height) / 2;

if (color == null)
color = (@this as ToolStripItem).ForeColor;

if (brush == null)
brush = new SolidBrush(color.Value);

var image = pictogram.GetImage((int)type, size, brush);

(@this as ToolStripItem).Image = image;
}
else if (typeof(NotifyIcon).IsAssignableFrom(@this.GetType()))
{

if (color == null)
color = SystemColors.ControlText;

if (size == 0)
size = 16;

if (brush == null)
brush = new SolidBrush(color.Value);

var image = pictogram.GetImage((int)type, size, brush);
var hIcon = new Bitmap(image).GetHicon();

(@this as NotifyIcon).Icon = Icon.FromHandle(hIcon);
}
else if (typeof(ImageList).IsAssignableFrom(@this.GetType()))
{
if (color == null)
color = SystemColors.ControlText;

if (size == 0)
size = ((@this as ImageList).ImageSize.Width + (@this as ImageList).ImageSize.Height) / 2;

if (brush == null)
brush = new SolidBrush(color.Value);

var image = pictogram.GetImage((int)type, size, brush);

(@this as ImageList).Images.Add(image);

}


}
public static void SetText(this Component @this, Pictogram pictogram, object type, float size = 0)
{

if (typeof(ToolStripItem).IsAssignableFrom(@this.GetType()))
{
if (size == 0)
size = (@this as ToolStripItem).Font.Size;

var text = pictogram.GetText((int)type);

if ((@this as ToolStripItem).Text == (@this as ToolStripItem).ToolTipText)
(@this as ToolStripItem).ToolTipText = (@this as ToolStripItem).Text;

(@this as ToolStripItem).Text = text;
(@this as ToolStripItem).Font = new Font(pictogram.FontFamily, size, (@this as ToolStripItem).Font.Style, (@this as ToolStripItem).Font.Unit);
}
}

public static void SetIcon(this NotifyIcon @this, Pictogram pictogram, object type, int size = 0, Color? color = null, Brush brush = null)
{
if (size == 0)
size = 16;

SetImage(@this, pictogram, type, size, color, brush);

}
public static void SetIcon(this ImageList @this, Pictogram pictogram, object type, int size = 0, Color? color = null, Brush brush = null)
{

if (color == null)
color = SystemColors.ControlText;

if (size == 0)
size = (@this.ImageSize.Width + @this.ImageSize.Height) / 2;

if (brush == null)
brush = new SolidBrush(color.Value);

var image = pictogram.GetImage((int)type, size, brush);

var hIcon = new Bitmap(image).GetHicon();
var icon = Icon.FromHandle(hIcon);

@this.Images.Add(icon);

}

}
}
24 changes: 24 additions & 0 deletions Pictograms.Forms/Package.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.8.1">
<id>$id$</id>
<version>$version$</version>
<title>$description$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/ennerperez/pictograms/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/ennerperez/pictograms</projectUrl>
<iconUrl>https://raw.githubusercontent.com/ennerperez/pictograms/master/.editoricon.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Introducing fonts based pictograms for .NET Windows Forms projects</description>
<summary />
<releaseNotes />
<copyright>$copyright$</copyright>
<language>en</language>
<tags>Pictograms Fonts Icons Design Windows Forms</tags>
<dependencies>
<dependency id="System.Drawing.Pictograms" version="1.1" />
</dependencies>
</metadata>
<files />
</package>
73 changes: 73 additions & 0 deletions Pictograms.Forms/Pictograms.Forms.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{45872AA9-7722-49B4-864D-B03F11AB5B3F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>System.Windows.Forms.Pictograms</RootNamespace>
<AssemblyName>System.Windows.Forms.Pictograms</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pictograms\Pictograms.csproj">
<Project>{11fc6c23-77b2-44dd-b9c8-39e30e1a1a1a}</Project>
<Name>Pictograms</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Package.nuspec">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuget\NuGet.targets" Condition="Exists('..\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
45 changes: 45 additions & 0 deletions Pictograms.Forms/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// La información general de un ensamblado se controla mediante el siguiente
// conjunto de atributos. Cambie estos valores de atributo para modificar la información
// asociada con un ensamblado.

[assembly: AssemblyTitle("Pictograms Forms")]
[assembly: AssemblyDescription("Fonts based pictograms for .NET (WinForms)")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
[assembly: AssemblyCompany("Enner Pérez")]
[assembly: AssemblyProduct("Pictograms Forms")]
[assembly: AssemblyCopyright("© Enner Pérez. All rights reserved.")]
[assembly: AssemblyTrademark("© Enner Pérez")]

// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
// COM, establezca el atributo ComVisible en true en este tipo.

[assembly: ComVisible(true)]

// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
[assembly: Guid("45872aa9-7722-49b4-864d-b03f11ab5b3f")]

// La información de versión de un ensamblado consta de los cuatro valores siguientes:
//
// Versión principal
// Versión secundaria
// Número de compilación
// Revisión
//
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
// mediante el carácter '*', como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
//[assembly: AssemblyInformationalVersion("1.0.0-master")]
14 changes: 14 additions & 0 deletions Pictograms/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;


internal static class NativeMethods
{

[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
internal static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);

}
8 changes: 4 additions & 4 deletions Pictograms/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<metadata minClientVersion="2.8.1">
<id>$id$</id>
<version>$version$</version>
<title>$id$</title>
<title>$description$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.githubusercontent.com/ennerperez/pictograms/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/ennerperez/pictograms</projectUrl>
<iconUrl>https://raw.githubusercontent.com/ennerperez/pictograms/master/.editoricon.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>$description$</description>
<summary>$description$</summary>
<description>Introducing fonts based pictograms for .NET solutions</description>
<summary />
<releaseNotes />
<copyright>$copyright$</copyright>
<language>en</language>
<tags>Pictograms Fonts FontAwesome Foundation Material Design</tags>
<tags>Pictograms Fonts Icons Design</tags>
<dependencies />
</metadata>
<files />
Expand Down
Loading

0 comments on commit d7c791c

Please sign in to comment.