Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeAkei committed Apr 3, 2024
1 parent f902731 commit 8e518c5
Show file tree
Hide file tree
Showing 262 changed files with 124 additions and 3,263 deletions.
2 changes: 1 addition & 1 deletion DeXAMLize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private async Task LoadXAML()
if(filePathXAML == "") return;


var obj = AvaloniaRuntimeXamlLoader.Load(ExternalXAML, typeof(MainWindow).Assembly) as Canvas;
var obj = AvaloniaRuntimeXamlLoader.Load(ExternalXAML, typeof(MainWindow).Assembly) as Canvas;


var buf = new List<JControl>();
Expand Down
6 changes: 5 additions & 1 deletion ElementGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public void GenerateElement(object? sender, RoutedEventArgs e)
element.PointerReleased += OnjControlReleased;

parent.AddChild(element);
selectedTreeItem.Items.Add(new mTreeViewItem(element));
var item = new mTreeViewItem(element);
selectedTreeItem.Items.Add(item);
(((JControl)(item.element.jParent))!).mTreeItem.IsExpanded = true;


}

public static void SetDefaultValues(JControl element)
Expand Down
32 changes: 32 additions & 0 deletions IgnTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Xamlade;


public class IgnoredTypesConverter<T> : JsonConverter<T>
{
private readonly HashSet<Type> ignoredTypes;

public IgnoredTypesConverter(HashSet<Type> ignoredTypes)
{
this.ignoredTypes = ignoredTypes;
}

public override bool CanConvert(Type typeToConvert)
{
return !ignoredTypes.Contains(typeToConvert);
}

public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return JsonSerializer.Deserialize<T>(ref reader, options);
}

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
}
Empty file added IgnoredTypeConverter.cs
Empty file.
1 change: 0 additions & 1 deletion MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:xamlade="clr-namespace:Xamlade"

xmlns:gif="clr-namespace:Avalonia.Gif;assembly=Avalonia.Gif"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:avaloniaColorPicker="clr-namespace:AvaloniaColorPicker;assembly=AvaloniaColorPicker"
Height="800" Width="1200"
x:Class="Xamlade.MainWindow"
Expand Down
36 changes: 29 additions & 7 deletions MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
Expand All @@ -19,6 +23,7 @@
using Avalonia.Media.Imaging;
using AvaloniaColorPicker;
using Avalonia.Markup;
using Microsoft.Diagnostics.Runtime;

namespace Xamlade;

Expand Down Expand Up @@ -91,10 +96,8 @@ private void GlobalKeyReleased(KeyEventArgs e)
RemovejElement(null,null);
}


//Переписать с привязкой к родителю

//Всё к хуям заново


private void jCanvas_OnPointerMoved(object? sender, PointerEventArgs e)
{
if (movable == null || Equals((JControl)sender!, movable) || Equals(movable, MainCanvas))
Expand Down Expand Up @@ -232,6 +235,7 @@ private void ShowProperties()
// Выбрать редактируемый элемент
private void SelectjElement(JControl element)
{
if ((element is null) || (element.Name == null)) return;
selectedTreeItem = element.mTreeItem;
MainHierarchyTree.SelectedItem = selectedTreeItem;
selectedOriginalBackground = selectedTreeItem.element.Background;
Expand Down Expand Up @@ -273,10 +277,15 @@ private void RemovejElement(object? sender, RoutedEventArgs? e)
{
if (selectedTreeItem == MainCanvas.mTreeItem) return;
var element = selectedTreeItem.element;
element.Dispose();
selectedTreeItem.element.jParent.RemoveChild(selectedTreeItem.element);
var jparent = selectedTreeItem.element.jParent;
jparent.RemoveChild(selectedTreeItem.element);
var parent = selectedTreeItem.Parent as mTreeViewItem;
parent.Items.Remove(selectedTreeItem);
//FIXME поставить поочередное удаление детей
MainHierarchyTree.SelectedItem = (jparent.jChildren.Count > 0) ? jparent.jChildren.Last().mTreeItem : ((JControl)jparent).mTreeItem;

// MainHierarchyTree.SelectedItem=selectedTreeItem.element.mTreeItem;
element.Dispose();
}

private void OnjControlPressed(object? sender, PointerPressedEventArgs e)
Expand Down Expand Up @@ -360,7 +369,6 @@ private void OnBoolPropertyChanged(object? sender, RoutedEventArgs e)
var txt_blc = parentPanel.Children[0] as TextBlock;
var prop_name = txt_blc.Text;
Type jElement_type = selectedTreeItem.element.GetType();
var prop_type = jElement_type.GetProperty(prop_name).PropertyType;
var prop = jElement_type.GetProperty(prop_name);
prop.SetValue(selectedTreeItem.element, checkBox.IsChecked);
}
Expand Down Expand Up @@ -496,9 +504,23 @@ private async void DEXAMLIZE(object? sender, RoutedEventArgs e)

}

