diff --git a/ElementGenerator.cs b/ElementGenerator.cs index fd1d365..be75a8b 100644 --- a/ElementGenerator.cs +++ b/ElementGenerator.cs @@ -14,6 +14,7 @@ using Avalonia.Media; using Avalonia.Styling; using Avalonia.Controls.Primitives; +using Avalonia.Media.Imaging; namespace Xamlade; @@ -70,6 +71,16 @@ public static void SetDefaultValues(JControl element) ((jTextBlock)element).Foreground = Brushes.White; } break; + case ControlType.Image: + { + + ((jImage)element).Source = new Bitmap("assets/Xamlade.png"); + ((jImage)element).Width = 400; + ((jImage)element).Height = 400; + ((jImage)element).jImageSource = @"assets/Xamlade.png"; + ((jImage)element).Background = Brushes.Blue; + } + break; case ControlType.ToggleButton: { // ((jTextBlock)element).Background = Brushes.Blue; diff --git a/MainWindow.axaml b/MainWindow.axaml index 29e25cb..76533d0 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -26,6 +26,7 @@ PropertyChanged="StrictModeEnabled_OnPropertyChanged" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalContentAlignment="Center"/> + @@ -55,6 +56,8 @@ Margin="10,0,10,10" /> - - - - - - - + + diff --git a/bin/Debug/net8.0/XamladeDemo/XamladeDemo.csproj b/bin/Debug/net8.0/XamladeDemo/XamladeDemo.csproj index 96faadb..8ab02d8 100644 --- a/bin/Debug/net8.0/XamladeDemo/XamladeDemo.csproj +++ b/bin/Debug/net8.0/XamladeDemo/XamladeDemo.csproj @@ -17,4 +17,21 @@ + + + + + PreserveNewest + + + + + + + + + + + + diff --git a/jElement.cs b/jElement.cs index a9ed484..6dad96a 100644 --- a/jElement.cs +++ b/jElement.cs @@ -41,7 +41,8 @@ public enum ControlType Slider, TextBox, ToggleButton, - TextBlock + TextBlock, + Image } @@ -188,6 +189,34 @@ private void XAMLize(int mode) } +public class jImage : Image, JControl +{ + protected override Type StyleKeyOverride => typeof(Image); + public jImage() + { + Broadcast.OnBroadcast += XAMLize; + XAMLPiece = new List(); + } + public IChildContainer? jParent { get; set; } + private ControlType controlType => ControlType.Image; + public object Type => controlType; + public mTreeViewItem? mTreeItem { get; set; } + public int XAMLRating { get; set; } + public List XAMLPiece { get; set; } + public IBrush? Background { get; set; } + public bool IsPressed { get; set; } + public event EventHandler? Click; + + public string? jImageSource { get; set; } + + private void XAMLize(int mode) + { + if(mode == 0) XAMLGenerator.XAMLRatingInit(this); + else if (mode == 1) XAMLGenerator.XAMLize(this); + } +} + + public class jToggleButton : ToggleButton, JControl { protected override Type StyleKeyOverride => typeof(ToggleButton);