Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Nov 8, 2023
1 parent 690f231 commit 885d92a
Show file tree
Hide file tree
Showing 12 changed files with 779 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/OneWare.PackageManager/Views/PackageManagerView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
Text="{Binding Package.Name}" />
<TextBlock Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
Text="{Binding Package.Description}" TextWrapping="Wrap" />
<StackPanel Grid.Row="0" Grid.Column="1" Spacing="5" Orientation="Horizontal">
<StackPanel Grid.Row="0" Grid.Column="1" Spacing="10" Orientation="Horizontal">
<TextBlock Text="{Binding SelectedVersion.Version}" Foreground="{DynamicResource ThemeForegroundLowBrush}"/>
<Button Content="{Binding PrimaryButtonText}"
Background="{Binding PrimaryButtonBrush}"
Expand Down
18 changes: 18 additions & 0 deletions src/OneWare.Shared/Converters/BoolToOpacityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Globalization;
using Avalonia.Data.Converters;

namespace OneWare.Shared.Converters;

public class BoolToOpacityConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool t && t) return 1d;
return 0d;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
3 changes: 3 additions & 0 deletions src/OneWare.Shared/Converters/SharedConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace OneWare.Shared.Converters;

public static class SharedConverters
{
public static readonly IValueConverter
BoolToOpacityConverter = new BoolToOpacityConverter();
public static readonly IValueConverter
BoolToScrollBarVisibilityConverter = new BoolToScrollBarVisibilityConverter();
public static readonly IValueConverter ComparisonConverter = new ComparisonConverter();
Expand All @@ -18,4 +20,5 @@ public static readonly IValueConverter
public static readonly IValueConverter PathToWindowIconConverter = new PathToWindowIconConverter();
public static readonly PathToBitmapConverter PathToBitmapConverter = new();
public static readonly IMultiValueConverter PathsEqualConverter = new PathsEqualConverter();
public static readonly IMultiValueConverter ObjectsEqualConverter = new ObjectsEqualConverter();
}
3 changes: 3 additions & 0 deletions src/OneWare.Shared/OneWare.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<Import Project="..\..\build\props\AvaloniaEdit.TextMate.props"/>
<Import Project="..\..\build\props\Asmichi.ChildProcess.props"/>
<Import Project="..\..\build\props\NodeEditorAvalonia.props"/>
<ItemGroup>
<UpToDateCheckInput Remove="Styles\Components.axaml" />
</ItemGroup>
</Project>
29 changes: 27 additions & 2 deletions src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
namespace OneWare.UniversalFpgaProjectSystem.Models;
using CommunityToolkit.Mvvm.ComponentModel;

public class FpgaModel
namespace OneWare.UniversalFpgaProjectSystem.Models;

public class FpgaModel : ObservableObject
{
public string Name { get; }

public Dictionary<string, FpgaPin> AvailablePins { get; } = new();

private CompileConnectionModel _selectedConnection;

Check failure on line 11 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileConnectionModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileConnectionModel' could not be found (are you missing a using directive or an assembly reference?)

private FpgaPin _selectedPin;
public FpgaPin SelectedPin
{
get => _selectedPin;
set => this.SetProperty(ref _selectedPin, value);
}

private CompileSignalModel _selectedSignal;

Check failure on line 20 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 20 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)

public FpgaModel(string name)
{
Name = name;
}

public override string ToString()
{
return Name;
}
}
43 changes: 43 additions & 0 deletions src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace OneWare.UniversalFpgaProjectSystem.Models;

public class FpgaPin : ObservableObject
{
public FpgaModel Parent { get; }
public string Name { get; }

private string _description;
public string Description
{
get => _description;
set => SetProperty(ref _description, value);
}

private string _toolTipText;
public string ToolTipText
{
get => _toolTipText;
set => SetProperty(ref _toolTipText, value);
}

private CompileSignalModel _connection;

Check failure on line 24 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)
public CompileSignalModel Connection

