Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Einen Refresh Button zum einlesen der Seriellen Schnitstelle eingefügt. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\src"
],
"SelectedNode": "\\src\\OpenSerialPortMonitor.sln",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/open-serial-port-monitor/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file added src/.vs/OpenSerialPortMonitor/v16/.suo
Binary file not shown.
Empty file.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/OpenSerialPortMonitor/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura />
</Weavers>
2 changes: 1 addition & 1 deletion src/OpenSerialPortMonitor/Framework/InputBindingTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Whitestone.OpenSerialPortMonitor.Main.Framework
{
public class InputBindingTrigger:TriggerBase<FrameworkElement>,ICommand
public class InputBindingTrigger:TriggerBase<FrameworkElement>, ICommand
{
public InputBindingTrigger()
{
Expand Down
34 changes: 21 additions & 13 deletions src/OpenSerialPortMonitor/OpenSerialPortMonitor.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.3.2.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.2.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -15,7 +16,8 @@
<WarningLevel>4</WarningLevel>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>30fe99fe</NuGetPackageImportStamp>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -40,22 +42,27 @@
<ApplicationIcon>Resources\ApplicationIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.2.0.2\lib\net45\Caliburn.Micro.dll</HintPath>
<Reference Include="Caliburn.Micro, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll</HintPath>
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.2.0.2\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
<Reference Include="Caliburn.Micro.Platform, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
<Private>True</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -163,15 +170,15 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\ApplicationIcon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\openSerialPortMonIcon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand All @@ -180,10 +187,11 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.2.0.0-beta0018\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.2.0.0-beta0018\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.2.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.2.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.4\build\dotnet\Fody.targets'))" />
</Target>
<Import Project="..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
<Import Project="..\packages\Costura.Fody.2.0.0-beta0018\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.2.0.0-beta0018\build\Costura.Fody.targets')" />
<Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
27 changes: 26 additions & 1 deletion src/OpenSerialPortMonitor/ViewModels/SerialConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,32 @@ private void BindValues()

SelectedComPort = ports.FirstOrDefault();
}

public void LoadPorts()
{
IEnumerable<string> ports = SerialReader.GetAvailablePorts();
List<string> toChange = new List<string>();
//Search not non-existent
foreach (var port in ComPorts){
if (!ports.Contains(port)){
toChange.Add(port);
}
}
//Delete not non-existent
ComPorts.RemoveRange(toChange);
toChange.Clear();
//Search New
foreach (var port in ports){
if (!ComPorts.Contains(port)){
toChange.Add(port);
}
}
//Add New
ComPorts.AddRange(toChange);
//Select One if needed
if (SelectedComPort == null || !ComPorts.Contains(SelectedComPort)){
SelectedComPort = ComPorts.FirstOrDefault();
}
}
public void Connect()
{
IsConnected = true;
Expand Down
48 changes: 42 additions & 6 deletions src/OpenSerialPortMonitor/ViewModels/SerialDataSendViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public bool IsHex
set
{
_isHex = value;
if (value){
LineEnd = LENONE;
}
NotifyOfPropertyChange(() => IsHex);
NotifyOfPropertyChange(() => IsValidData);
}
Expand Down Expand Up @@ -89,23 +92,42 @@ public bool IsValidData
}

private bool _isConnected = false;
public bool IsConnected
{
public bool IsConnected {
get { return _isConnected; }
set
{
set {
_isConnected = value;
NotifyOfPropertyChange(() => IsConnected);
NotifyOfPropertyChange(() => IsValidData);
}
}

private bool _clearAfterSend = false;
public bool ClearAfterSend {
get { return _clearAfterSend; }
set {
_clearAfterSend = value;
NotifyOfPropertyChange(() => ClearAfterSend);
}
}
private string _lineEnd;
public string LineEnd {
get { return _lineEnd; }
set {
Console.WriteLine(value.ToString());
_lineEnd = value;
NotifyOfPropertyChange(() => LineEnd);
}
}
private const string LENONE = "No Line End";
private const string LECR = "add CR";
private const string LELF = "add LF";
private const string LECRLD = "add CR + LF";
public string[] LineEndsValues { get; } = {LENONE, LECR, LELF, LECRLD};
public SerialDataSendViewModel(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
_eventAggregator.Subscribe(this);
LineEnd = LENONE;
}

public void DoSend()
{
List<byte> data = new List<byte>();
Expand All @@ -124,7 +146,21 @@ public void DoSend()
if (IsText)
{
string parsed = DataToSend.Replace("\\\\r", "\r").Replace("\\\\n", "\n");
switch (LineEnd){
case LECR:
parsed += "\r";
break;
case LELF:
parsed += "\n";
break;
case LECRLD:
parsed += "\r\n";
break;
}
data.AddRange(System.Text.Encoding.ASCII.GetBytes(parsed));
if (ClearAfterSend){
DataToSend = String.Empty;
}
}

_eventAggregator.PublishOnUIThread(new Messages.SerialPortSend() { Data = data.ToArray() });
Expand Down
12 changes: 12 additions & 0 deletions src/OpenSerialPortMonitor/ViewModels/SerialDataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,17 @@ public void Handle(SerialPortSend message)
{
_serialReader.Send(message.Data);
}

public void ClearAllRecived(){
ClearRecived();
ClearData();
}
public void ClearRecived(){
DataViewParsed = String.Empty;
}
public void ClearData(){
DataViewHex = String.Empty;
DataViewRaw = String.Empty;
}
}
}
5 changes: 4 additions & 1 deletion src/OpenSerialPortMonitor/Views/SerialConnectorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="195" d:DesignWidth="212">
d:DesignHeight="229" d:DesignWidth="212">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"></BooleanToVisibilityConverter>
</UserControl.Resources>
Expand All @@ -23,6 +23,7 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="Serial port connection" Background="#FF4d6082" Foreground="White" Margin="-5,-3,-5,2" Padding="5,2,0,0"></Label>
Expand All @@ -48,6 +49,8 @@

<Button Grid.Row="6" Grid.ColumnSpan="2" Content="Connect" x:Name="Connect" Visibility="{Binding IsDisconnected, Converter={StaticResource booleanToVisibilityConverter}}" Height="30" Margin="0,5,0,0"></Button>
<Button Grid.Row="6" Grid.ColumnSpan="2" Content="Disconnect" x:Name="Disconnect" Visibility="{Binding IsConnected, Converter={StaticResource booleanToVisibilityConverter}}" Height="30" Margin="0,5,0,0"></Button>

<Button Grid.Row="7" Grid.ColumnSpan="2" Content="Reload Ports" x:Name="LoadPorts" IsEnabled="{Binding IsDisconnected}" Height="30" Margin="0,5,0,0"></Button>
</Grid>
</Border>
</UserControl>
2 changes: 2 additions & 0 deletions src/OpenSerialPortMonitor/Views/SerialDataSendView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<Label Grid.Row="2" Content="Data format:" Width="80" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,0,5,5"></Label>
<RadioButton Grid.Row="2" Margin="85,7,5,5" Content="Text" GroupName="DataFormat" x:Name="IsText" />
<RadioButton Grid.Row="2" Margin="140,7,5,5" Content="Hex" GroupName="DataFormat" x:Name="IsHex" />
<CheckBox Grid.Row="2" Margin="200,7,5,5" Content="Clear after Send" x:Name="ClearAfterSend" />
<ComboBox Grid.Row="2" Margin="5,0,85,5" Name="CBLineEnd" Padding="15,4,15,4" Width="120" HorizontalAlignment="Right" IsEnabled="{Binding IsText}" SelectedItem="{Binding LineEnd}" ItemsSource="{Binding LineEndsValues}" />
<Button Grid.Row="2" Content="Send" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,5" Padding="15,4,15,4" x:Name="DoSend" IsEnabled="{Binding IsValidData}"></Button>

</Grid>
Expand Down
4 changes: 3 additions & 1 deletion src/OpenSerialPortMonitor/Views/SerialDataView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Received data" Background="#FF4d6082" Foreground="White" Padding="5,2,0,0"></Label>

<Button Grid.Row="0" Content="Clear" HorizontalAlignment="Right" Margin="5,0,5,0" x:Name="ClearRecived"/>
<Button Grid.Row="0" Content="Clear All" HorizontalAlignment="Right" Margin="5,0,40,0" x:Name="ClearAllRecived"/>
<ScrollViewer Grid.Row="1" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" x:Name="ParsedDataScroller" Tag="{Binding IsAutoscroll}">
<TextBox Background="#FFFFFFFF" VerticalAlignment="Stretch" Padding="5" x:Name="DataViewParsed" IsReadOnly="True" IsUndoEnabled="False" TextWrapping="Wrap" FontFamily="Courier New" ></TextBox>
</ScrollViewer>
Expand All @@ -35,6 +36,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Raw data" Background="#FF4d6082" Foreground="White" Margin="0,0,0,0" Padding="5,2,0,0"></Label>
<Button Grid.Row="0" Content="Clear" HorizontalAlignment="Right" Margin="5,0,5,0" x:Name="ClearData"/>
<ScrollViewer Grid.Row="1" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" x:Name="RawDataScroller" Tag="{Binding IsAutoscroll}">
<Grid>
<Grid.ColumnDefinitions>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

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 not shown.
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 removed src/OpenSerialPortMonitor/obj/Debug/App.baml
Binary file not shown.
10 changes: 5 additions & 5 deletions src/OpenSerialPortMonitor/obj/Debug/App.g.i.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "C47EE5C397702967129307625E81A2F6"
#pragma checksum "..\..\App.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B6576131163F8DA9269F1F4CDDBE73745B1ABC3B7CF9458B36CE61B5B1821305"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------

Expand Down
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 not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
winexe
C#
.cs
D:\Projects\Temp\open-serial-port-monitor\src\OpenSerialPortMonitor\obj\Debug\
C:\Users\fapo.SPOTTOG\Source\Repos\open-serial-port-monitor\src\OpenSerialPortMonitor\obj\Debug\
Whitestone.OpenSerialPortMonitor.Main
none
false
DEBUG;TRACE
D:\Projects\Temp\open-serial-port-monitor\src\OpenSerialPortMonitor\App.xaml
C:\Users\fapo.SPOTTOG\Source\Repos\open-serial-port-monitor\src\OpenSerialPortMonitor\App.xaml
5231517310

26-1779096540
692133236741
23-1332301753
701201618920
Views\AboutView.xaml;Views\MainView.xaml;Views\SerialConnectorView.xaml;Views\SerialDataSendView.xaml;Views\SerialDataView.xaml;

True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
D:\Projects\Temp\open-serial-port-monitor\src\OpenSerialPortMonitor\obj\Debug\GeneratedInternalTypeHelper.g.i.cs
FD:\Projects\Temp\open-serial-port-monitor\src\OpenSerialPortMonitor\App.xaml;;
FD:\Projects\Temp\open-serial-port-monitor\src\OpenSerialPortMonitor\Views\SerialDataSendView.xaml;;
C:\Users\fapo.SPOTTOG\Source\Repos\open-serial-port-monitor\src\OpenSerialPortMonitor\obj\Debug\GeneratedInternalTypeHelper.g.i.cs
FC:\Users\fapo.SPOTTOG\Source\Repos\open-serial-port-monitor\src\OpenSerialPortMonitor\App.xaml;;
FC:\Users\fapo.SPOTTOG\Source\Repos\open-serial-port-monitor\src\OpenSerialPortMonitor\Views\SerialDataSendView.xaml;;

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading