Skip to content

Commit

Permalink
Merge pull request #3 from randolfly/develop
Browse files Browse the repository at this point in the history
update scan ads function
  • Loading branch information
randolfly authored Oct 30, 2024
2 parents 632b0c8 + 68ed737 commit a45c5d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TwincatToolbox/Controls/ScanAdsRouteControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
x:Class="TwincatToolbox.ScanAdsRouteControl"
x:DataType="vm:ScanAdsRouteViewModel"
Title="Scan and Select AdsRoute"
Width="400" Height="300" BackgroundStyle="BubbleStrong"
Width="400" Height="300" ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300">
<Design.DataContext>
<vm:ScanAdsRouteViewModel/>
Expand All @@ -20,7 +20,7 @@
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0">Scan and select target ads route</TextBlock>
<TextBlock Grid.Column="0" FontSize="16" FontWeight="DemiBold">Scan and select target ads route</TextBlock>
<Button Grid.Column="1" Content="Close" Classes="Flat" Click="CloseDialog"/>
</Grid>
<DataGrid Margin="5" ItemsSource="{Binding AdsRoutes}"
Expand Down
16 changes: 16 additions & 0 deletions src/TwincatToolbox/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

using Avalonia.Collections;
using Avalonia.Controls.ApplicationLifetimes;

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
Expand Down Expand Up @@ -66,4 +68,18 @@ private void OnDisconnectAdsServer()
private void OnCheckAdsState() {
AdsStateText = _adsComService.GetAdsState().ToString();
}

[RelayCommand]
private async Task ScanAndSelectAdsRouteAsync() {
var dialog = new ScanAdsRouteControl
{
DataContext = new ScanAdsRouteViewModel()
};
if (App.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
var dialogResult = await dialog.ShowDialog<string>(desktop?.MainWindow);
if (dialogResult != null) NetId = dialogResult;
Debug.WriteLine($"Selected NetId: {NetId}");
}
}
}

0 comments on commit a45c5d1

Please sign in to comment.