Check failure on line 25 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 25 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'CompileSignalModel' could not be found (are you missing a using directive or an assembly reference?)
{
get => _connection;
set
{
this.SetProperty(ref _connection, value);
if (_connection == null) ToolTipText = "Click to connect " + Name;
else ToolTipText = Name + " is connected with " + _connection.Name;
}
}

public CompilePinModel(string name, string description, FpgaModel parent)

Check failure on line 36 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

Method must have a return type

Check failure on line 36 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs

View workflow job for this annotation

GitHub Actions / build

Method must have a return type
{
Name = name;
Description = description;
Connection = null;
Parent = parent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="Styles\Components.axaml" />
</ItemGroup>
</Project>
215 changes: 215 additions & 0 deletions src/OneWare.UniversalFpgaProjectSystem/Styles/Components.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:models="clr-namespace:OneWare.UniversalFpgaProjectSystem.Models"
xmlns:views="clr-namespace:OneWare.UniversalFpgaProjectSystem.Views"
xmlns:viewModels="clr-namespace:OneWare.UniversalFpgaProjectSystem.ViewModels"
xmlns:converters="clr-namespace:OneWare.Shared.Converters;assembly=OneWare.Shared">

<Styles.Resources>
<SolidColorBrush x:Key="SelectionColorPin" Opacity="1" Color="{DynamicResource ThemeForegroundColor}" />
<SolidColorBrush x:Key="SelectionColorConnected" Opacity="1" Color="#d4d4d4" />
<Thickness x:Key="SelectedThickness">3</Thickness>
<Thickness x:Key="NormalThickness">1</Thickness>
</Styles.Resources>

<Style Selector="Button.YellowGreen">
<Setter Property="Background" Value="YellowGreen" />
</Style>
<Style Selector="Button.Cyan">
<Setter Property="Background" Value="Cyan" />
</Style>
<Style Selector="Button.Orange">
<Setter Property="Background" Value="Orange" />
</Style>
<Style Selector="Button.V5">
<Setter Property="Background" Value="#FF0033" />
</Style>

<Style Selector="Button:disabled">
<Setter Property="Opacity" Value="1" />
<Setter Property="BorderThickness" Value="1" />
</Style>

<Style Selector="Button.Connectable:pointerover">
<Setter Property="Background" Value="#222222" />
</Style>

<Style Selector="TextBlock">
<Setter Property="Height" Value="15" />
<Setter Property="FontSize" Value="12" />
</Style>
<Style Selector="TextBlock.Vert">
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="270" />
</Setter.Value>
</Setter>
</Style>
<Style Selector="Button:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
</Style>

<Style Selector="Button">
<Setter Property="Margin" Value="0" />
<Setter Property="Width" Value="12" />
<Setter Property="Height" Value="12" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="Yellow" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
<Setter Property="Padding" Value="0" />
</Style>

<Style Selector="Button.Unconnectable">
<Setter Property="Template">
<ControlTemplate>
<Border Name="PinBorder" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{DynamicResource ThemeBorderLowBrush}">
<Grid>
<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,0,0,0" />
</Grid>
</Border>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="Menu.BindMenu > MenuItem > Panel > TextBlock">
<Setter Property="Foreground" Value="White" />
</Style>

<Style Selector="Menu.BindMenu > MenuItem:pointerover > Border#root">
<Setter Property="Background" Value="Transparent" />
</Style>

<Style Selector="Menu.BindMenu > MenuItem:selected > Border#root">
<Setter Property="Background" Value="Transparent" />
</Style>

<Style Selector="Border.CruviExtension">
<Setter Property="Opacity"
Value="{Binding !!$parent[views:UniversalFpgaProjectCompileView].((viewModels:UniversalFpgaProjectCompileViewModel)DataContext).HideExtensions,
Converter={x:Static converters:SharedConverters.BoolToOpacityConverter}}" />
<Setter Property="IsHitTestVisible" Value="{Binding !$parent[views:UniversalFpgaProjectCompileView].((viewModels:UniversalFpgaProjectCompileViewModel)DataContext).HideExtensions}" />
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
</Transitions>
</Setter>
</Style>

