-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
669 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
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). | ||
|
||
## [vNext] | ||
|
||
## [1.0.0] / YYYY-MM-DD | ||
- First Release | ||
|
||
[vNext]: https://github.com/ricaun-io/ricaun.Revit.UI/compare/1.0.0...HEAD | ||
[1.0.0]: https://github.com/ricaun-io/ricaun.Revit.UI/compare/1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# ricaun.Revit.UI | ||
|
||
[![Publish](https://github.com/ricaun-io/ricaun.Revit.UI/actions/workflows/Publish.yml/badge.svg)](https://github.com/ricaun-io/ricaun.Revit.UI/actions) | ||
[![Develop](https://github.com/ricaun-io/ricaun.Revit.UI/actions/workflows/Develop.yml/badge.svg)](https://github.com/ricaun-io/ricaun.Revit.UI/actions) | ||
|
||
--- | ||
|
||
Copyright © 2021 ricaun | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ricaun.Revit.UI", "ricaun.Revit.UI\ricaun.Revit.UI.csproj", "{2064BA4D-5527-41E9-8B76-0CBFEFA35900}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{A81D2950-B5CB-4CDB-B7FE-9132C730C8CC}" | ||
ProjectSection(SolutionItems) = preProject | ||
ricaun.Revit.UI\CHANGELOG.md = ricaun.Revit.UI\CHANGELOG.md | ||
ricaun.Revit.UI\README.md = ricaun.Revit.UI\README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2064BA4D-5527-41E9-8B76-0CBFEFA35900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2064BA4D-5527-41E9-8B76-0CBFEFA35900}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2064BA4D-5527-41E9-8B76-0CBFEFA35900}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2064BA4D-5527-41E9-8B76-0CBFEFA35900}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E22315E4-8753-4610-B0F8-91367AEA4F9A} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Autodesk.Windows; | ||
using System.Windows; | ||
using System.Windows.Interop; | ||
|
||
namespace ricaun.Revit.UI | ||
{ | ||
/// <summary> | ||
/// AutodeskExtension | ||
/// </summary> | ||
public static class AutodeskExtension | ||
{ | ||
/// <summary> | ||
/// Set Autodesk.Windows as the Owner of the Window | ||
/// </summary> | ||
/// <param name="window"></param> | ||
public static void SetAutodeskOwner(this Window window) | ||
{ | ||
new WindowInteropHelper(window) { Owner = ComponentManager.ApplicationWindow }; | ||
} | ||
|
||
/// <summary> | ||
/// Get Autodesk.Windows as the Owner Window | ||
/// </summary> | ||
/// <returns></returns> | ||
public static Window GetAutodeskOwner() | ||
{ | ||
var owner = ComponentManager.ApplicationWindow; | ||
var source = System.Windows.Interop.HwndSource.FromHwnd(owner); | ||
return source.RootVisual as Window; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.IO; | ||
using System.Windows; | ||
using System.Windows.Interop; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace ricaun.Revit.UI | ||
{ | ||
/// <summary> | ||
/// BitmapExtension | ||
/// </summary> | ||
public static class BitmapExtension | ||
{ | ||
/// <summary> | ||
/// GetBitmapSource | ||
/// </summary> | ||
/// <param name="bitmap"></param> | ||
/// <returns></returns> | ||
public static BitmapSource GetBitmapSource(this System.Drawing.Bitmap bitmap) | ||
{ | ||
var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap( | ||
bitmap.GetHbitmap(), | ||
IntPtr.Zero, | ||
Int32Rect.Empty, | ||
BitmapSizeOptions.FromEmptyOptions()); | ||
|
||
return bitmapSource; | ||
} | ||
|
||
/// <summary> | ||
/// GetBitmapSource | ||
/// </summary> | ||
/// <param name="icon"></param> | ||
/// <returns></returns> | ||
public static BitmapSource GetBitmapSource(this System.Drawing.Icon icon) | ||
{ | ||
var bitmapSource = Imaging.CreateBitmapSourceFromHIcon( | ||
icon.ToBitmap().GetHicon(), | ||
Int32Rect.Empty, | ||
BitmapSizeOptions.FromEmptyOptions()); | ||
|
||
return bitmapSource; | ||
} | ||
|
||
/// <summary> | ||
/// GetBitmapSource | ||
/// </summary> | ||
/// <param name="image"></param> | ||
/// <returns></returns> | ||
public static BitmapSource GetBitmapSource(this System.Drawing.Image image) | ||
{ | ||
var bitmap = new System.Drawing.Bitmap(image); | ||
return bitmap.GetBitmapSource(); | ||
} | ||
|
||
/// <summary> | ||
/// Transform string base64 to BitmapSource | ||
/// </summary> | ||
/// <param name="base64"></param> | ||
/// <returns></returns> | ||
public static BitmapSource GetBitmapSource(this string base64) | ||
{ | ||
var image = System.Drawing.Bitmap.FromStream(new MemoryStream(Convert.FromBase64String(base64))); | ||
return image.GetBitmapSource(); | ||
} | ||
|
||
/// <summary> | ||
/// Scale <paramref name="bitmapSource"/> | ||
/// </summary> | ||
/// <param name="bitmapSource"></param> | ||
/// <param name="scale"></param> | ||
/// <returns></returns> | ||
public static BitmapSource Scale(this BitmapSource bitmapSource, double scale) | ||
{ | ||
return new TransformedBitmap(bitmapSource, new ScaleTransform(scale, scale)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using Autodesk.Revit.ApplicationServices; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
namespace ricaun.Revit.UI | ||
{ | ||
/// <summary> | ||
/// LanguageExtension | ||
/// </summary> | ||
public static class LanguageExtension | ||
{ | ||
/// <summary> | ||
/// Get Base LanguageType | ||
/// </summary> | ||
/// <returns></returns> | ||
public static LanguageType GetLanguageType() | ||
{ | ||
return GetCultureInfo().GetLanguageType(); | ||
} | ||
|
||
/// <summary> | ||
/// Get LanguageType as CultureInfoName | ||
/// </summary> | ||
/// <param name="languageType"></param> | ||
/// <returns></returns> | ||
public static string GetCultureInfoName(this LanguageType languageType) | ||
{ | ||
string language = ""; | ||
switch (languageType) | ||
{ | ||
case LanguageType.Unknown: | ||
language = ""; | ||
break; | ||
case LanguageType.English_USA: | ||
language = "en-US"; | ||
break; | ||
case LanguageType.German: | ||
language = "de-DE"; | ||
break; | ||
case LanguageType.Spanish: | ||
language = "es-ES"; | ||
break; | ||
case LanguageType.French: | ||
language = "fr-FR"; | ||
break; | ||
case LanguageType.Italian: | ||
language = "it-IT"; | ||
break; | ||
case LanguageType.Dutch: | ||
language = "nl-BE"; | ||
break; | ||
case LanguageType.Chinese_Simplified: | ||
language = "zh-CHS"; | ||
break; | ||
case LanguageType.Chinese_Traditional: | ||
language = "zh-CHT"; | ||
break; | ||
case LanguageType.Japanese: | ||
language = "ja-JP"; | ||
break; | ||
case LanguageType.Korean: | ||
language = "ko-KR"; | ||
break; | ||
case LanguageType.Russian: | ||
language = "ru-RU"; | ||
break; | ||
case LanguageType.Czech: | ||
language = "cs-CZ"; | ||
break; | ||
case LanguageType.Polish: | ||
language = "pl-PL"; | ||
break; | ||
case LanguageType.Hungarian: | ||
language = "hu-HU"; | ||
break; | ||
case LanguageType.Brazilian_Portuguese: | ||
language = "pt-BR"; | ||
break; | ||
} | ||
return language; | ||
} | ||
|
||
/// <summary> | ||
/// Get LanguageType by Culture Key | ||
/// </summary> | ||
/// <returns></returns> | ||
public static Dictionary<string, LanguageType> GetLanguages() | ||
{ | ||
var languages = new Dictionary<string, LanguageType>(); | ||
|
||
languages.Add("en-US", LanguageType.English_USA); | ||
languages.Add("de-DE", LanguageType.German); | ||
languages.Add("es-ES", LanguageType.Spanish); | ||
languages.Add("fr-FR", LanguageType.French); | ||
languages.Add("nl-BE", LanguageType.Dutch); | ||
languages.Add("zh-CHS", LanguageType.Chinese_Simplified); | ||
languages.Add("zh-CHT", LanguageType.Chinese_Traditional); | ||
languages.Add("ko-KR", LanguageType.Korean); | ||
languages.Add("ru-RU", LanguageType.Russian); | ||
languages.Add("cs-CZ", LanguageType.Czech); | ||
languages.Add("pl-PL", LanguageType.Polish); | ||
languages.Add("hu-HU", LanguageType.Hungarian); | ||
languages.Add("pt-BR", LanguageType.Brazilian_Portuguese); | ||
|
||
return languages; | ||
} | ||
|
||
/// <summary> | ||
/// Get CultureInfo LanguageType | ||
/// </summary> | ||
/// <param name="cultureInfo"></param> | ||
/// <returns></returns> | ||
private static LanguageType GetLanguageType(this CultureInfo cultureInfo) | ||
{ | ||
var languages = GetLanguages(); | ||
|
||
LanguageType languageType; | ||
var name = cultureInfo.Name; | ||
if (languages.TryGetValue(name, out languageType)) | ||
{ | ||
return languageType; | ||
} | ||
|
||
return LanguageType.English_USA; | ||
} | ||
|
||
/// <summary> | ||
/// Get CurrentUICulture | ||
/// </summary> | ||
/// <returns></returns> | ||
private static CultureInfo GetCultureInfo() | ||
{ | ||
var cultureInfo = CultureInfo.CurrentUICulture; | ||
return cultureInfo; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.