Initial push

This commit is contained in:
Ano-sys
2025-02-12 14:55:57 +01:00
commit 0daaa854b7
7 changed files with 224 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SimpleNote.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
+23
View File
@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using System;
namespace SimpleNote;
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(desktop.Args);
}
base.OnFrameworkInitializationCompleted();
}
}
+56
View File
@@ -0,0 +1,56 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:SimpleNote"
mc:Ignorable="d" d:DesignWidth="40" d:DesignHeight="200"
x:Class="SimpleNote.MainWindow"
x:DataType="vm:MainViewModel"
WindowStartupLocation="CenterScreen"
TransparencyLevelHint="AcrylicBlur"
Background="Transparent"
Height="50"
Width="{Binding WindowWidth}"
SystemDecorations="None"
ExtendClientAreaToDecorationsHint="False"
CanResize="False"
Topmost="True"
Title="SimpleNote">
<Panel>
<ExperimentalAcrylicBorder IsHitTestVisible="False">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial
BackgroundSource="Digger"
TintColor="Black"
TintOpacity="0.6"
MaterialOpacity="0.65" />
</ExperimentalAcrylicBorder.Material>
</ExperimentalAcrylicBorder>
<TextBox HorizontalAlignment="Center"
VerticalAlignment="Top"
Height="5"
IsHitTestVisible="False"
Margin="0, -3, 0, 0"
Foreground="Black"
Text="SimpleNote - Note"
Background="Transparent"
BorderThickness="0"
FontSize="12">
</TextBox>
<TextBox x:Name="Note"
Height="20"
BorderThickness="0"
Width="{Binding WindowWidth}"
Margin="0, 12, 0, 0"
Padding="5,0,5,0"
TextAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Background="Transparent"
IsHitTestVisible="False"
FontSize="{Binding FontSize}">
</TextBox>
</Panel>
</Window>
+76
View File
@@ -0,0 +1,76 @@
using System;
using System.ComponentModel;
using Avalonia;
using Avalonia.Controls;
using System.Reactive.Linq;
using Avalonia.Media;
namespace SimpleNote;
public partial class MainWindow : Window
{
private MainViewModel ViewModel;
public MainWindow(string[]? args)
{
if (args == null || args.Length < 1)
{
Console.WriteLine("Call with Note as Argument!");
Environment.Exit(1);
}
InitializeComponent();
ViewModel = new MainViewModel();
DataContext = ViewModel;
this.GetObservable(Window.WidthProperty)
.Subscribe(width =>
{
if (DataContext is MainViewModel vm)
{
vm.WindowWidth = (double)width;
}
});
init_TextField(args[0]);
}
public void init_TextField(string text)
{
var textBlock = new TextBlock
{
Text = text,
FontSize = ViewModel.FontSize,
FontFamily = new FontFamily(FontFamily.DefaultFontFamilyName)
};
textBlock.Measure(Size.Infinity);
ViewModel.WindowWidth = textBlock.DesiredSize.Width + 50;
Note.Text = text;
}
}
public class MainViewModel : INotifyPropertyChanged
{
private double _windowWidth = 200;
private double _fontSize = 24;
public double WindowWidth
{
get => _windowWidth;
set
{
_windowWidth = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(WindowWidth)));
}
}
public double FontSize
{
get => _fontSize;
set
{
_fontSize = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FontSize)));
}
}
public event PropertyChangedEventHandler? PropertyChanged;
}
+21
View File
@@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace SimpleNote;
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<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}
+20
View File
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0" />
<PackageReference Include="System.Reactive.Linq" Version="6.0.1" />
</ItemGroup>
</Project>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="SimpleNote.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>