diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60f2d05..a0cb7ea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,11 +2,20 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
-### Ribbon V2.11.1, RibbonTools V1.3.7+
+### Ribbon V2.12.0, RibbonTools V1.4.0
+
+#### Changed (Ribbon)
+
+- AssemblyVersion is now 1.0.0.0 for .NET Framework 3.5. This version is installed to the GAC. For all other (.NET Framework 4.0 and higher, .NET Core) the AssemblyVersion is 4.0.0.0. These changes are done for easier handling with different .Net versions, mainly for .NET Framework 4.x.
#### Changed (RibbonTools)
- Added functions (and small changes) to AlphaBitmap, NativeMethods
+- Project files changes to the Ribbon with Assembly version 4.0.0.0
+- So we don't need to activate the .NET Framework 3.5 in the Windows System
+
+#### Changed Setup files
+
### Ribbon V2.11.1, RibbonTools V1.3.7
diff --git a/Ribbon/Properties/AssemblyInfo.cs b/Ribbon/Properties/AssemblyInfo.cs
index 0f70944..598a9c8 100644
--- a/Ribbon/Properties/AssemblyInfo.cs
+++ b/Ribbon/Properties/AssemblyInfo.cs
@@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RibbonLib")]
[assembly: AssemblyProduct("Ribbon")]
-[assembly: AssemblyCopyright("Copyright © 2009, 2021")]
+[assembly: AssemblyCopyright("Copyright © 2009, 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,6 +32,10 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
+#if NET || NET40 || NETCOREAPP3_1
+[assembly: AssemblyVersion("4.0.0.0")]
+#else
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("2.11.1.0")]
+#endif
+[assembly: AssemblyFileVersion("2.12.0.0")]
diff --git a/Ribbon/RecentItemsPropertySet.cs b/Ribbon/RecentItemsPropertySet.cs
index 0dc7c52..234c2e6 100644
--- a/Ribbon/RecentItemsPropertySet.cs
+++ b/Ribbon/RecentItemsPropertySet.cs
@@ -14,7 +14,7 @@ namespace RibbonLib
///
/// Helper class that wraps a recent items simple property set.
///
- public class RecentItemsPropertySet : IUISimplePropertySet
+ public sealed class RecentItemsPropertySet : IUISimplePropertySet
{
private string _label;
private string _labelDescription;
diff --git a/Ribbon/Ribbon.cs b/Ribbon/Ribbon.cs
index 8c4ee43..c657f8b 100644
--- a/Ribbon/Ribbon.cs
+++ b/Ribbon/Ribbon.cs
@@ -763,9 +763,9 @@ public RibbonColors GetColors()
}
///
- /// Wraps a bitmap object with IUIImage interface
+ /// Wraps a Bitmap object with IUIImage interface
///
- /// bitmap object to wrap
+ /// Bitmap object to wrap
/// IUIImage wrapper
public IUIImage ConvertToUIImage(Bitmap bitmap)
{
diff --git a/Ribbon/RibbonCore.csproj b/Ribbon/RibbonCore.csproj
index 1317769..b4f3339 100644
--- a/Ribbon/RibbonCore.csproj
+++ b/Ribbon/RibbonCore.csproj
@@ -19,7 +19,7 @@
WindowsRibbon
Windows Ribbon Control
- 2.11.1
+ 2.12.0
Hartmut Borkenhagen
RibbonLib
Ribbon64.png
diff --git a/RibbonTools/Misc/AlphaBitmap.cs b/RibbonTools/Misc/AlphaBitmap.cs
index c1ecf9c..349f9a4 100644
--- a/RibbonTools/Misc/AlphaBitmap.cs
+++ b/RibbonTools/Misc/AlphaBitmap.cs
@@ -52,6 +52,8 @@ private static bool IsAnyAlpha(int[] bmpScan)
public static Bitmap TryCreateAlphaBitmap(Stream stream)
{
+ if (stream == null)
+ throw new ArgumentNullException(nameof(stream));
Bitmap bmp = new Bitmap(stream);
return TryConvertToAlphaBitmap(bmp);
}
@@ -61,9 +63,13 @@ public static Bitmap TryCreateAlphaBitmap(Stream stream)
///
///
/// The Bitmap with fully transparency if available
- public static Bitmap TryCreateAlphaBitmap(string filename)
+ public static Bitmap TryCreateAlphaBitmap(string fileName)
{
- Bitmap bmp = new Bitmap(filename);
+ if (string.IsNullOrEmpty(fileName))
+ throw new ArgumentNullException(nameof(fileName));
+ if (!File.Exists(fileName))
+ throw new ArgumentException("File does not exist", nameof(fileName));
+ Bitmap bmp = new Bitmap(fileName);
return TryConvertToAlphaBitmap(bmp);
}
@@ -167,10 +173,21 @@ public static Bitmap BitmapFromFile(string fileName, bool highContrast = false)
/// The Bitmap with fully transparency if available
public static Bitmap FromHbitmap(IntPtr hBitmap)
{
+ if (hBitmap == IntPtr.Zero)
+ throw new ArgumentNullException(nameof(hBitmap));
// Create the BITMAP structure and get info from our nativeHBitmap
NativeMethods.BITMAP bitmapStruct = new NativeMethods.BITMAP();
- NativeMethods.GetObjectBitmap(hBitmap, Marshal.SizeOf(bitmapStruct), ref bitmapStruct);
-
+ try
+ {
+ int bitmapSize = Marshal.SizeOf(bitmapStruct);
+ int size = NativeMethods.GetObjectBitmap(hBitmap, bitmapSize, ref bitmapStruct);
+ if (size != bitmapSize)
+ return null;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
Bitmap managedBitmap;
if (bitmapStruct.bmBitsPixel == 32)
{
@@ -183,7 +200,6 @@ public static Bitmap FromHbitmap(IntPtr hBitmap)
else
{
managedBitmap = Bitmap.FromHbitmap(hBitmap);
- //managedBitmap.MakeTransparent();
}
return managedBitmap;
}
@@ -211,7 +227,7 @@ public static Bitmap ImageFromFile(string path)
(uint)(NativeMethods.ImageLoad.LR_LOADFROMFILE | NativeMethods.ImageLoad.LR_CREATEDIBSECTION));
if (handle != IntPtr.Zero)
return FromHbitmap(handle);
- return null;
+ //A V5 Bitmap is not supported by LoadImage, so we try with a Bitmap Ctor
}
try
{
@@ -270,6 +286,8 @@ public static Bitmap ImageFromResource(IntPtr resourceHandle, uint id)
/// The converted Bitmap
public static Bitmap SetTransparentRGB(Bitmap bitmap, int transparentRGB)
{
+ if (bitmap == null)
+ throw new ArgumentNullException(nameof(bitmap));
int x, y;
IntPtr p;
if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
diff --git a/RibbonTools/Properties/AssemblyInfo.cs b/RibbonTools/Properties/AssemblyInfo.cs
index 4df9c3c..e8e6980 100644
--- a/RibbonTools/Properties/AssemblyInfo.cs
+++ b/RibbonTools/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.3.7.0")]
+[assembly: AssemblyFileVersion("1.4.0.0")]
diff --git a/RibbonTools/RibbonTools.csproj b/RibbonTools/RibbonTools.csproj
index 989bccc..84e66b5 100644
--- a/RibbonTools/RibbonTools.csproj
+++ b/RibbonTools/RibbonTools.csproj
@@ -51,9 +51,8 @@
-
- False
- ..\Ribbon\bin\Release\Ribbon.dll
+
+ ..\Ribbon\bin\Release\net40\Ribbon.dll
diff --git a/Setup/Ribbon.wxs b/Setup/Ribbon.wxs
index 7814077..677daa6 100644
--- a/Setup/Ribbon.wxs
+++ b/Setup/Ribbon.wxs
@@ -9,7 +9,7 @@
-
+
@@ -37,6 +37,8 @@
+
+
@@ -49,7 +51,7 @@
.NET2.0, 3.5 GAC Assembly
-->
-
+