public System.String ass;

private void DEBUG(object? sender, RoutedEventArgs e)
{
Console.WriteLine(selectedTreeItem.element.Name);
/* var ignoredTypes = new HashSet<Type> { typeof(ContentPresenter) };
var options = new JsonSerializerOptions
{
ReferenceHandler = ReferenceHandler.Preserve,
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
};
options.Converters.Add(new IgnoredTypesConverter<jButton>(ignoredTypes));
string json = JsonSerializer.Serialize((jButton)selectedTreeItem.element, options);
var t = new jButton();
Console.WriteLine(json);
*/
}
}
26 changes: 26 additions & 0 deletions Reflector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using Avalonia;
using Microsoft.Diagnostics.Runtime;
using System.Runtime.InteropServices;

namespace Xamlade;

Expand All @@ -15,4 +20,25 @@ public static void SetName(string? name, JControl element)
typeof(StyledElement).GetField("_name", BindingFlags.NonPublic | BindingFlags.Instance);
privateField.SetValue(element, name);
}


public static void PrintFieldsForType(ClrRuntime runtime, string targetType)
{
int i = 0;
ClrHeap heap = runtime.Heap;
foreach (var ptr in heap.EnumerateObjects())
{
ClrType type = heap.GetObjectType(ptr);
if (type.Name == targetType)
{
i++;
}
}
Console.WriteLine(targetType+": "+i);
}





}
24 changes: 15 additions & 9 deletions Xamlade.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand All @@ -10,19 +10,24 @@


<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" />
<PackageReference Include="Avalonia" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0-beta1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta1" />
<PackageReference Include="AvaloniaColorPicker" Version="1.4.0" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" />
<PackageReference Include="Material.Avalonia" Version="3.0.2" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview1" />
<PackageReference Include="Material.Avalonia" Version="3.4.4-nightly.0.5" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="3.1.512801" />
</ItemGroup>


<ItemGroup>
<AdditionalFiles Include="**\*.xaml" />
</ItemGroup>

<ItemGroup>
<None Remove="Xamlade.png" />
<None Remove="Avalonia.AXAML.LanguageServer.Log20231031.txt" />
Expand All @@ -44,6 +49,7 @@
<ItemGroup>
<Compile Remove="bin\**" />
<Compile Remove="TestWindow.axaml.cs" />
<Compile Remove="IgnoredTypeConverter.cs" />
</ItemGroup>


Expand Down
1 change: 1 addition & 0 deletions Xamlade.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fakei_002FProjects_002FXamlade_002FXamlade_002FAvalonia_002EGIF_002FAvaloniaGif_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fakei_002FProjects_002FXamlade_002FXamlade_002FAvalonia_002EGIF_002FAvalonia_002EGif_002Edll/@EntryIndexedValue">True</s:Boolean>

<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;
&lt;Assembly Path="/home/akei/.nuget/packages/citrus.avalonia/1.6.1/lib/netstandard2.0/Citrus.Avalonia.dll" /&gt;
&lt;Assembly Path="/home/akei/.nuget/packages/semi.avalonia/11.0.1/lib/net6.0/Semi.Avalonia.dll" /&gt;
Expand Down
Binary file removed bin/Debug/net8.0/Avalonia.Base.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Controls.ColorPicker.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Controls.DataGrid.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Controls.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.DesignerSupport.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Desktop.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Diagnostics.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Dialogs.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Fonts.Inter.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.FreeDesktop.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Gif.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Gif.pdb
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Markup.Xaml.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Markup.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Metal.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.MicroCom.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Native.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.OpenGL.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Remote.Protocol.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Skia.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Themes.Fluent.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Themes.Simple.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.Win32.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.X11.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Avalonia.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/HarfBuzzSharp.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Material.Avalonia.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Material.Colors.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Material.Ripple.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Material.Styles.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/MicroCom.Runtime.dll
Binary file not shown.
Binary file not shown.
Binary file removed bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.dll
Binary file not shown.
Binary file not shown.
Binary file removed bin/Debug/net8.0/Microsoft.CodeAnalysis.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Microsoft.Win32.SystemEvents.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/SkiaSharp.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/System.Drawing.Common.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/System.IO.Pipelines.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/System.Reactive.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Tmds.DBus.Protocol.dll
Binary file not shown.
Binary file removed bin/Debug/net8.0/Xamlade
Binary file not shown.
Loading

0 comments on commit 8e518c5

Please sign in to comment.