Skip to content

Commit

Permalink
add ConnectorStyle compact
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Aug 8, 2024
1 parent 9806ff3 commit 2f6b0de
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public static async Task<HardwareGuiViewModel> CreateGuiAsync(string guiPath, IH
var bind = element.TryGetProperty("bind", out var bindProperty)
? bindProperty.GetString()
: null;

var connectorStyle = element.TryGetProperty("connectorStyle", out var connectorStyleProperty)
? connectorStyleProperty.GetString()
: "default";

switch (element.GetProperty("type").GetString()?.ToLower())
{
Expand Down Expand Up @@ -157,6 +161,7 @@ public static async Task<HardwareGuiViewModel> CreateGuiAsync(string guiPath, IH
Rotation = rotation,
Bind = bind,
Parent = hardwareModel,
ConnectorStyle = connectorStyle
});
break;
}
Expand All @@ -168,6 +173,7 @@ public static async Task<HardwareGuiViewModel> CreateGuiAsync(string guiPath, IH
Rotation = rotation,
Bind = bind,
Parent = hardwareModel,
ConnectorStyle = connectorStyle
});
break;
}
Expand All @@ -178,7 +184,8 @@ public static async Task<HardwareGuiViewModel> CreateGuiAsync(string guiPath, IH
{
Rotation = rotation,
Bind = bind,
Parent = hardwareModel
Parent = hardwareModel,
ConnectorStyle = connectorStyle
});
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace OneWare.UniversalFpgaProjectSystem.ViewModels.FpgaGuiElements;

public abstract class FpgaGuiElementInterfaceViewModelBase : FpgaGuiElementViewModelBase
{
public string? ConnectorStyle { get; init; }
public string? Bind { get; init; }

private HardwareInterfaceModel? _interfaceModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<ContextDropBehavior Context="{Binding InterfaceModel}" Handler="{StaticResource ExtensionDropHandler}"/>
</Interaction.Behaviors>

<Rectangle Fill="#202020" Height="20" Width="54" Margin="3 0 3 0" />
<Rectangle Fill="#202020" Height="10" Width="60" />
<Border Classes="ConnectorBorder" Height="20" Width="54" Margin="3 0 3 0" />
<Border Classes="ConnectorBorder" Height="10" Width="60" />
<TextBlock Text="CRUVI HS" Foreground="White" FontSize="10" VerticalAlignment="Center"
TextAlignment="Center" Width="60" HorizontalAlignment="Center"/>
</Panel>
Expand All @@ -41,6 +41,13 @@
<Style Selector="MenuItem.RootMenuItem:pointerover /template/ Border#root">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="MenuItem.RootMenuItem Border.ConnectorBorder">
<Setter Property="Background" Value="#202020" />
<Setter Property="CornerRadius" Value="0"/>
</Style>
<Style Selector="MenuItem.RootMenuItem:pointerover Border.ConnectorBorder">
<Setter Property="Background" Value="#505050" />
</Style>
</MenuItem.Styles>
</MenuItem>
</Menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ContextDropBehavior Context="{Binding InterfaceModel}" Handler="{StaticResource ExtensionDropHandler}"/>
</Interaction.Behaviors>

<Rectangle Fill="#202020" Height="20" Width="50"/>
<Border Classes="ConnectorBorder" Height="20" Width="50"/>
<TextBlock Text="CRUVI LS" Foreground="White" FontSize="9" VerticalAlignment="Center"
TextAlignment="Center" Width="50" HorizontalAlignment="Center"/>
</Panel>
Expand All @@ -40,6 +40,13 @@
<Style Selector="MenuItem.RootMenuItem:pointerover /template/ Border#root">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="MenuItem.RootMenuItem Border.ConnectorBorder">
<Setter Property="Background" Value="#202020" />
<Setter Property="CornerRadius" Value="0"/>
</Style>
<Style Selector="MenuItem.RootMenuItem:pointerover Border.ConnectorBorder">
<Setter Property="Background" Value="#505050" />
</Style>
</MenuItem.Styles>
</MenuItem>
</Menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:fpgaGuiElements="clr-namespace:OneWare.UniversalFpgaProjectSystem.ViewModels.FpgaGuiElements"
xmlns:behaviors="clr-namespace:OneWare.UniversalFpgaProjectSystem.Behaviors"
xmlns:fpgaGuiElements1="clr-namespace:OneWare.UniversalFpgaProjectSystem.Views.FpgaGuiElements"
xmlns:converters="clr-namespace:OneWare.Essentials.Converters;assembly=OneWare.Essentials"
mc:Ignorable="d" d:DesignWidth="200" d:DesignHeight="150"
x:Class="OneWare.UniversalFpgaProjectSystem.Views.FpgaGuiElements.FpgaGuiElementPmodView"
x:DataType="fpgaGuiElements:FpgaGuiElementPmodViewModel" ClipToBounds="False"
Expand All @@ -16,53 +17,70 @@
<UserControl.RenderTransform>
<RotateTransform Angle="{Binding Rotation}" />
</UserControl.RenderTransform>
<Panel>
<Panel DragDrop.AllowDrop="True">
<Interaction.Behaviors>
<ContextDropBehavior Context="{Binding InterfaceModel}"
Handler="{StaticResource ExtensionDropHandler}" />
</Interaction.Behaviors>
<Grid RowDefinitions="Auto, Auto">
<StackPanel Grid.Row="1" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[5]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[6]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[7]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[8]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[GND]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3V3]}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[1]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[2]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[4]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[GND]}"/>
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3V3]}"/>
</StackPanel>
</StackPanel>
<Menu Grid.Row="0" Classes="BindMenu">
<Menu Grid.Row="0" Classes="BindMenu" ClipToBounds="False">
<MenuItem Padding="0"
Classes="RootMenuItem"
Classes="RootMenuItem" ClipToBounds="False"
ItemsSource="{Binding InterfaceModel.InterfaceMenu, FallbackValue={x:Null}}">
<MenuItem.Header>
<Panel DragDrop.AllowDrop="True">
<Interaction.Behaviors>
<ContextDropBehavior Context="{Binding InterfaceModel}"
Handler="{StaticResource ExtensionDropHandler}" />
</Interaction.Behaviors>

