Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework modal logic #25

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,21 @@ public static IServiceCollection AddServices(this IServiceCollection collection)
.AddSingleton<IStyleService, DefaultStyleService>()
.AddSingleton<IPluginTranslationService, PluginTranslationService>()
.AddSingleton<IFunctionSettingsService, FunctionSettingService>()
.AddSingleton<IUrlOpenerService, UrlOpenerService>()
.AddSingleton<ILanguageService, ResourceCultureService>()
.AddSingleton<IWindowManagementService, WindowManagementService>()
.AddSingleton<IPluginService, PluginService>()
.AddSingleton<ISerializationOptionFactory<JsonSerializerOptions>, JsonSerializationOptionFactory>()
.AddSingleton<ISerializeService, JsonSerializationService>()
.AddSingleton<IFunctionService, SerializedFunctionService>()
.AddTransient(typeof(IPluginLoggerService<>), typeof(LoggingPluginAdapter<>))
.AddSingleton<IViewModelLocatorService, ViewModelLocator>()
.AddSingleton<IDependencyResolverService, MicrosoftDepdencyResolverService>()
.AddSingleton<IFileSystemService, FileSystemService>()
.AddSingleton<ISettingsService, SerializedSettingsService>()
.AddSingleton<ViewLocator>();
.AddTransient<ViewLocator>()
.AddTransient<ISerializeService, JsonSerializationService>()
.AddTransient<IImageService, ImageService>()
.AddTransient<IUrlOpenerService, UrlOpenerService>()
.AddTransient<IFileSystemService, FileSystemService>()
.AddTransient(typeof(IPluginLoggerService<>), typeof(LoggingPluginAdapter<>));


}
}
3 changes: 3 additions & 0 deletions src/ModularToolManager/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<StreamGeometry x:Key="dismiss_regular">M3.52499419,3.71761187 L3.61611652,3.61611652 C4.0717282,3.16050485 4.79154862,3.13013074 5.28238813,3.52499419 L5.38388348,3.61611652 L14,12.233 L22.6161165,3.61611652 C23.1042719,3.12796116 23.8957281,3.12796116 24.3838835,3.61611652 C24.8720388,4.10427189 24.8720388,4.89572811 24.3838835,5.38388348 L15.767,14 L24.3838835,22.6161165 C24.8394952,23.0717282 24.8698693,23.7915486 24.4750058,24.2823881 L24.3838835,24.3838835 C23.9282718,24.8394952 23.2084514,24.8698693 22.7176119,24.4750058 L22.6161165,24.3838835 L14,15.767 L5.38388348,24.3838835 C4.89572811,24.8720388 4.10427189,24.8720388 3.61611652,24.3838835 C3.12796116,23.8957281 3.12796116,23.1042719 3.61611652,22.6161165 L12.233,14 L3.61611652,5.38388348 C3.16050485,4.9282718 3.13013074,4.20845138 3.52499419,3.71761187 L3.61611652,3.61611652 L3.52499419,3.71761187 Z</StreamGeometry>
<StreamGeometry x:Key="settings_regular">M14 9.50006C11.5147 9.50006 9.5 11.5148 9.5 14.0001C9.5 16.4853 11.5147 18.5001 14 18.5001C15.3488 18.5001 16.559 17.9066 17.3838 16.9666C18.0787 16.1746 18.5 15.1365 18.5 14.0001C18.5 13.5401 18.431 13.0963 18.3028 12.6784C17.7382 10.8381 16.0253 9.50006 14 9.50006ZM11 14.0001C11 12.3432 12.3431 11.0001 14 11.0001C15.6569 11.0001 17 12.3432 17 14.0001C17 15.6569 15.6569 17.0001 14 17.0001C12.3431 17.0001 11 15.6569 11 14.0001Z M21.7093 22.3948L19.9818 21.6364C19.4876 21.4197 18.9071 21.4515 18.44 21.7219C17.9729 21.9924 17.675 22.4693 17.6157 23.0066L17.408 24.8855C17.3651 25.273 17.084 25.5917 16.7055 25.682C14.9263 26.1061 13.0725 26.1061 11.2933 25.682C10.9148 25.5917 10.6336 25.273 10.5908 24.8855L10.3834 23.0093C10.3225 22.4731 10.0112 21.9976 9.54452 21.7281C9.07783 21.4586 8.51117 21.4269 8.01859 21.6424L6.29071 22.4009C5.93281 22.558 5.51493 22.4718 5.24806 22.1859C4.00474 20.8536 3.07924 19.2561 2.54122 17.5137C2.42533 17.1384 2.55922 16.7307 2.8749 16.4977L4.40219 15.3703C4.83721 15.0501 5.09414 14.5415 5.09414 14.0007C5.09414 13.4598 4.83721 12.9512 4.40162 12.6306L2.87529 11.5051C2.55914 11.272 2.42513 10.8638 2.54142 10.4882C3.08038 8.74734 4.00637 7.15163 5.24971 5.82114C5.51684 5.53528 5.93492 5.44941 6.29276 5.60691L8.01296 6.36404C8.50793 6.58168 9.07696 6.54881 9.54617 6.27415C10.0133 6.00264 10.3244 5.52527 10.3844 4.98794L10.5933 3.11017C10.637 2.71803 10.9245 2.39704 11.3089 2.31138C12.19 2.11504 13.0891 2.01071 14.0131 2.00006C14.9147 2.01047 15.8128 2.11485 16.6928 2.31149C17.077 2.39734 17.3643 2.71823 17.4079 3.11017L17.617 4.98937C17.7116 5.85221 18.4387 6.50572 19.3055 6.50663C19.5385 6.507 19.769 6.45838 19.9843 6.36294L21.7048 5.60568C22.0626 5.44818 22.4807 5.53405 22.7478 5.81991C23.9912 7.1504 24.9172 8.74611 25.4561 10.487C25.5723 10.8623 25.4386 11.2703 25.1228 11.5035L23.5978 12.6297C23.1628 12.95 22.9 13.4586 22.9 13.9994C22.9 14.5403 23.1628 15.0489 23.5988 15.3698L25.1251 16.4965C25.441 16.7296 25.5748 17.1376 25.4586 17.5131C24.9198 19.2536 23.9944 20.8492 22.7517 22.1799C22.4849 22.4657 22.0671 22.5518 21.7093 22.3948ZM16.263 22.1966C16.4982 21.4685 16.9889 20.8288 17.6884 20.4238C18.5702 19.9132 19.6536 19.8547 20.5841 20.2627L21.9281 20.8526C22.791 19.8538 23.4593 18.7013 23.8981 17.4552L22.7095 16.5778L22.7086 16.5771C21.898 15.98 21.4 15.0277 21.4 13.9994C21.4 12.9719 21.8974 12.0195 22.7073 11.4227L22.7085 11.4218L23.8957 10.545C23.4567 9.2988 22.7881 8.14636 21.9248 7.1477L20.5922 7.73425L20.5899 7.73527C20.1844 7.91463 19.7472 8.00722 19.3039 8.00663C17.6715 8.00453 16.3046 6.77431 16.1261 5.15465L16.1259 5.15291L15.9635 3.69304C15.3202 3.57328 14.6677 3.50872 14.013 3.50017C13.3389 3.50891 12.6821 3.57367 12.0377 3.69328L11.8751 5.15452C11.7625 6.16272 11.1793 7.05909 10.3019 7.56986C9.41937 8.0856 8.34453 8.14844 7.40869 7.73694L6.07273 7.14893C5.20949 8.14751 4.54092 9.29983 4.10196 10.5459L5.29181 11.4233C6.11115 12.0269 6.59414 12.9837 6.59414 14.0007C6.59414 15.0173 6.11142 15.9742 5.29237 16.5776L4.10161 17.4566C4.54002 18.7044 5.2085 19.8585 6.07205 20.8587L7.41742 20.2682C8.34745 19.8613 9.41573 19.9215 10.2947 20.4292C11.174 20.937 11.7593 21.832 11.8738 22.84L11.8744 22.8445L12.0362 24.3088C13.3326 24.5638 14.6662 24.5638 15.9626 24.3088L16.1247 22.8418C16.1491 22.6217 16.1955 22.4055 16.263 22.1966Z</StreamGeometry>
<StreamGeometry x:Key="flag_regular">M12.5,10.5 L34.60324,10.5 L30.4128926,17.8829931 C30.1957025,18.2656614 30.1957025,18.7343386 30.4128926,19.1170069 L34.60324,26.5 L12.5,26.5 L12.5,10.5 Z M12.5,29 L36.75,29 C37.7081614,29 38.3100612,27.9662926 37.8371074,27.1329931 L32.9373005,18.5 L37.8371074,9.8670069 C38.3100612,9.03370742 37.7081614,8 36.75,8 L11.25,8 C10.5596441,8 10,8.55964406 10,9.25 L10,38.75 C10,39.4403559 10.5596441,40 11.25,40 C11.9403559,40 12.5,39.4403559 12.5,38.75 L12.5,29 Z</StreamGeometry>
<StreamGeometry x:Key="add_circle_regular">M14,2 C20.627417,2 26,7.372583 26,14 C26,20.627417 20.627417,26 14,26 C7.372583,26 2,20.627417 2,14 C2,7.372583 7.372583,2 14,2 Z M14,3.5 C8.20101013,3.5 3.5,8.20101013 3.5,14 C3.5,19.7989899 8.20101013,24.5 14,24.5 C19.7989899,24.5 24.5,19.7989899 24.5,14 C24.5,8.20101013 19.7989899,3.5 14,3.5 Z M14,8 C14.4142136,8 14.75,8.33578644 14.75,8.75 L14.75,13.25 L19.25,13.25 C19.6642136,13.25 20,13.5857864 20,14 C20,14.4142136 19.6642136,14.75 19.25,14.75 L14.75,14.75 L14.75,19.25 C14.75,19.6642136 14.4142136,20 14,20 C13.5857864,20 13.25,19.6642136 13.25,19.25 L13.25,14.75 L8.75,14.75 C8.33578644,14.75 8,14.4142136 8,14 C8,13.5857864 8.33578644,13.25 8.75,13.25 L13.25,13.25 L13.25,8.75 C13.25,8.33578644 13.5857864,8 14,8 Z</StreamGeometry>
<StreamGeometry x:Key="edit_regular">M27.3138 4.68622C28.8759 6.24832 28.8759 8.78098 27.3138 10.3431L12.5409 25.116C11.9001 25.7568 11.0972 26.2114 10.218 26.4312L5.63602 27.5767C4.90364 27.7598 4.24025 27.0964 4.42335 26.364L5.56885 21.782C5.78864 20.9028 6.24323 20.0999 6.88402 19.4591L21.6569 4.68622C23.219 3.12412 25.7517 3.12412 27.3138 4.68622ZM20.2426 8.92865L8.29824 20.8734C7.91376 21.2578 7.641 21.7396 7.50913 22.2671L6.76786 25.2322L9.73295 24.4909C10.2604 24.359 10.7422 24.0863 11.1267 23.7018L23.0706 11.7566L20.2426 8.92865ZM23.0712 6.10043L21.6566 7.51465L24.4846 10.3426L25.8996 8.92886C26.6806 8.14781 26.6806 6.88148 25.8996 6.10043C25.1185 5.31939 23.8522 5.31939 23.0712 6.10043Z</StreamGeometry>
<StreamGeometry x:Key="delete_regular">M24,7.25 C27.1017853,7.25 29.629937,9.70601719 29.7458479,12.7794443 L29.75,13 L37,13 C37.6903559,13 38.25,13.5596441 38.25,14.25 C38.25,14.8972087 37.7581253,15.4295339 37.1278052,15.4935464 L37,15.5 L35.909,15.5 L34.2058308,38.0698451 C34.0385226,40.2866784 32.1910211,42 29.9678833,42 L18.0321167,42 C15.8089789,42 13.9614774,40.2866784 13.7941692,38.0698451 L12.09,15.5 L11,15.5 C10.3527913,15.5 9.8204661,15.0081253 9.75645361,14.3778052 L9.75,14.25 C9.75,13.6027913 10.2418747,13.0704661 10.8721948,13.0064536 L11,13 L18.25,13 C18.25,9.82436269 20.8243627,7.25 24,7.25 Z M33.4021054,15.5 L14.5978946,15.5 L16.2870795,37.8817009 C16.3559711,38.7945146 17.116707,39.5 18.0321167,39.5 L29.9678833,39.5 C30.883293,39.5 31.6440289,38.7945146 31.7129205,37.8817009 L33.4021054,15.5 Z M27.25,20.75 C27.8972087,20.75 28.4295339,21.2418747 28.4935464,21.8721948 L28.5,22 L28.5,33 C28.5,33.6903559 27.9403559,34.25 27.25,34.25 C26.6027913,34.25 26.0704661,33.7581253 26.0064536,33.1278052 L26,33 L26,22 C26,21.3096441 26.5596441,20.75 27.25,20.75 Z M20.75,20.75 C21.3972087,20.75 21.9295339,21.2418747 21.9935464,21.8721948 L22,22 L22,33 C22,33.6903559 21.4403559,34.25 20.75,34.25 C20.1027913,34.25 19.5704661,33.7581253 19.5064536,33.1278052 L19.5,33 L19.5,22 C19.5,21.3096441 20.0596441,20.75 20.75,20.75 Z M24,9.75 C22.2669685,9.75 20.8507541,11.1064548 20.7551448,12.8155761 L20.75,13 L27.25,13 C27.25,11.2050746 25.7949254,9.75 24,9.75 Z</StreamGeometry>
</Style.Resources>
</Style>
</Styles>
45 changes: 45 additions & 0 deletions src/ModularToolManager/Properties/Properties.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/ModularToolManager/Properties/Properties.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@
<data name="GithubUrl" xml:space="preserve">
<value>https://github.com/XanatosX/ModularToolManager/issues</value>
</data>
<data name="Icon_edit_function" xml:space="preserve">
<value>edit_regular</value>
</data>
<data name="Icon_hide" xml:space="preserve">
<value>eye_hide_regular</value>
</data>
<data name="Icon_language" xml:space="preserve">
<value>flag_regular</value>
</data>
<data name="Icon_new_function" xml:space="preserve">
<value>add_circle_regular</value>
</data>
<data name="Icon_settings" xml:space="preserve">
<value>settings_regular</value>
</data>
<data name="SettingsFile" xml:space="preserve">
<value>settings.set</value>
</data>
Expand Down
33 changes: 30 additions & 3 deletions src/ModularToolManager/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/ModularToolManager/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
<data name="Menu_File" xml:space="preserve">
<value>Datei</value>
</data>
<data name="Menu_ReportBug" xml:space="preserve">
<value>Fehler Melden</value>
<data name="Menu_Help" xml:space="preserve">
<value>Hilfe</value>
</data>
<data name="NewFunction_Description" xml:space="preserve">
<value>Funktionsbeschreibung</value>
Expand All @@ -159,18 +159,27 @@
<data name="Settings_StartMinimized" xml:space="preserve">
<value>Minimiert starten</value>
</data>
<data name="SubMenu_About" xml:space="preserve">
<value>Über</value>
</data>
<data name="SubMenu_Exit" xml:space="preserve">
<value>Beenden</value>
</data>
<data name="SubMenu_Hide" xml:space="preserve">
<value>Verstecken</value>
</data>
<data name="SubMenu_Hotkeys" xml:space="preserve">
<value>Hotkeys</value>
</data>
<data name="SubMenu_Language" xml:space="preserve">
<value>Sprache</value>
</data>
<data name="SubMenu_NewFunction" xml:space="preserve">
<value>Neue Funktion</value>
</data>
<data name="SubMenu_ReportBug" xml:space="preserve">
<value>Fehler Melden</value>
</data>
<data name="SubMenu_Settings" xml:space="preserve">
<value>Einstellungen</value>
</data>
Expand Down
13 changes: 11 additions & 2 deletions src/ModularToolManager/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
<data name="Menu_File" xml:space="preserve">
<value>File</value>
</data>
<data name="Menu_ReportBug" xml:space="preserve">
<value>Report Bug</value>
<data name="Menu_Help" xml:space="preserve">
<value>Help</value>
</data>
<data name="NewFunction_Description" xml:space="preserve">
<value>Function Description</value>
Expand All @@ -165,18 +165,27 @@
<data name="Settings_StartMinimized" xml:space="preserve">
<value>Start minimized</value>
</data>
<data name="SubMenu_About" xml:space="preserve">
<value>About</value>
</data>
<data name="SubMenu_Exit" xml:space="preserve">
<value>Exit</value>
</data>
<data name="SubMenu_Hide" xml:space="preserve">
<value>Hide</value>
</data>
<data name="SubMenu_Hotkeys" xml:space="preserve">
<value>Hotkeys</value>
</data>
<data name="SubMenu_Language" xml:space="preserve">
<value>Language</value>
</data>
<data name="SubMenu_NewFunction" xml:space="preserve">
<value>New Function</value>
</data>
<data name="SubMenu_ReportBug" xml:space="preserve">
<value>Report Bug</value>
</data>
<data name="SubMenu_Settings" xml:space="preserve">
<value>Settings</value>
</data>
Expand Down
25 changes: 25 additions & 0 deletions src/ModularToolManager/Services/Ui/IImageService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Avalonia.Media;
using Avalonia.Media.Imaging;

