Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports Avalonia 0.10 #10

Merged
merged 11 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sample/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaGraphControlSample.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
<FluentTheme />
</Application.Styles>
</Application>
21 changes: 16 additions & 5 deletions sample/AvaloniaGraphControlSample.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<UseControlOnNuget>False</UseControlOnNuget>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
Expand All @@ -12,12 +14,21 @@
<SubType>Designer</SubType>
</AvaloniaResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.*" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.*" />
<PackageReference Include="AvaloniaGraphControl" Version="0.3.2" Condition="'$(UseControlOnNuget)'=='True'" />
<PackageReference Include="Avalonia" Version="0.10.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../src/AvaloniaGraphControl.csproj" Condition="'$(UseControlOnNuget)'=='False'" />

<ItemGroup Condition="'$(Configuration)'=='Debug'">
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0" />
</ItemGroup>

<ItemGroup Condition="'$(UseControlOnNuget)'=='False'">
<ProjectReference Include="../src/AvaloniaGraphControl.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(UseControlOnNuget)'=='True'">
<PackageReference Include="AvaloniaGraphControl" Version="0.3.2" />
</ItemGroup>

</Project>
94 changes: 70 additions & 24 deletions sample/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,94 @@
<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:agc="clr-namespace:AvaloniaGraphControl;assembly=AvaloniaGraphControl"
xmlns:local="clr-namespace:AvaloniaGraphControlSample;assembly=AvaloniaGraphControlSample" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" Width="800" Height="700" x:Class="AvaloniaGraphControlSample.MainWindow" Title="AvaloniaGraphControlSample">
<Grid ColumnDefinitions="1*" RowDefinitions="25,1*">
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<TextBlock>Select Graph:</TextBlock>
<ComboBox Name="graphs" Items="{Binding SampleGraphs}"/>
<TextBlock>Select Zoom:</TextBlock>
<Slider Name="zoomer" Orientation="Horizontal" Width="200" Value="1" Minimum="0.3" Maximum="3"/>
<TextBlock>Select Layout Method:</TextBlock>
<ComboBox Name="layoutMethods" />
</StackPanel>
<ScrollViewer Grid.Column="0" Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<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:agc="clr-namespace:AvaloniaGraphControl;assembly=AvaloniaGraphControl"
xmlns:local="clr-namespace:AvaloniaGraphControlSample;assembly=AvaloniaGraphControlSample"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="800" Height="700"
x:Class="AvaloniaGraphControlSample.MainWindow"
Title="AvaloniaGraphControlSample">
<Grid ColumnDefinitions="Auto,Auto,1*"
RowDefinitions="Auto,Auto,1*"
Margin="4">
<TextBlock Text="Select Graph:"
Margin="4"
Grid.Row="0" Grid.Column="0" />
<TextBlock Text="Select Zoom:"
Margin="4"
Grid.Row="0" Grid.Column="1" />
<TextBlock Text="Select Layout Method:"
Margin="4"
Grid.Row="0" Grid.Column="2" />
<ComboBox Name="graphs"
Items="{Binding SampleGraphs}"
Margin="4"
Width="320"
Grid.Row="1" Grid.Column="0" />
<Slider Name="zoomer"
Orientation="Horizontal"
Width="200"
Value="1"
Minimum="0.3" Maximum="3"
Margin="4"
Grid.Row="1" Grid.Column="1" />
<ComboBox Name="layoutMethods"
Margin="4"
Width="160"
Grid.Row="1" Grid.Column="2" />
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Grid.Row="2" Grid.Column="0"
Grid.ColumnSpan="3">
<LayoutTransformControl Classes="screen pdf">
<LayoutTransformControl.LayoutTransform>
<ScaleTransform ScaleX="{Binding Value, ElementName=zoomer}" ScaleY="{Binding Value, ElementName=zoomer}"/>
<ScaleTransform ScaleX="{Binding Value, ElementName=zoomer}"
ScaleY="{Binding Value, ElementName=zoomer}"/>
</LayoutTransformControl.LayoutTransform>
<agc:GraphPanel Background="WhiteSmoke" Graph="{Binding SelectedItem, ElementName=graphs}" LayoutMethod="{Binding SelectedItem, ElementName=layoutMethods}">
<agc:GraphPanel Background="WhiteSmoke"
Graph="{Binding SelectedItem, ElementName=graphs}"
LayoutMethod="{Binding SelectedItem, ElementName=layoutMethods}">
<agc:GraphPanel.DataTemplates>
<DataTemplate DataType="{x:Type local:StandardItem}">
<agc:TextSticker Text="{Binding Name}" Shape="Ellipse" Padding="30,10" />
<agc:TextSticker Text="{Binding Name}"
Shape="Ellipse"
Padding="30,10" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:InteractiveItem}">
<ToggleButton Content="{Binding Name}" Padding="20,5" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:CompositeItem}">
<agc:TextSticker Text="{Binding Name}" Shape="RoundedRectangle" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<agc:TextSticker Text="{Binding Name}"
Shape="RoundedRectangle"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:FamilyMember}">
<Button Content="{Binding Name}" Background="{Binding BackgroundColor}" Command="{Binding Navigate}" />
<Button Content="{Binding Name}"
Background="{Binding BackgroundColor}"
Command="{Binding Navigate}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:Family}">
<Canvas Width="17" Height="12">
<Rectangle Width="17" Height="12" Fill="Black" />
<Rectangle Canvas.Left="1" Canvas.Top="1" Width="15" Height="10" Fill="Gray" />
<Rectangle Canvas.Left="1" Canvas.Top="1"
Width="15" Height="10"
Fill="Gray" />
</Canvas>
</DataTemplate>
<DataTemplate DataType="{x:Type local:State}">
<agc:TextSticker Text="{Binding Name}" Background="{Binding Color}" Shape="RoundedRectangle" Padding="1,1" />
<agc:TextSticker Text="{Binding Name}"
Background="{Binding Color}"
Shape="RoundedRectangle"
Padding="1" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:CompositeState}">
<agc:TextSticker Text="{Binding Name}" Background="{Binding Color}" Shape="RoundedRectangle" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="1,1" />
<agc:TextSticker Text="{Binding Name}"
Background="{Binding Color}"
Shape="RoundedRectangle"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Padding="1" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:InitialState}">
<Ellipse Width="10" Height="10" Fill="Black" />
Expand Down
3 changes: 1 addition & 2 deletions sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Avalonia;
using Avalonia.Logging.Serilog;

namespace AvaloniaGraphControlSample
{
Expand All @@ -15,6 +14,6 @@ public static void Main(string[] args) => BuildAvaloniaApp()
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug();
.LogToTrace();
}
}
2 changes: 1 addition & 1 deletion src/AvaloniaGraphControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.*" />
<PackageReference Include="Avalonia" Version="0.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public static FormattedText CreateText(MsaglDrawing.Label label)
var ftext = new FormattedText
{
Constraint = new Size(10, 10),
Typeface = new Typeface(fontFamily, fontSize, fontStyle, fontWeight),
Text = label.Text
Typeface = new Typeface(fontFamily, fontStyle, fontWeight),
Text = label.Text,
FontSize = fontSize,
};
return ftext;
}
Expand Down