<Rectangle Fill="#202020" Height="20" Width="60" />
<TextBlock Text="PMOD" Foreground="White" HorizontalAlignment="Center" FontSize="10"
VerticalAlignment="Center" TextAlignment="Center" />
<Panel>
<Panel
IsVisible="{Binding ConnectorStyle, Converter={x:Static converters:SharedConverters.ComparisonConverter}, ConverterParameter=default}">
<Border Classes="ConnectorBorder" Height="20" Width="60" />
<TextBlock Text="PMOD" Foreground="White" HorizontalAlignment="Center" FontSize="10"
VerticalAlignment="Center" TextAlignment="Center" />
</Panel>
<Panel Margin="-5 0 0 -20" HorizontalAlignment="Left"
IsVisible="{Binding ConnectorStyle, Converter={x:Static converters:SharedConverters.ComparisonConverter}, ConverterParameter=compact}">
<Border Classes="ConnectorBorder" Height="20" Width="5" />
</Panel>
<Panel Margin="60 0 0 -20" HorizontalAlignment="Left"
IsVisible="{Binding ConnectorStyle, Converter={x:Static converters:SharedConverters.ComparisonConverter}, ConverterParameter=compact}">
<Border Classes="ConnectorBorder" Height="20" Width="5" />
</Panel>
</Panel>
</MenuItem.Header>
<MenuItem.Styles>
<Style Selector="MenuItem.RootMenuItem /template/ Border#root">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="MenuItem.RootMenuItem:pointerover /template/ Border#root">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="MenuItem.RootMenuItem Border.ConnectorBorder">
<Setter Property="Background" Value="#202020" />
<Setter Property="CornerRadius" Value="0"/>
</Style>
<Style Selector="MenuItem.RootMenuItem:pointerover Border.ConnectorBorder">
<Setter Property="Background" Value="#505050" />
</Style>
</MenuItem.Styles>
</MenuItem>
</Menu>
<StackPanel Grid.Row="1" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[5]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[6]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[7]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[8]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[GND]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3V3]}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[1]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[2]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[4]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[GND]}" />
<fpgaGuiElements1:FpgaGuiElementPinView DataContext="{Binding PinViewModels[3V3]}" />
</StackPanel>
</StackPanel>
</Grid>
<Border
IsVisible="{Binding InterfaceModel.ConnectedExtensionViewModel, FallbackValue={x:Null}, Converter={x:Static ObjectConverters.IsNotNull}}"
Expand Down

0 comments on commit 2f6b0de

Please sign in to comment.