namespace ModularToolManager.Services.Ui;

/// <summary>
/// Service to get bitmap images from stream geometry
/// </summary>
public interface IImageService
{
/// <summary>
/// Create a bitmap with a black brush
/// </summary>
/// <param name="streamGeometry">The geometry to convert</param>
/// <returns>If a bitmap could be generated the generated bitmap otherwise null</returns>
Bitmap? CreateBitmap(StreamGeometry streamGeometry) => CreateBitmap(streamGeometry, new SolidColorBrush(Color.FromRgb(0, g: 0, 0)));

/// <summary>
/// Create a bitmap with a brush
/// </summary>
/// <param name="streamGeometry">The geometry to convert</param>
/// <param name="brush">The brush to use</param>
/// <returns>If a bitmap could be generated the generated bitmap otherwise null</returns>
Bitmap? CreateBitmap(StreamGeometry streamGeometry, Brush brush);
}
41 changes: 41 additions & 0 deletions src/ModularToolManager/Services/Ui/ImageService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Avalonia;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using System.IO;

namespace ModularToolManager.Services.Ui;

/// <summary>
/// Implementation of the image service interface
/// </summary>
public class ImageService : IImageService
{
/// <inheritdoc/>
public Bitmap? CreateBitmap(StreamGeometry streamGeometry, Brush brush)
{
var testImage = new DrawingImage
{
Drawing = new GeometryDrawing
{
Geometry = streamGeometry,
Brush = brush
}
};
var pixelSize = new PixelSize((int)testImage.Size.Width, (int)testImage.Size.Height);
Bitmap? returnImage = null;
using (MemoryStream memoryStream = new())
{
using (RenderTargetBitmap bitmap = new(pixelSize, new Vector(72, 72)))
{
using (DrawingContext ctx = new(bitmap.CreateDrawingContext(null)))
{
testImage.Drawing.Draw(ctx);
}
bitmap.Save(memoryStream);
}
memoryStream.Seek(0, SeekOrigin.Begin);
returnImage = new Bitmap(memoryStream);
}
return returnImage;
}
}
Loading