Catalog/imagecatalog/AvaloniaViews/LogoTabView.axaml.cs
MaddoScientisto 90fb03bf0c Add new tab views for image catalog functionality
- Implement GeneralTabView for source and destination path settings, options, processing parameters, and image library selection.
- Create LogoTabView for logo selection, preview, and positioning options.
- Add PhotoTabView for photo dimensions and JPEG quality settings.
- Introduce RaceUploadTabView for race setup and processed photo upload functionality, including API integration.
- Develop TextTabView for horizontal and vertical text settings, font options, and race time configuration.
- Implement ThumbnailsTabView for thumbnail creation options and settings.
2026-02-28 21:48:05 +01:00

62 lines
1.5 KiB
C#

using Avalonia.Controls;
using Avalonia.Media.Imaging;
using System.ComponentModel;
using System.IO;
namespace ImageCatalog_2.AvaloniaViews;
public partial class LogoTabView : Avalonia.Controls.UserControl
{
public LogoTabView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
}
private void OnDataContextChanged(object? sender, System.EventArgs e)
{
if (sender is not LogoTabView)
{
return;
}
if (DataContext is DataModel model)
{
model.PropertyChanged -= ModelOnPropertyChanged;
model.PropertyChanged += ModelOnPropertyChanged;
UpdateLogoPreview(model.LogoFile);
}
}
private void ModelOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(DataModel.LogoFile) && sender is DataModel model)
{
UpdateLogoPreview(model.LogoFile);
}
}
private void UpdateLogoPreview(string? path)
{
var preview = this.FindControl<Avalonia.Controls.Image>("LogoPreview");
if (preview is null)
{
return;
}
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path))
{
preview.Source = null;
return;
}
try
{
preview.Source = new Avalonia.Media.Imaging.Bitmap(path);
}
catch
{
preview.Source = null;
}
}
}