-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added image support to controlStatic
- Loading branch information
Showing
4 changed files
with
68 additions
and
6 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
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
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
45 changes: 45 additions & 0 deletions
45
Arma.Studio.UiEditor/UI/Converters/ControlTextImageConverter.cs
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,45 @@ | ||
using Arma.Studio.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace Arma.Studio.UiEditor.UI.Converters | ||
{ | ||
public class ControlTextImageConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is string str) | ||
{ | ||
str = str.TrimStart('\\', '/', ' ', '\t'); | ||
var pbo = (Application.Current as IApp).MainWindow.FileManagement.FirstOrDefault((it) => str.StartsWith(it.FullPath, StringComparison.InvariantCultureIgnoreCase) || str.StartsWith(it.Prefix, StringComparison.InvariantCultureIgnoreCase)); | ||
if (pbo is null) | ||
{ | ||
return null; | ||
} | ||
if (str.StartsWith(pbo.Prefix)) | ||
{ | ||
return System.IO.Path.Combine(pbo.FullPath, str.Substring(pbo.Prefix.Length).TrimStart('\\', '/', ' ', '\t')); | ||
} | ||
else | ||
{ | ||
return str; | ||
} | ||
} | ||
else | ||
{ | ||
return value; | ||
} | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |