Skip to content

Commit

Permalink
SimHub plugin: Added gridlines to canvas and rearranged sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrGri committed Dec 24, 2023
1 parent 55892cc commit 4d9a40f
Show file tree
Hide file tree
Showing 27 changed files with 1,400 additions and 380 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo
Binary file not shown.
119 changes: 75 additions & 44 deletions SimHubPlugin/SettingsControlDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,109 +108,139 @@
<!-- Pedal preforce slider -->
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="5,0,0,0"
Margin="341,67,0,0"
Text="Pedal min force:"
Grid.Row="5"
Grid.Column="0"
Grid.Row="9"
Width="120"
Foreground="White"/>
Foreground="White" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="2">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
<Slider x:Name="PedalMinForce_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="5,0,0,0"
Grid.Row="5"
Grid.Column="0"
VerticalAlignment="Top"
Margin="358,71,0,0"
Grid.Row="9"
Width="120"
ValueChanged="Slider_PedalMinForce"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="1"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="10" RenderTransformOrigin="0.508,0.525"
Value="8"
/>
RenderTransformOrigin="0.508,0.525"
Value="8" Grid.ColumnSpan="2"
>
<Slider.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</Slider.RenderTransform>
</Slider>


<!-- Pedal max force slider -->
<TextBlock HorizontalAlignment="Center"
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="5,0,0,0"
Margin="406,64,0,0"
Text="Pedal max force:"
Grid.Row="5"
Grid.Column="0"
Grid.Row="9"
Grid.Column="1"
Width="120"
Foreground="White"/>
Foreground="White" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="2">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
<Slider x:Name="PedalMaxForce_Slider"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="5,0,0,0"
Grid.Row="5"
Grid.Column="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="421,67,0,0"
Grid.Row="9"
Grid.Column="1"
Width="120"
ValueChanged="Slider_PedalMaxForce"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="255"
TickPlacement="BottomRight"
TickFrequency="10" RenderTransformOrigin="0.508,0.525"
Value="73"
/>
RenderTransformOrigin="0.508,0.525"
Value="73" Grid.ColumnSpan="2"
>
<Slider.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</Slider.RenderTransform>
</Slider>




<!-- Pedal min position slider -->
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="5,0,0,0"
Margin="65,165,0,0"
Text="Pedal min position:"
Grid.Row="5"
Grid.Row="9"
Grid.Column="1"
Width="120"
Foreground="White"/>
<Slider x:Name="PedalMinPos_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="5,0,0,0"
Grid.Row="5"
VerticalAlignment="Top"
Margin="63,186,0,0"
Grid.Row="9"
Grid.Column="1"
Width="120"
ValueChanged="Slider_PedalMinPos"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="10" RenderTransformOrigin="0.508,0.525"
RenderTransformOrigin="0.508,0.525"
Value="41"
/>


<!-- Pedal max position slider -->
<TextBlock HorizontalAlignment="Center"
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="5,0,0,0"
Margin="330,165,0,0"
Text="Pedal max position:"
Grid.Row="5"
Grid.Row="9"
Grid.Column="1"
Width="120"
Foreground="White"/>
<Slider x:Name="PedalMaxPos_Slider"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="5,0,0,0"
Grid.Row="5"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="330,186,0,0"
Grid.Row="9"
Grid.Column="1"
Width="120"
ValueChanged="Slider_PedalMaxPos"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="10" RenderTransformOrigin="0.508,0.525"
RenderTransformOrigin="0.508,0.525"
Value="86"
/>

Expand Down Expand Up @@ -304,14 +334,15 @@


<!-- Travel vs Force curve GUI elements -->
<Canvas x:Name="canvas" Height="100" Width="400" Background="#FF333333" HorizontalAlignment="Left" Grid.Row="9" Opacity="0.5" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Margin="0,20,0,0" Grid.Column="1" >
<Canvas x:Name="canvas" Height="100" Width="400" Background="#FF333333" HorizontalAlignment="Center" Grid.Row="9" Opacity="0.5" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Margin="0,31,0,0" Grid.Column="1" >
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>

</Canvas.RenderTransform>


Expand Down Expand Up @@ -379,7 +410,7 @@
<!-- Travel vs Force curve adjustment sliders -->
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="5,0,0,0"
Margin="140,7,0,0"
Text="Force curve adjustment:"
Grid.Row="9"
Grid.Column="1"
Expand Down
65 changes: 57 additions & 8 deletions SimHubPlugin/SettingsControlDemo.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public partial class SettingsControlDemo : System.Windows.Controls.UserControl
public DataPluginDemo Plugin { get; }

public DAP_config_st[] dap_config_st = new DAP_config_st[3];
private string stringValue;





private string stringValue;






// read config from JSON on startup
Expand Down Expand Up @@ -97,6 +97,52 @@ public partial class SettingsControlDemo : System.Windows.Controls.UserControl

//}

private void DrawGridLines()
{
// Specify the number of rows and columns for the grid
int rowCount = 5;
int columnCount = 5;

// Calculate the width and height of each cell
double cellWidth = canvas.Width / columnCount;
double cellHeight = canvas.Height / rowCount;

// Draw horizontal gridlines
for (int i = 1; i < rowCount; i++)
{
Line line = new Line
{
X1 = 0,
Y1 = i * cellHeight,
X2 = canvas.Width,
Y2 = i * cellHeight,
//Stroke = Brush.Black,
Stroke = System.Windows.Media.Brushes.LightSteelBlue,
StrokeThickness = 1,
Opacity = 0.1

};
canvas.Children.Add(line);
}

// Draw vertical gridlines
for (int i = 1; i < columnCount; i++)
{
Line line = new Line
{
X1 = i * cellWidth,
Y1 = 0,
X2 = i * cellWidth,
Y2 = canvas.Height,
//Stroke = Brushes.Black,
Stroke = System.Windows.Media.Brushes.LightSteelBlue,
StrokeThickness = 1,
Opacity = 0.1
};
canvas.Children.Add(line);
}
}

private void InitReadStructFromJson()
{

Expand Down Expand Up @@ -222,8 +268,11 @@ public SettingsControlDemo()

dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.control_strategy_b = 0;

InitializeComponent();

InitializeComponent();

// Call this method to generate gridlines on the Canvas
DrawGridLines();

}

}
Expand Down
Binary file modified SimHubPlugin/bin/DiyActivePedal.dll
Binary file not shown.
Binary file modified SimHubPlugin/bin/DiyActivePedal.g.resources
Binary file not shown.
Binary file modified SimHubPlugin/bin/DiyActivePedal.pdb
Binary file not shown.
Binary file modified SimHubPlugin/obj/Debug/DiyActivePedal.dll
Binary file not shown.
Binary file modified SimHubPlugin/obj/Debug/DiyActivePedal.g.resources
Binary file not shown.
Binary file modified SimHubPlugin/obj/Debug/DiyActivePedal.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion SimHubPlugin/obj/Debug/DiyActivePedal_MarkupCompile.cache
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DEBUG;TRACE

1-1832596077
1-1358375093
5495540988
61479502685
136-165144657
SettingsControlDemo.xaml;

Expand Down
Binary file modified SimHubPlugin/obj/Debug/SettingsControlDemo.baml
Binary file not shown.
Loading

0 comments on commit 4d9a40f

Please sign in to comment.