94 lines
2.3 KiB
C#
94 lines
2.3 KiB
C#
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
using LibS7Adv;
|
|||
|
using System.Windows;
|
|||
|
using System.Windows.Controls;
|
|||
|
using System.Windows.Media;
|
|||
|
using CtrEditor.FuncionesBase;
|
|||
|
using System.ComponentModel;
|
|||
|
using Newtonsoft.Json;
|
|||
|
|
|||
|
namespace CtrEditor.ObjetosSim
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// A custom image control that can display an image from a file path
|
|||
|
/// </summary>
|
|||
|
public partial class osCustomImage : osBase, IosBase
|
|||
|
{
|
|||
|
public static string NombreClase()
|
|||
|
{
|
|||
|
return "Custom Image";
|
|||
|
}
|
|||
|
|
|||
|
private string nombre = NombreClase();
|
|||
|
public override string Nombre
|
|||
|
{
|
|||
|
get => nombre;
|
|||
|
set => SetProperty(ref nombre, value);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
[ObservableProperty]
|
|||
|
[NotifyPropertyChangedFor(nameof(ImageSource_oculta))]
|
|||
|
[property: Description("Path to the image file")]
|
|||
|
[property: Category("Image:")]
|
|||
|
private string imagePath;
|
|||
|
|
|||
|
|
|||
|
[JsonIgnore]
|
|||
|
[ObservableProperty]
|
|||
|
public ImageSource imageSource_oculta;
|
|||
|
|
|||
|
partial void OnImagePathChanged(string value)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(value))
|
|||
|
{
|
|||
|
ImageSource_oculta = ImageFromPath(value);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public osCustomImage()
|
|||
|
{
|
|||
|
Ancho = 0.30f;
|
|||
|
Alto = 0.30f;
|
|||
|
}
|
|||
|
|
|||
|
public override void ucLoaded()
|
|||
|
{
|
|||
|
base.ucLoaded();
|
|||
|
if (!string.IsNullOrEmpty(ImagePath))
|
|||
|
{
|
|||
|
ImageSource_oculta = ImageFromPath(ImagePath);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public partial class ucCustomImage : UserControl, IDataContainer
|
|||
|
{
|
|||
|
public osBase? Datos { get; set; }
|
|||
|
public int zIndex_fromFrames { get; set; }
|
|||
|
|
|||
|
public ucCustomImage()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
this.Loaded += OnLoaded;
|
|||
|
this.Unloaded += OnUnloaded;
|
|||
|
}
|
|||
|
|
|||
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
Datos?.ucLoaded();
|
|||
|
}
|
|||
|
|
|||
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
Datos?.ucUnLoaded();
|
|||
|
}
|
|||
|
|
|||
|
public void Highlight(bool State) { }
|
|||
|
|
|||
|
public ZIndexEnum ZIndex_Base()
|
|||
|
{
|
|||
|
return ZIndexEnum.Estaticos;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|