-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from irihitech/260-pi
Fix IpV4Box event handling.
- Loading branch information
Showing
17 changed files
with
295 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Nullable>enable</Nullable> | ||
<AvaloniaVersion>11.1.0-rc2</AvaloniaVersion> | ||
<AvaloniaVersion>11.1.1</AvaloniaVersion> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Application xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
x:Class="Sandbox.App" | ||
xmlns:local="using:Sandbox" | ||
xmlns:semi="https://irihi.tech/semi" | ||
xmlns:u-semi="https://irihi.tech/ursa/themes/semi" | ||
RequestedThemeVariant="Default"> | ||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> | ||
|
||
<Application.DataTemplates> | ||
<local:ViewLocator/> | ||
</Application.DataTemplates> | ||
|
||
<Application.Styles> | ||
<semi:SemiTheme Locale="zh-cn" /> | ||
<StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" /> | ||
<u-semi:SemiTheme Locale="zh-cn" /> | ||
</Application.Styles> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Avalonia; | ||
using Avalonia.Controls.ApplicationLifetimes; | ||
using Avalonia.Data.Core; | ||
using Avalonia.Data.Core.Plugins; | ||
using Avalonia.Markup.Xaml; | ||
using Sandbox.ViewModels; | ||
using Sandbox.Views; | ||
|
||
namespace Sandbox; | ||
|
||
public partial class App : Application | ||
{ | ||
public override void Initialize() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
|
||
public override void OnFrameworkInitializationCompleted() | ||
{ | ||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) | ||
{ | ||
// Line below is needed to remove Avalonia data validation. | ||
// Without this line you will get duplicate validations from both Avalonia and CT | ||
BindingPlugins.DataValidators.RemoveAt(0); | ||
desktop.MainWindow = new MainWindow | ||
{ | ||
DataContext = new MainWindowViewModel(), | ||
}; | ||
} | ||
|
||
base.OnFrameworkInitializationCompleted(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Avalonia; | ||
using System; | ||
|
||
namespace Sandbox; | ||
|
||
sealed 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() | ||
.LogToTrace(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Models\"/> | ||
<AvaloniaResource Include="Assets\**"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" /> | ||
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)"/> | ||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> | ||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" /> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" /> | ||
<PackageReference Include="Semi.Avalonia" Version="11.1.0" /> | ||
<PackageReference Include="Semi.Avalonia.DataGrid" Version="11.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj" /> | ||
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Templates; | ||
using Sandbox.ViewModels; | ||
|
||
namespace Sandbox; | ||
|
||
public class ViewLocator : IDataTemplate | ||
{ | ||
public Control? Build(object? data) | ||
{ | ||
if (data is null) | ||
return null; | ||
|
||
var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); | ||
var type = Type.GetType(name); | ||
|
||
if (type != null) | ||
{ | ||
var control = (Control)Activator.CreateInstance(type)!; | ||
control.DataContext = data; | ||
return control; | ||
} | ||
|
||
return new TextBlock { Text = "Not Found: " + name }; | ||
} | ||
|
||
public bool Match(object? data) | ||
{ | ||
return data is ViewModelBase; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Net; | ||
|
||
namespace Sandbox.ViewModels; | ||
|
||
public partial class MainWindowViewModel : ViewModelBase | ||
{ | ||
public ObservableCollection<DataGridItem> Items { get; set; } | ||
|
||
public MainWindowViewModel() | ||
{ | ||
Items = new ObservableCollection<DataGridItem>() | ||
{ | ||
new DataGridItem() { Name = "John Doe", Age = 42 }, | ||
new DataGridItem() { Name = "Jane Doe", Age = 39 }, | ||
new DataGridItem() { Name = "Sammy Doe", Age = 13 }, | ||
new DataGridItem() { Name = "Barry Doe", Age = 7 }, | ||
new DataGridItem() { Name = "Molly Doe", Age = 5 }, | ||
}; | ||
} | ||
|
||
|
||
} | ||
|
||
public class DataGridItem | ||
{ | ||
public string? Name { get; set; } | ||
public int Age { get; set; } | ||
public IPAddress? Address { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
namespace Sandbox.ViewModels; | ||
|
||
public class ViewModelBase : ObservableObject | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<Window xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:vm="using:Sandbox.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:u="https://irihi.tech/ursa" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="Sandbox.Views.MainWindow" | ||
x:DataType="vm:MainWindowViewModel" | ||
Icon="/Assets/avalonia-logo.ico" | ||
Title="Sandbox"> | ||
|
||
<Design.DataContext> | ||
<!-- This only sets the DataContext for the previewer in an IDE, | ||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> | ||
<vm:MainWindowViewModel/> | ||
</Design.DataContext> | ||
|
||
<Grid> | ||
<DataGrid ItemsSource="{Binding Items}" IsReadOnly="False" HorizontalAlignment="Left"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/> | ||
|
||
<DataGridTemplateColumn Width="2*" Header="Address" MaxWidth="300" MinWidth="300"> | ||
<DataGridTemplateColumn.CellTemplate> | ||
<DataTemplate> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Text="{Binding Address}" /> | ||
</DataTemplate> | ||
</DataGridTemplateColumn.CellTemplate> | ||
<DataGridTemplateColumn.CellEditingTemplate> | ||
<DataTemplate> | ||
<u:IPv4Box | ||
HorizontalAlignment="Stretch" | ||
IPAddress="{Binding Address}" /> | ||
</DataTemplate> | ||
</DataGridTemplateColumn.CellEditingTemplate> | ||
</DataGridTemplateColumn> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
</Grid> | ||
|
||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Avalonia.Controls; | ||
|
||
namespace Sandbox.Views; | ||
|
||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="Sandbox.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<AvaloniaVersion>11.1.0-rc2</AvaloniaVersion> | ||
<AvaloniaVersion>11.1.1</AvaloniaVersion> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.