<Style Selector="Button.Connectable" x:DataType="models:FpgaPin" x:CompileBindings="True">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Border Name="PinBorder" Padding="0" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{DynamicResource ThemeBorderLowBrush}">
<Grid>
<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,0,0,0" />
<Interaction.Behaviors>
<DataTriggerBehavior ComparisonCondition="Equal" Value="True">
<DataTriggerBehavior.Binding>
<MultiBinding Converter="{x:Static converters:SharedConverters.ObjectsEqualConverter}">
<Binding Path="Parent.SelectedPin" />
<Binding Path="#PinBorder.DataContext"/>
</MultiBinding>
</DataTriggerBehavior.Binding>
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderBrush"
Value="{StaticResource SelectionColorPin}" />
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderThickness"
Value="{StaticResource SelectedThickness}" />
</DataTriggerBehavior>
<DataTriggerBehavior ComparisonCondition="Equal" Value="False">
<DataTriggerBehavior.Binding>
<MultiBinding Converter="{x:Static converters:SharedConverters.ObjectsEqualConverter}">
<Binding Path="Parent.SelectedPin" />
<Binding Path="#PinBorder.DataContext"/>
</MultiBinding>
</DataTriggerBehavior.Binding>
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderBrush"
Value="{DynamicResource ThemeBorderLowBrush}" />
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderThickness"
Value="{StaticResource NormalThickness}" />
</DataTriggerBehavior>

<DataTriggerBehavior ComparisonCondition="Equal" Value="True">
<DataTriggerBehavior.Binding>
<MultiBinding Converter="{x:Static converters:SharedConverters.ObjectsEqualConverter}">
<Binding Path="Parent.SelectedConnection.Pin" />
<Binding Path="#PinBorder.DataContext"/>
</MultiBinding>
</DataTriggerBehavior.Binding>
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderBrush"
Value="{StaticResource SelectionColorConnected}" />
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderThickness"
Value="{StaticResource SelectedThickness}" />
</DataTriggerBehavior>
<DataTriggerBehavior ComparisonCondition="Equal" Value="False">
<DataTriggerBehavior.Binding>
<MultiBinding Converter="{x:Static converters:SharedConverters.ObjectsEqualConverter}">
<Binding Path="Parent.SelectedConnection.Pin" />
<Binding Path="#PinBorder.DataContext"/>
</MultiBinding>
</DataTriggerBehavior.Binding>
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderBrush"
Value="{DynamicResource ThemeBorderLowBrush}" />
<ChangePropertyAction TargetObject="{Binding #PinBorder}"
PropertyName="BorderThickness"
Value="{StaticResource NormalThickness}" />
</DataTriggerBehavior>
</Interaction.Behaviors>
</Grid>
</Border>
<Border Name="ConnectedRectangle"
IsVisible="{Binding Connection, Converter={x:Static ObjectConverters.IsNotNull}}"
Background="Black" BorderBrush="Transparent" BorderThickness="2" Opacity="0.8" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Command" Value="{Binding Parent.SelectPin}"/>
<Setter Property="CommandParameter" Value="{Binding Name}" />
<Setter Property="ToolTip.Tip" Value="{Binding ToolTipText}" />
</Style>

<Style Selector="Button:pointerover" />

<Style Selector="Button.Connectable:pointerover">
<Setter Property="Background" Value="#353535" />
</Style>


<Style Selector="TextBlock.VertLeft, Image.VertLeft, Menu.VertLeft, Button.VertLeft, Grid.VertLeft">
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
</Style>
<Style Selector="TextBlock.VertRight, Image.VertRight, Menu.VertRight, Button.VertRight, Grid.VertRight">
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="270" />
</Setter.Value>
</Setter>
</Style>

<Style Selector="Rectangle.Diag, Button.Diag">
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="45" />
</Setter.Value>
</Setter>
</Style>
</Styles>
Loading

0 comments on commit 885d92a

Please sign in to comment.