Skip to content

Commit 1de97e5

Browse files
support cross platform
1 parent 901be2d commit 1de97e5

11 files changed

Lines changed: 461 additions & 33 deletions

File tree

Cross-Platform/SignalGoTest.Desktop/Converters/TypeToImageConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Avalonia;
22
using Avalonia.Controls;
3+
using Avalonia.Data.Converters;
34
using Avalonia.Markup;
45
using Avalonia.Media.Imaging;
56
using SignalGo.Shared.Helpers;

Cross-Platform/SignalGoTest.Desktop/MainWindow.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ public MainWindow()
2626
//a.DataType
2727
ListBox ListConnections = this.FindControl<ListBox>("ListConnections");
2828
ListConnections.SelectedIndex = 1;
29+
Closing += MainWindow_Closing;
30+
}
31+
32+
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
33+
{
34+
MainViewModel.This.Save();
2935
}
3036

3137
private void lslConnections_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -34,7 +40,7 @@ private void lslConnections_SelectionChanged(object sender, SelectionChangedEven
3440
ConnectionInfoView ConnectionView = this.FindControl<ConnectionInfoView>("ConnectionView");
3541
AddNewView AddNewView = this.FindControl<AddNewView>("AddNewView");
3642
ConnectionInfo item = (ConnectionInfo)ListConnections.SelectedItem;
37-
((ConnectionInfoViewModel)ConnectionView.DataContext).CurrentConnectionInfo = item;
43+
((ConnectionInfoViewModel)((Control)ConnectionView.Content).DataContext).CurrentConnectionInfo = item;
3844

3945
AddNewView.IsVisible = item.Name == "Add New...";
4046
ConnectionView.IsVisible = !AddNewView.IsVisible;

Cross-Platform/SignalGoTest.Desktop/SignalGoTest.Desktop.csproj

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<!--<TargetFramework>netcoreapp2.0</TargetFramework>-->
5-
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<!--<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>-->
6+
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
67
</PropertyGroup>
8+
79
<ItemGroup>
810
<Compile Update="**\*.xaml.cs">
911
<DependentUpon>%(Filename)</DependentUpon>
@@ -23,6 +25,7 @@
2325
<None Remove="Views\AddNewView.xaml" />
2426
<None Remove="Views\BusyDialogView.xaml" />
2527
<None Remove="Views\ConnectionInfoView.xaml" />
28+
<None Remove="Views\JsonTemplateWindow.xaml" />
2629
</ItemGroup>
2730
<ItemGroup>
2831
<EmbeddedResource Include="Resources\Images\classicons.png">
@@ -48,16 +51,20 @@
4851
</EmbeddedResource>
4952
</ItemGroup>
5053
<ItemGroup>
51-
<PackageReference Include="Avalonia" Version="0.6.1" />
52-
<PackageReference Include="Avalonia.Desktop" Version="0.6.1" />
54+
<PackageReference Include="Avalonia" Version="0.7.0" />
55+
<PackageReference Include="Avalonia.Desktop" Version="0.7.0" />
5356
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
57+
<PackageReference Include="NSubsys" Version="0.7.0-build20180604-0047">
58+
<PrivateAssets>all</PrivateAssets>
59+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
60+
</PackageReference>
5461
</ItemGroup>
5562
<ItemGroup>
63+
<ProjectReference Include="..\..\..\SignalGo-full-net\SignalGo.Client\SignalGo.Client.csproj" />
64+
<ProjectReference Include="..\..\..\SignalGo-full-net\SignalGo.Shared\SignalGo.Shared.csproj" />
5665
<ProjectReference Include="..\SignalGoTest.Models\SignalGoTest.Models.csproj" />
5766
<ProjectReference Include="..\SignalGoTest.ViewModels\SignalGoTest.ViewModels.csproj" />
5867
<ProjectReference Include="D:\Github\MVVMGo\MvvmGo\MvvmGo\MvvmGo.csproj" />
59-
<ProjectReference Include="D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\SignalGo.Client.csproj" />
60-
<ProjectReference Include="D:\SignalGo\Github\SignalGo-full-net\SignalGo.Shared\SignalGo.Shared.csproj" />
6168
</ItemGroup>
6269
<ItemGroup>
6370
<EmbeddedResource Update="Views\AddNewView.xaml">
@@ -69,5 +76,8 @@
6976
<EmbeddedResource Update="Views\ConnectionInfoView.xaml">
7077
<Generator>MSBuild:Compile</Generator>
7178
</EmbeddedResource>
79+
<EmbeddedResource Update="Views\JsonTemplateWindow.xaml">
80+
<Generator>MSBuild:Compile</Generator>
81+
</EmbeddedResource>
7282
</ItemGroup>
7383
</Project>

Cross-Platform/SignalGoTest.Desktop/Views/BusyDialogView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Avalonia;
22
using Avalonia.Controls;
3+
using Avalonia.Data;
34
using Avalonia.Markup.Xaml;
4-
using Avalonia.Markup.Xaml.Data;
55

66
namespace SignalGoTest.Desktop.Views
77
{

Cross-Platform/SignalGoTest.Desktop/Views/ConnectionInfoView.xaml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
xmlns:conv="clr-namespace:SignalGoTest.Desktop.Converters"
66
xmlns:types="clr-namespace:SignalGo.Shared.Helpers;assembly=SignalGo.Shared"
77
xmlns:viewmodels="clr-namespace:SignalGoTest.ViewModels;assembly=SignalGoTest.ViewModels">
8-
<UserControl.DataContext>
8+
<UserControl.Resources>
9+
<viewmodels:ConnectionInfoViewModel x:Key="ConnectionInfoViewModel"/>
10+
</UserControl.Resources>
11+
<!--<UserControl.DataContext>
912
<viewmodels:ConnectionInfoViewModel />
10-
</UserControl.DataContext>
11-
<local:BusyDialogView IsBusy="{Binding IsBusy}" IsAlert="{Binding IsAlert}" Message="{Binding BusyContent}">
13+
</UserControl.DataContext>-->
14+
<local:BusyDialogView DataContext="{StaticResource ConnectionInfoViewModel}" IsBusy="{Binding IsBusy}" IsAlert="{Binding IsAlert}" Message="{Binding BusyContent}">
1215
<local:BusyDialogView.Child>
1316
<Grid Margin="10">
1417
<Grid.RowDefinitions>
@@ -21,7 +24,7 @@
2124
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
2225
<Button Command="{Binding ConnectCommand}" Content="Connect" />
2326
<Button x:Name="btndisconnect" Command="{Binding DisconnectCommand}" IsEnabled="False" Content="Disconncet" Margin="5,0,0,0"/>
24-
<Button x:Name="btnHtttpUpdate" Content="Http Update" Margin="5,0,0,0"/>
27+
<Button x:Name="btnHtttpUpdate" Command="{Binding HttpUpdateCommand}" Content="Http Update" Margin="5,0,0,0"/>
2528
<Button x:Name="btnSave" Command="{Binding SaveCommand}" Content="Save" Margin="5,0,0,0"/>
2629
</StackPanel>
2730
</StackPanel>
@@ -44,7 +47,7 @@
4447
<TextBox x:Name="txtSearch">
4548

4649
</TextBox>
47-
<TreeView x:Name="TreeViewServices" BorderThickness="1" Background="White" Margin="0,5,0,0" DataContext="{Binding CurrentConnectionInfo}" Items="{Binding ItemsSource}" Grid.Row="1">
50+
<TreeView x:Name="TreeViewServices" BorderThickness="1" Background="White" Margin="0,5,0,0" Items="{Binding CurrentConnectionInfo.ItemsSource}" SelectedItem="{Binding SelectedTreeItem}" Grid.Row="1">
4851
<TreeView.DataTemplates>
4952
<TreeDataTemplate DataType="{x:Type self:ServiceDetailsInterface}" ItemsSource="{Binding Methods}">
5053
<StackPanel Orientation="Horizontal">
@@ -139,7 +142,7 @@
139142
<TextBox x:Name="newRequestName" Text=""/>
140143
<Button x:Name="btnAddRequest" Content="Add" Grid.Column="1"/>
141144
</Grid>
142-
<ListBox x:Name="lstRequests" Grid.Row="1" SelectedIndex="0" Items="{Binding SelectedItem.Requests,ElementName=TreeViewServices}">
145+
<ListBox x:Name="lstRequests" Grid.Row="1" Items="{Binding SelectedItem.Requests,ElementName=TreeViewServices}" SelectedItem="{Binding ServiceDetailsRequestInfo,Mode=OneWayToSource}" SelectedIndex="0">
143146
<ListBox.ItemTemplate>
144147
<DataTemplate>
145148
<Grid>
@@ -345,7 +348,7 @@
345348
</ContentControl>
346349
</TabItem>
347350
<TabItem Header="Request">
348-
<Grid>
351+
<Grid IsEnabled="{Binding IsRequestSelected}">
349352
<Grid.RowDefinitions>
350353
<RowDefinition Height="auto"/>
351354
<RowDefinition Height="*"/>
@@ -356,6 +359,28 @@
356359
</Grid.RowDefinitions>
357360

358361
<TextBlock Text="Request Values:"/>
362+
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled">
363+
<ItemsControl DataContext="{Binding ElementName=lstRequests,Path=SelectedItem}" Items="{Binding Parameters}" Margin="0,5,0,0">
364+
<ItemsControl.ItemTemplate>
365+
<DataTemplate>
366+
<Grid Margin="5">
367+
<Grid.ColumnDefinitions>
368+
<ColumnDefinition Width="auto"/>
369+
<ColumnDefinition Width="*"/>
370+
</Grid.ColumnDefinitions>
371+
<StackPanel x:Name="mainStack" Margin="5" Orientation="Horizontal">
372+
<TextBlock VerticalAlignment="Center" Text="{Binding Name}"/>
373+
<TextBlock VerticalAlignment="Center" Text=":"/>
374+
<Button Margin="5,0,0,0" VerticalAlignment="Center" Content="Simple Template" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding LoadSimpleTemplateCommand}" CommandParameter="{Binding DataContext,ElementName=mainStack}" />
375+
<Button Margin="5,0,0,0" VerticalAlignment="Center" Content="Full Template" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding LoadFullTemplateCommand}" CommandParameter="{Binding DataContext,ElementName=mainStack}"/>
376+
</StackPanel>
377+
<TextBox Grid.Column="1" Text="{Binding Value}" AcceptsReturn="True" TextWrapping="Wrap"/>
378+
</Grid>
379+
</DataTemplate>
380+
</ItemsControl.ItemTemplate>
381+
</ItemsControl>
382+
</ScrollViewer>
383+
359384
<!--<DataGrid x:Name="DGRequestValues" ScrollViewer.CanContentScroll="False" AutoGenerateColumns="False" CanUserAddRows="False" DataContext="{Binding ElementName=lstRequests,Path=SelectedItem}" ItemsSource="{Binding Parameters}" Margin="0,5,0,0" Grid.Row="1" HeadersVisibility="Column">
360385
<DataGrid.Columns>
361386
<DataGridTextColumn Header="Name" IsReadOnly="True" Binding="{Binding Name}"/>
@@ -405,7 +430,7 @@
405430
<ColumnDefinition Width="auto"/>
406431
<ColumnDefinition Width="auto"/>
407432
</Grid.ColumnDefinitions>
408-
<Button x:Name="btnSend" Content="Send" Padding="10,0,10,0" Margin="0,5,0,0" />
433+
<Button x:Name="btnSend" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding SendCommand}" Content="Send" Padding="10,0,10,0" Margin="0,5,0,0" />
409434
<Button Grid.Column="1" x:Name="btnAttachment" Content="Attach File (0)" Padding="10,0,10,0" Margin="10,5,0,0" />
410435
<Button Grid.Column="2" x:Name="btnRemoveAttachment" Content="Remove Attachment" Padding="10,0,10,0" Margin="10,5,0,0" />
411436
</Grid>
@@ -415,7 +440,7 @@
415440
<TextBlock Text="Comming soon!"/>
416441
</TabItem>-->
417442
<TabItem x:Name="rawDataTab" Header="Raw Data">
418-
<TextBox x:Name="txtReponse" Margin="0,5,0,0" AcceptsReturn="True" TextWrapping="Wrap"/>
443+
<TextBox x:Name="txtReponse" Text="{Binding ServiceDetailsRequestInfo.Response}" Margin="0,5,0,0" AcceptsReturn="True" TextWrapping="Wrap"/>
419444
</TabItem>
420445
</TabControl>
421446
<Button x:Name="btnToString" Content="ToString" Height="23" Padding="10,0,10,0" Margin="0,5,0,0" Grid.Row="5"/>

