commit 29ec6e9fffa972871afbb6f9794949b4fb7f4bb1 Author: Timerix Date: Thu Sep 5 12:20:33 2024 +0500 project created diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62faaac --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Build results +[Bb]in/ +.bin/ +[Dd]ebug/ +[Rr]elease/ +[Rr]eleases/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ +[Pp]ublish/ + +# IDE files +.vs/ +.vscode/ +.vshistory/ +.idea/ +.editorconfig +*.user + +#backups +.old*/ \ No newline at end of file diff --git a/App.axaml b/App.axaml new file mode 100644 index 0000000..0a682d2 --- /dev/null +++ b/App.axaml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/App.axaml.cs b/App.axaml.cs new file mode 100644 index 0000000..482b78a --- /dev/null +++ b/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace Slimak; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/MainWindow.axaml b/MainWindow.axaml new file mode 100644 index 0000000..a557f2d --- /dev/null +++ b/MainWindow.axaml @@ -0,0 +1,22 @@ + + + + + + diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs new file mode 100644 index 0000000..05f04dc --- /dev/null +++ b/MainWindow.axaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Data; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Platform; +using Avalonia.Platform.Storage; + +namespace Slimak; + +public partial class MainWindow : Window +{ + public static readonly StyledProperty IsEatingProperty = + AvaloniaProperty.Register(nameof(IsEating), + defaultBindingMode: BindingMode.TwoWay, defaultValue: false); + public bool IsEating + { + get => GetValue(IsEatingProperty); + set => SetValue(IsEatingProperty, value); + } + + public MainWindow() + { + InitializeComponent(); + AddHandler(DragDrop.DropEvent, Drop); + } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + using var res = AssetLoader.Open(new Uri("avares://Slimak/resources/Salata.png")); + using var file = File.OpenWrite("Salata.png"); + res.CopyTo(file); + } + + private void InputElement_OnPointerOver(object? sender, PointerPressedEventArgs e) + { + if (IsEating) + { + IsEating = false; + Console.WriteLine("Stopped eating"); + } + } + + private void Drop(object? sender, DragEventArgs e) + { + if(IsEating) + return; + + Console.WriteLine("Drag and Drop"); + var data = e.Data; + var draggedFiles = data.GetFiles(); + var storageItems = (draggedFiles ?? Array.Empty()).ToArray(); + Console.WriteLine($"files: {storageItems.Select(f => f.Name).Aggregate((a, b) => a + " " + b + " ")}"); + if(draggedFiles != null && storageItems.Any(st => st.Name.ToLower().Contains("salata"))) + { + IsEating = true; + Console.WriteLine("Started eating"); + } + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..468ff86 --- /dev/null +++ b/Program.cs @@ -0,0 +1,20 @@ +using Avalonia; +using System; + +namespace Slimak; + +class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace(); +} \ No newline at end of file diff --git a/Slimak.csproj b/Slimak.csproj new file mode 100644 index 0000000..086a0f5 --- /dev/null +++ b/Slimak.csproj @@ -0,0 +1,25 @@ + + + WinExe + net8.0 + latest + enable + true + app.manifest + true + en + + + + + + + + + + + + + + + diff --git a/Slimak.sln b/Slimak.sln new file mode 100644 index 0000000..9968519 --- /dev/null +++ b/Slimak.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Slimak", "Slimak.csproj", "{9E0B960E-6E69-4497-9D1F-2F25601F258F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E0B960E-6E69-4497-9D1F-2F25601F258F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E0B960E-6E69-4497-9D1F-2F25601F258F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E0B960E-6E69-4497-9D1F-2F25601F258F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E0B960E-6E69-4497-9D1F-2F25601F258F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/app.manifest b/app.manifest new file mode 100644 index 0000000..ef22c12 --- /dev/null +++ b/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/resources/Salata.png b/resources/Salata.png new file mode 100644 index 0000000..89ea6ca Binary files /dev/null and b/resources/Salata.png differ diff --git a/resources/Slimak.png b/resources/Slimak.png new file mode 100644 index 0000000..b4714e9 Binary files /dev/null and b/resources/Slimak.png differ diff --git a/resources/Slimak_eating.gif b/resources/Slimak_eating.gif new file mode 100644 index 0000000..35b4f0a Binary files /dev/null and b/resources/Slimak_eating.gif differ