-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
690f231
commit 885d92a
Showing
12 changed files
with
779 additions
and
5 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 |
---|---|---|
@@ -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(); | ||
} | ||
} |
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
29 changes: 27 additions & 2 deletions
29
src/OneWare.UniversalFpgaProjectSystem/Models/FpgaModel.cs
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,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 GitHub Actions / build
|
||
|
||
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 GitHub Actions / build
|
||
|
||
public FpgaModel(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return Name; | ||
} | ||
} |
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,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 GitHub Actions / build
|
||
public CompileSignalModel Connection | ||
Check failure on line 25 in src/OneWare.UniversalFpgaProjectSystem/Models/FpgaPin.cs GitHub Actions / build
|
||
{ | ||
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 GitHub Actions / build
|
||
{ | ||
Name = name; | ||
Description = description; | ||
Connection = null; | ||
Parent = parent; | ||
} | ||
} |
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
215 changes: 215 additions & 0 deletions
215
src/OneWare.UniversalFpgaProjectSystem/Styles/Components.axaml
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,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> |
Oops, something went wrong.