added Csharp project RobotClientWpf

main
Jonas Arnold 4 years ago
parent 20d33a20a9
commit be9ee7769f
  1. 6
      ADIS_Csharp/ADIS_Csharp.sln
  2. 9
      ADIS_Csharp/RobotClientWpf/App.xaml
  3. 17
      ADIS_Csharp/RobotClientWpf/App.xaml.cs
  4. 10
      ADIS_Csharp/RobotClientWpf/AssemblyInfo.cs
  5. 14
      ADIS_Csharp/RobotClientWpf/MainWindow.xaml
  6. 49
      ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs
  7. 14
      ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj

@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotLib", "RobotLib\RobotL
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RobotConsoleClient", "RobotConsoleClient\RobotConsoleClient.csproj", "{7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RobotConsoleClient", "RobotConsoleClient\RobotConsoleClient.csproj", "{7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RobotClientWpf", "RobotClientWpf\RobotClientWpf.csproj", "{1D715C65-A8D8-45D3-AE63-D88C60337505}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -63,6 +65,10 @@ Global
{7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Release|Any CPU.ActiveCfg = Release|Any CPU {7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Release|Any CPU.Build.0 = Release|Any CPU {7FFC4B71-FFC2-45A1-941D-4B0A78C20B89}.Release|Any CPU.Build.0 = Release|Any CPU
{1D715C65-A8D8-45D3-AE63-D88C60337505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D715C65-A8D8-45D3-AE63-D88C60337505}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D715C65-A8D8-45D3-AE63-D88C60337505}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D715C65-A8D8-45D3-AE63-D88C60337505}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -0,0 +1,9 @@
<Application x:Class="RobotClientWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:RobotClientWpf"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace RobotClientWpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,14 @@
<Window x:Class="RobotClientWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RobotClientWpf"
mc:Ignorable="d"
Title="RobotClientWpf" Height="450" Width="800">
<Grid>
<Button x:Name="buttonBuzz" Content="Beep" HorizontalAlignment="Left" Margin="246,86,0,0" VerticalAlignment="Top" Click="buttonBuzz_Click"/>
<Label x:Name="labelBattery" Content="Battery: 1.25V" HorizontalAlignment="Left" Margin="22,27,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RobotLib;
namespace RobotClientWpf
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Robot.Instance.Connect("host", 1818);
Robot.Instance.Battery.BatteryChanged += BatteryChanged;
}
private void BatteryChanged(object? sender, BatteryEventArgs e)
{
if (!Dispatcher.CheckAccess())
{
EventHandler<BatteryEventArgs> eventDelegate = BatteryChanged;
Dispatcher.Invoke(eventDelegate, sender, e);
}
else
{
labelBattery.Content = $"Battery: {e.Voltage} V";
}
}
private void buttonBuzz_Click(object sender, RoutedEventArgs e)
{
Robot.Instance.Buzzer.Beep(300, 500);
}
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RobotLib\RobotLib.csproj" />
</ItemGroup>
</Project>
Loading…
Cancel
Save