From 86e355c9921a83a3041da3e95d19d70879e32966 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 23 Aug 2022 16:36:41 -0300 Subject: [PATCH 1/2] Version 0.4.0 ### Features - Bitmap to BitmapSource perfect pixel --- CHANGELOG.md | 5 ++++ ricaun.Revit.UI.Example/Models/TestModel.cs | 4 ++- ricaun.Revit.UI.Example/Views/TestView.xaml | 28 +++++++++++-------- .../ricaun.Revit.UI.Example.csproj | 2 +- ricaun.Revit.UI/BitmapExtension.cs | 21 ++++++++------ ricaun.Revit.UI/ricaun.Revit.UI.csproj | 2 +- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c9ef2d..bee18d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.4.0] / 2022-08-23 +### Features +- Bitmap to BitmapSource perfect pixel + ## [0.3.2] / 2022-08-16 ### Features - Add `AppLoader` Attribute @@ -184,6 +188,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - First Release [vNext]: ../../compare/1.0.0...HEAD +[0.4.0]: ../../compare/0.3.2...0.4.0 [0.3.2]: ../../compare/0.3.1...0.3.2 [0.3.1]: ../../compare/0.3.0...0.3.1 [0.3.0]: ../../compare/0.2.1...0.3.0 diff --git a/ricaun.Revit.UI.Example/Models/TestModel.cs b/ricaun.Revit.UI.Example/Models/TestModel.cs index bc86a83..b810185 100644 --- a/ricaun.Revit.UI.Example/Models/TestModel.cs +++ b/ricaun.Revit.UI.Example/Models/TestModel.cs @@ -5,7 +5,9 @@ namespace ricaun.Revit.UI.Example.Models { public class TestModel : NotifyPropertyBase { - public string Text { get; set; } + public string Text { get; set; } = "Test"; + public string Title { get; set; } = "Title"; + public object Icon { get; set; } = Proprieties.Icons8.Circled; public ICommand CommandTest { get; set; } public ICommand CommandTest2 { get; set; } } diff --git a/ricaun.Revit.UI.Example/Views/TestView.xaml b/ricaun.Revit.UI.Example/Views/TestView.xaml index 6c64d6f..567a710 100644 --- a/ricaun.Revit.UI.Example/Views/TestView.xaml +++ b/ricaun.Revit.UI.Example/Views/TestView.xaml @@ -1,19 +1,25 @@  + DataContext="{Binding RelativeSource={RelativeSource Self}}" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="clr-namespace:ricaun.Revit.UI.Example.Views" + Width="320" + Height="240" + Icon="{Binding Icon}" + Title="{Binding Title}" + mc:Ignorable="d"> - - + + diff --git a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj index 54dc075..68b24de 100644 --- a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj +++ b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj @@ -76,7 +76,7 @@ ricaun.Revit.UI.Example - 1.3.2 + 1.4.0 {f736f68f-7101-4640-9093-8715f88ccb95} diff --git a/ricaun.Revit.UI/BitmapExtension.cs b/ricaun.Revit.UI/BitmapExtension.cs index bd17bf8..e61b3b2 100644 --- a/ricaun.Revit.UI/BitmapExtension.cs +++ b/ricaun.Revit.UI/BitmapExtension.cs @@ -14,23 +14,28 @@ namespace ricaun.Revit.UI public static class BitmapExtension { /// - /// GetBitmapSource + /// Convert to /// /// /// public static BitmapSource GetBitmapSource(this System.Drawing.Bitmap bitmap) { - var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap( - bitmap.GetHbitmap(), - IntPtr.Zero, - Int32Rect.Empty, - BitmapSizeOptions.FromEmptyOptions()); + var data = bitmap.LockBits( + new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), + System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat); + + var bitmapSource = BitmapSource.Create( + data.Width, data.Height, 96.0, 96.0, + System.Windows.Media.PixelFormats.Bgra32, null, + data.Scan0, data.Stride * data.Height, data.Stride); + + bitmap.UnlockBits(data); return bitmapSource; } /// - /// GetBitmapSource + /// Convert to /// /// /// @@ -43,7 +48,7 @@ public static BitmapSource GetBitmapSource(this System.Drawing.Icon icon) } /// - /// GetBitmapSource + /// Convert to /// /// /// diff --git a/ricaun.Revit.UI/ricaun.Revit.UI.csproj b/ricaun.Revit.UI/ricaun.Revit.UI.csproj index d7119e8..f88a519 100644 --- a/ricaun.Revit.UI/ricaun.Revit.UI.csproj +++ b/ricaun.Revit.UI/ricaun.Revit.UI.csproj @@ -76,7 +76,7 @@ ricaun.Revit.UI - 0.3.2 + 0.4.0 {2064ba4d-5527-41e9-8b76-0cbfefa35900} From 0896325efda11a32444fe164efecb80461d033ca Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 23 Aug 2022 16:57:05 -0300 Subject: [PATCH 2/2] Change ApplicationLoader to AppLoader --- README.md | 4 ++-- ricaun.Revit.UI/AppLoaderAttribute.cs | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 97619ed..5b0864a 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ ## Features -`ricaun.Revit.UI` package is design to work with the plugin [ApplicationLoader](https://ricaun.com/ApplicationLoader/) that allow loading Revit Applications on runtime. +`ricaun.Revit.UI` package is design to work with the plugin [AppLoader](https://ricaun.com/AppLoader/) that allow loading Revit Applications on runtime. ```C# -[ApplicationLoader] +[AppLoader] public class App : IExternalApplication { private static RibbonPanel ribbonPanel; diff --git a/ricaun.Revit.UI/AppLoaderAttribute.cs b/ricaun.Revit.UI/AppLoaderAttribute.cs index 288e253..20d4fde 100644 --- a/ricaun.Revit.UI/AppLoaderAttribute.cs +++ b/ricaun.Revit.UI/AppLoaderAttribute.cs @@ -15,11 +15,4 @@ public class ConsoleAttribute : Attribute public class AppLoaderAttribute : Attribute { } - - /// - /// ApplicationLoader Attribute for ricaun.AppLoader - /// - public class ApplicationLoaderAttribute : Attribute - { - } }