2025-02-24 07:37:52 -03:00
|
|
|
|
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);
|
|
|
|
|
}
|
2025-02-24 12:33:27 -03:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Si no hay path, usar la imagen por defecto
|
|
|
|
|
ImageSource_oculta = ImageFromPath("/Icons/unselect.png");
|
|
|
|
|
}
|
2025-02-24 07:37:52 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public osCustomImage()
|
|
|
|
|
{
|
|
|
|
|
Ancho = 0.30f;
|
|
|
|
|
Alto = 0.30f;
|
2025-02-24 12:33:27 -03:00
|
|
|
|
// Establecer la imagen por defecto al crear el objeto
|
|
|
|
|
ImageSource_oculta = ImageFromPath("/Icons/unselect.png");
|
2025-02-24 07:37:52 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
base.ucLoaded();
|
|
|
|
|
if (!string.IsNullOrEmpty(ImagePath))
|
|
|
|
|
{
|
|
|
|
|
ImageSource_oculta = ImageFromPath(ImagePath);
|
|
|
|
|
}
|
2025-02-24 12:33:27 -03:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Si no hay path al cargar, usar la imagen por defecto
|
|
|
|
|
ImageSource_oculta = ImageFromPath("/Icons/unselect.png");
|
|
|
|
|
}
|
2025-02-24 07:37:52 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|