Cross-Platform/SignalGoTest.Desktop/Views/ConnectionInfoView.xaml.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
using Avalonia;
2-
using Avalonia.Controls;
3-
using Avalonia.Controls.Templates;
1+
using Avalonia.Controls;
42
using Avalonia.Markup.Xaml;
5-
using Avalonia.Markup.Xaml.Templates;
6-
using Avalonia.Media.Imaging;
7-
using Avalonia.Platform;
8-
using SignalGo.Shared.Models;
93
using SignalGoTest.ViewModels;
10-
using System.Collections;
114

125
namespace SignalGoTest.Desktop.Views
136
{
147
public class ConnectionInfoView : UserControl
158
{
169
public ConnectionInfoView()
1710
{
11+
ConnectionInfoViewModel.ShowJsonTemplateWindowAction = async (value) =>
12+
{
13+
JsonTemplateWindow jsonTemplateWindow = new JsonTemplateWindow();
14+
jsonTemplateWindow.ZIndex = 100;
15+
jsonTemplateWindow.Text = value;
16+
await jsonTemplateWindow.ShowDialog();
17+
};
18+
1819
InitializeComponent();
1920
}
2021

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Window xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
Title="JsonTemplateWindow" Width="500" MaxHeight="500">
4+
<TextBox x:Name="TxtJson" AcceptsReturn="True" TextWrapping="Wrap" IsReadOnly="True">
5+
6+
</TextBox>
7+
</Window>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Avalonia;
2+
using Avalonia.Controls;
3+
using Avalonia.Markup.Xaml;
4+
5+
namespace SignalGoTest.Desktop.Views
6+
{
7+
public class JsonTemplateWindow : Window
8+
{
9+
public JsonTemplateWindow()
10+
{
11+
this.InitializeComponent();
12+
#if DEBUG
13+
this.AttachDevTools();
14+
#endif
15+
}
16+
17+
private void InitializeComponent()
18+
{
19+
AvaloniaXamlLoader.Load(this);
20+
21+
}
22+
23+
public string Text
24+
{
25+
set
26+
{
27+
TextBox TxtJson = this.FindControl<TextBox>("TxtJson");
28+
TxtJson.Text = value;
29+
}
30+
}
31+
}
32+
}

Cross-Platform/SignalGoTest.Models/ConnectionInfoViewHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace SignalGoTest.Models
1010
public class ConnectionInfoViewHelper
1111
{
1212
public ClientProvider Provider { get; private set; } = new ClientProvider();
13-
13+
public string Session { get; set; }
14+
public string AttachmentFile { get; set; }
1415
public ConnectionInfoViewHelper()
1516
{
1617

0 commit comments

Comments
 (0)