Skip to content
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
7 changes: 0 additions & 7 deletions Svg.Editor.Avalonia.Forms/Dialog/UserInteractionServiceExt.cs

This file was deleted.

8 changes: 7 additions & 1 deletion Svg.Editor.Avalonia.Forms/Services/ColorInputService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ namespace Svg.Editor.Avalon.Forms.Services
{
public class ColorInputService : Editor.Tools.IColorInputService
{
private readonly IUserInteraction _userInteractionService;

public ColorInputService()
{
_userInteractionService = SvgEngine.Resolve<IUserInteraction>();
}
public async Task<string> GetHexaColorFromUserInput(string title)
{
var result = await UserInteractionServiceExt.UserInteractionInst.ColorPickerAsync(title);
var result = await _userInteractionService.ColorPickerAsync(title);

if (result == null)
return "#000000";
Expand Down
19 changes: 14 additions & 5 deletions Svg.Editor.Avalonia.Forms/Services/MarkerOptionsInputService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Svg.Editor.Avalon.Forms.Dialog;
using Svg.Editor.Interfaces;
using Svg.Editor.Tools;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,22 +9,30 @@ namespace Svg.Editor.Avalon.Forms.Services
{
public class MarkerOptionsInputService : IMarkerOptionsInputService
{
public async Task<int[]> GetUserInput(string title, IEnumerable<string> markerStartOptions, int markerStartSelected, IEnumerable<string> markerEndOptions,
int markerEndSelected)
private readonly ILocalizationService _localizationService;
private readonly IUserInteraction _userInteractionService;


public MarkerOptionsInputService()
{
_localizationService = SvgEngine.Resolve<ILocalizationService>();
Comment thread
Zeljko-Predjeskovic marked this conversation as resolved.
_userInteractionService = SvgEngine.Resolve<IUserInteraction>();
}

public async Task<int[]> GetUserInput(IEnumerable<string> markerStartOptions, int markerStartSelected, IEnumerable<string> markerEndOptions,
int markerEndSelected)
{

var mso = markerStartOptions.ToList();
var start = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync(title, mso.ToArray());
var start = await _userInteractionService.ActionSheetAsync(_localizationService.GetString("Svg.Editor.Marker.Options.Start"), mso.ToArray(), cancelButton: _localizationService.GetString("Svg.Editor.Global.Cancel"), cancellable: true);

await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync(title, mso.ToArray());

var startIndex = mso.IndexOf(start);
if (start == null || startIndex < 0)
return new[] { markerStartSelected, markerEndSelected };

var meo = markerEndOptions.ToList();
var end = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync(title, mso.ToArray());
var end = await _userInteractionService.ActionSheetAsync(_localizationService.GetString("Svg.Editor.Marker.Options.End"), meo.ToArray(), cancelButton: _localizationService.GetString("Svg.Editor.Global.Cancel"), cancellable: true);

var endIndex = meo.IndexOf(end);
if (end == null || endIndex < 0)
Expand Down
12 changes: 10 additions & 2 deletions Svg.Editor.Avalonia.Forms/Services/PinInputService.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
using Avalonia.Controls;
using Svg.Editor.Avalon.Forms.Dialog;
using Svg.Editor.Interfaces;
using Svg.Editor.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Svg.Editor.Avalon.Forms.Dialog;

namespace Svg.Editor.Avalon.Forms.Services
{
public class PinInputService : IPinInputService
{
private readonly IUserInteraction _userInteractionService;


public PinInputService()
{
_userInteractionService = SvgEngine.Resolve<IUserInteraction>();
}
public async Task<PinTool.PinSize> GetUserInput(IEnumerable<string> pinSizeOptions, int oldSizeIndex = 1)
{
var defaultResult = (PinTool.PinSize)oldSizeIndex;

var sizeResult = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync("Select pin size", pinSizeOptions.ToArray());
var sizeResult = await _userInteractionService.ActionSheetAsync("Select pin size", pinSizeOptions.ToArray());
PinTool.PinSize.Medium.ToString();

if (sizeResult == "Cancel")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,34 @@
using System.Threading.Tasks;
using Avalonia.Controls;
using Svg.Editor.Avalon.Forms.Dialog;
using Svg.Editor.Interfaces;
using Svg.Editor.Tools;

namespace Svg.Editor.Avalon.Forms.Services
{
public class StrokeStyleOptionsInputService : IStrokeStyleOptionsInputService
{
private readonly ILocalizationService _localizationService;
private readonly IUserInteraction _userInteractionService;

public StrokeStyleOptionsInputService()
{
_localizationService = SvgEngine.Resolve<ILocalizationService>();
_userInteractionService = SvgEngine.Resolve<IUserInteraction>();

}

public async Task<StrokeStyleTool.StrokeStyleOptions> GetUserInput(string title, IEnumerable<string> strokeDashOptions, int strokeDashSelected, IEnumerable<string> strokeWidthOptions,
int strokeWidthSelected)
{
var dashes = strokeDashOptions.ToArray();
var dash = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync(title, dashes);
var dash = await _userInteractionService.ActionSheetAsync(title, dashes, cancelButton: _localizationService.GetString("Svg.Editor.Global.Cancel"), cancellable: true);

if (dash == null || dash == "cancel")
if (dash == null)
return null;
var widths = strokeWidthOptions.ToArray();
var width = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync(title, widths);
if (width == null || width == "cancel")
var width = await _userInteractionService.ActionSheetAsync(title, widths, cancelButton: _localizationService.GetString("Svg.Editor.Global.Cancel"), cancellable: true);
if (width == null)
return null;
return new StrokeStyleTool.StrokeStyleOptions() { StrokeDashIndex = Array.IndexOf(dashes, dash), StrokeWidthIndex = Array.IndexOf(widths, width) };
}
Expand Down
12 changes: 9 additions & 3 deletions Svg.Editor.Avalonia.Forms/Services/TextInputService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ namespace Svg.Editor.Avalon.Forms.Services
{
public class TextInputService : ITextInputService
{
private readonly IUserInteraction _userInteractionService;

public TextInputService()
{
_userInteractionService = SvgEngine.Resolve<IUserInteraction>();
}
public async Task<TextTool.TextProperties> GetUserInput(string title, string textValue = "",
IEnumerable<string> textSizeOptions = null, int textSizeSelected = 0, int maxTextLength = -1)
{
var result = await UserInteractionServiceExt.UserInteractionInst.InputAsync("Text edit", title, "Ok", "Cancel", textValue, placeholder: "Enter text");
var result = await _userInteractionService.InputAsync("Text edit", title, "Ok", "Cancel", textValue, placeholder: "Enter text");
if (maxTextLength != -1)
{
while (result.Text.Length > 2)
{
result = await UserInteractionServiceExt.UserInteractionInst.InputAsync("Text edit", title, "Ok", "Cancel", textValue, placeholder: "Enter text");
result = await _userInteractionService.InputAsync("Text edit", title, "Ok", "Cancel", textValue, placeholder: "Enter text");
}
}
var defaultResult = new TextTool.TextProperties
Expand All @@ -36,7 +42,7 @@ public class TextInputService : ITextInputService
int sizeIndex = textSizeSelected;
if (textSizeOptions != null)
{
var sizeResult = await UserInteractionServiceExt.UserInteractionInst.ActionSheetAsync("Font size", textSizeOptions.ToArray());
var sizeResult = await _userInteractionService.ActionSheetAsync("Font size", textSizeOptions.ToArray());

sizeIndex = textSizeOptions.ToList().IndexOf(sizeResult);
sizeIndex = sizeIndex >= 0 ? sizeIndex : textSizeSelected;
Expand Down
4 changes: 3 additions & 1 deletion Svg.Editor.Avalonia.Forms/Svg.Editor.Avalon.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>3.2.0-optiq01</Version>
<Version>3.2.0-optiq04</Version>
<PackageReleaseNotes>
#3.2.0-optiq04
Improved marker options input service and StrokeStyleOptionsInputService
#3.2.0-optiq01
Moved to avalonia 12
#3.1.4-optiq01
Expand Down
2 changes: 2 additions & 0 deletions Svg.Editor.Avalonia.Forms/SvgEditorForms.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls.Templates;
using Svg.Editor.Avalon.Forms.Dialog;
using Svg.Editor.Avalon.Forms.Services;
using Svg.Editor.Avalon.Forms.ToolBar;
using Svg.Editor.Interfaces;
Expand Down Expand Up @@ -30,6 +31,7 @@ public static void Init(Avalonia.Application app)
SvgEngine.Register<IPickImageService>(() => new FormsPickImageService());
SvgEngine.Register<IPinInputService>(() => new PinInputService());
SvgEngine.Register<IToolTipInfoService>(() => new ToolTipInfoService());
SvgEngine.Register<IUserInteraction>(() => new UserInteractionService());

app.DataTemplates.Add(new MenuItemHeaderTemplate());

Expand Down
4 changes: 3 additions & 1 deletion Svg.Editor.Avalonia.Views/Svg.Editor.Avalon.Views.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>3.2.0-optiq01</Version>
<Version>3.2.0-optiq04</Version>
<PackageReleaseNotes>
#3.2.0-optiq04
Improved marker options input service and StrokeStyleOptionsInputService
#3.2.0-optiq01
Moved to avalonia 12
#3.1.4-optiq01
Expand Down
Loading
Loading