Permalink
Browse files

Updated to work with .NET 4 instead of 3.5.

  • Loading branch information...
kharnagy committed Nov 10, 2015
1 parent e3df321 commit 9f4d0f2c4abb6060e51fba9d51b7d9bef2be6a61
View
@@ -11,33 +11,18 @@ namespace IconMaker
/// </summary>
public sealed class IconFile
{
#region Private Fields
/// <summary>
/// Stores the images in the icon.
/// </summary>
private readonly IconImageCollection images = new IconImageCollection();
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the IconFile class.
/// </summary>
public IconFile()
{
}
#endregion
#region Public Properties
/// <summary>
/// Gets the images contained in the icon.
/// </summary>
public IconImageCollection Images
{
get { return this.images; }
}
#endregion
public IconImageCollection Images { get; } = new IconImageCollection();
#region Public Methods
/// <summary>
/// Saves the icon to a file.
/// </summary>
@@ -67,12 +52,12 @@ public void Save(Stream stream)
var sortedImages = this.Images;
var imageData = new Dictionary<int, byte[]>();
int offset = (this.images.Count * 16) + 6;
int offset = (this.Images.Count * 16) + 6;
// Write the icon file header.
writer.Write((ushort)0); // must be 0
writer.Write((ushort)1); // 1 = ico file
writer.Write((ushort)this.images.Count); // number of sizes
writer.Write((ushort)this.Images.Count); // number of sizes
foreach(var image in sortedImages)
{
@@ -98,9 +83,7 @@ orderby i.Key
foreach(var data in sortedData)
writer.Write(data);
}
#endregion
#region Private Static Methods
/// <summary>
/// Returns a byte array containing the serialized icon image.
/// </summary>
@@ -175,6 +158,5 @@ private static byte[] GetImageData(BitmapSource image)
return memoryStream.ToArray();
}
}
#endregion
}
}
@@ -12,30 +12,23 @@ namespace IconMaker
/// </summary>
public sealed class IconImageCollection : ICollection<BitmapSource>, INotifyCollectionChanged
{
#region Private Fields
/// <summary>
/// Stores icon images.
/// </summary>
private readonly SortedList<int, BitmapSource> images = new SortedList<int, BitmapSource>();
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the IconImageCollection class.
/// </summary>
public IconImageCollection()
{
}
#endregion
#region Public Events
/// <summary>
/// Occurs when the collection has changed.
/// </summary>
public event NotifyCollectionChangedEventHandler CollectionChanged;
#endregion
#region Public Properties
/// <summary>
/// Gets the number of images in the collection.
/// </summary>
@@ -51,9 +44,7 @@ public int Count
{
get { return false; }
}
#endregion
#region Public Methods
/// <summary>
/// Adds a new image to the collection.
/// </summary>
@@ -163,9 +154,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
#endregion
#region Private Static Methods
/// <summary>
/// Returns an exception to be raised if the item fails validation.
/// </summary>
@@ -197,9 +186,7 @@ private static BitmapSource ConvertBitmap(BitmapSource source)
return new FormatConvertedBitmap(source, PixelFormats.Bgra32, null, 0.0);
}
#endregion
#region Private Methods
/// <summary>
/// Raises the CollectionChanged event.
/// </summary>
@@ -210,6 +197,5 @@ private void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
if(handler != null)
handler(this, e);
}
#endregion
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IconMaker</RootNamespace>
<AssemblyName>IconMaker</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
@@ -53,6 +53,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -62,6 +63,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@@ -79,6 +81,7 @@
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
@@ -96,12 +99,14 @@
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
@@ -11,7 +11,6 @@ namespace IconMaker
/// </summary>
public partial class MainWindow : Window
{
#region Private Fields
/// <summary>
/// File browser dialog for importing images.
/// </summary>
@@ -31,19 +30,15 @@ public partial class MainWindow : Window
/// Indicates whether the current icon has been modified.
/// </summary>
private bool modified;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the MainWindow class.
/// </summary>
public MainWindow()
{
InitializeComponent();
}
#endregion
#region Protected Methods
/// <summary>
/// Invoked when the window is initialized.
/// </summary>
@@ -71,9 +66,7 @@ protected override void OnDrop(DragEventArgs e)
base.OnDrop(e);
}
#endregion
#region Private Methods
/// <summary>
/// Attempts to load an image file and add it to the icon's image collection.
/// </summary>
@@ -95,9 +88,7 @@ private void AddImageFile(string fileName)
MessageBox.Show(this, ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion
#region Event Handlers
/// <summary>
/// Handler for commands which are always enabled.
/// </summary>
@@ -272,6 +263,5 @@ private void PasteExecuted(object sender, ExecutedRoutedEventArgs e)
this.modified = true;
}
}
#endregion
}
}
@@ -9,15 +9,15 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Inedo, LLC")]
[assembly: AssemblyProduct("Icon Maker")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: CLSCompliant(true)]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 9f4d0f2

Please sign in to comment.