Skip to content

Commit

Permalink
support cross platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Oct 31, 2018
1 parent 901be2d commit 1de97e5
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Markup;
using Avalonia.Media.Imaging;
using SignalGo.Shared.Helpers;
Expand Down
8 changes: 7 additions & 1 deletion Cross-Platform/SignalGoTest.Desktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public MainWindow()
//a.DataType
ListBox ListConnections = this.FindControl<ListBox>("ListConnections");
ListConnections.SelectedIndex = 1;
Closing += MainWindow_Closing;
}

private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
MainViewModel.This.Save();
}

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

AddNewView.IsVisible = item.Name == "Add New...";
ConnectionView.IsVisible = !AddNewView.IsVisible;
Expand Down
22 changes: 16 additions & 6 deletions Cross-Platform/SignalGoTest.Desktop/SignalGoTest.Desktop.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!--<TargetFramework>netcoreapp2.0</TargetFramework>-->
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFramework>netcoreapp2.0</TargetFramework>
<!--<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>-->
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
Expand All @@ -23,6 +25,7 @@
<None Remove="Views\AddNewView.xaml" />
<None Remove="Views\BusyDialogView.xaml" />
<None Remove="Views\ConnectionInfoView.xaml" />
<None Remove="Views\JsonTemplateWindow.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Images\classicons.png">
Expand All @@ -48,16 +51,20 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.1" />
<PackageReference Include="Avalonia.Desktop" Version="0.6.1" />
<PackageReference Include="Avalonia" Version="0.7.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NSubsys" Version="0.7.0-build20180604-0047">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\SignalGo-full-net\SignalGo.Client\SignalGo.Client.csproj" />
<ProjectReference Include="..\..\..\SignalGo-full-net\SignalGo.Shared\SignalGo.Shared.csproj" />
<ProjectReference Include="..\SignalGoTest.Models\SignalGoTest.Models.csproj" />
<ProjectReference Include="..\SignalGoTest.ViewModels\SignalGoTest.ViewModels.csproj" />
<ProjectReference Include="D:\Github\MVVMGo\MvvmGo\MvvmGo\MvvmGo.csproj" />
<ProjectReference Include="D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\SignalGo.Client.csproj" />
<ProjectReference Include="D:\SignalGo\Github\SignalGo-full-net\SignalGo.Shared\SignalGo.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Views\AddNewView.xaml">
Expand All @@ -69,5 +76,8 @@
<EmbeddedResource Update="Views\ConnectionInfoView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\JsonTemplateWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.Data;

namespace SignalGoTest.Desktop.Views
{
Expand Down
43 changes: 34 additions & 9 deletions Cross-Platform/SignalGoTest.Desktop/Views/ConnectionInfoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
xmlns:conv="clr-namespace:SignalGoTest.Desktop.Converters"
xmlns:types="clr-namespace:SignalGo.Shared.Helpers;assembly=SignalGo.Shared"
xmlns:viewmodels="clr-namespace:SignalGoTest.ViewModels;assembly=SignalGoTest.ViewModels">
<UserControl.DataContext>
<UserControl.Resources>
<viewmodels:ConnectionInfoViewModel x:Key="ConnectionInfoViewModel"/>
</UserControl.Resources>
<!--<UserControl.DataContext>
<viewmodels:ConnectionInfoViewModel />
</UserControl.DataContext>
<local:BusyDialogView IsBusy="{Binding IsBusy}" IsAlert="{Binding IsAlert}" Message="{Binding BusyContent}">
</UserControl.DataContext>-->
<local:BusyDialogView DataContext="{StaticResource ConnectionInfoViewModel}" IsBusy="{Binding IsBusy}" IsAlert="{Binding IsAlert}" Message="{Binding BusyContent}">
<local:BusyDialogView.Child>
<Grid Margin="10">
<Grid.RowDefinitions>
Expand All @@ -21,7 +24,7 @@
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<Button Command="{Binding ConnectCommand}" Content="Connect" />
<Button x:Name="btndisconnect" Command="{Binding DisconnectCommand}" IsEnabled="False" Content="Disconncet" Margin="5,0,0,0"/>
<Button x:Name="btnHtttpUpdate" Content="Http Update" Margin="5,0,0,0"/>
<Button x:Name="btnHtttpUpdate" Command="{Binding HttpUpdateCommand}" Content="Http Update" Margin="5,0,0,0"/>
<Button x:Name="btnSave" Command="{Binding SaveCommand}" Content="Save" Margin="5,0,0,0"/>
</StackPanel>
</StackPanel>
Expand All @@ -44,7 +47,7 @@
<TextBox x:Name="txtSearch">

</TextBox>
<TreeView x:Name="TreeViewServices" BorderThickness="1" Background="White" Margin="0,5,0,0" DataContext="{Binding CurrentConnectionInfo}" Items="{Binding ItemsSource}" Grid.Row="1">
<TreeView x:Name="TreeViewServices" BorderThickness="1" Background="White" Margin="0,5,0,0" Items="{Binding CurrentConnectionInfo.ItemsSource}" SelectedItem="{Binding SelectedTreeItem}" Grid.Row="1">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="{x:Type self:ServiceDetailsInterface}" ItemsSource="{Binding Methods}">
<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -139,7 +142,7 @@
<TextBox x:Name="newRequestName" Text=""/>
<Button x:Name="btnAddRequest" Content="Add" Grid.Column="1"/>
</Grid>
<ListBox x:Name="lstRequests" Grid.Row="1" SelectedIndex="0" Items="{Binding SelectedItem.Requests,ElementName=TreeViewServices}">
<ListBox x:Name="lstRequests" Grid.Row="1" Items="{Binding SelectedItem.Requests,ElementName=TreeViewServices}" SelectedItem="{Binding ServiceDetailsRequestInfo,Mode=OneWayToSource}" SelectedIndex="0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
Expand Down Expand Up @@ -345,7 +348,7 @@
</ContentControl>
</TabItem>
<TabItem Header="Request">
<Grid>
<Grid IsEnabled="{Binding IsRequestSelected}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
Expand All @@ -356,6 +359,28 @@
</Grid.RowDefinitions>

<TextBlock Text="Request Values:"/>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled">
<ItemsControl DataContext="{Binding ElementName=lstRequests,Path=SelectedItem}" Items="{Binding Parameters}" Margin="0,5,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="mainStack" Margin="5" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="{Binding Name}"/>
<TextBlock VerticalAlignment="Center" Text=":"/>
<Button Margin="5,0,0,0" VerticalAlignment="Center" Content="Simple Template" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding LoadSimpleTemplateCommand}" CommandParameter="{Binding DataContext,ElementName=mainStack}" />
<Button Margin="5,0,0,0" VerticalAlignment="Center" Content="Full Template" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding LoadFullTemplateCommand}" CommandParameter="{Binding DataContext,ElementName=mainStack}"/>
</StackPanel>
<TextBox Grid.Column="1" Text="{Binding Value}" AcceptsReturn="True" TextWrapping="Wrap"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<!--<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">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" IsReadOnly="True" Binding="{Binding Name}"/>
Expand Down Expand Up @@ -405,7 +430,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="btnSend" Content="Send" Padding="10,0,10,0" Margin="0,5,0,0" />
<Button x:Name="btnSend" DataContext="{DynamicResource ConnectionInfoViewModel}" Command="{Binding SendCommand}" Content="Send" Padding="10,0,10,0" Margin="0,5,0,0" />
<Button Grid.Column="1" x:Name="btnAttachment" Content="Attach File (0)" Padding="10,0,10,0" Margin="10,5,0,0" />
<Button Grid.Column="2" x:Name="btnRemoveAttachment" Content="Remove Attachment" Padding="10,0,10,0" Margin="10,5,0,0" />
</Grid>
Expand All @@ -415,7 +440,7 @@
<TextBlock Text="Comming soon!"/>
</TabItem>-->
<TabItem x:Name="rawDataTab" Header="Raw Data">
<TextBox x:Name="txtReponse" Margin="0,5,0,0" AcceptsReturn="True" TextWrapping="Wrap"/>
<TextBox x:Name="txtReponse" Text="{Binding ServiceDetailsRequestInfo.Response}" Margin="0,5,0,0" AcceptsReturn="True" TextWrapping="Wrap"/>
</TabItem>
</TabControl>
<Button x:Name="btnToString" Content="ToString" Height="23" Padding="10,0,10,0" Margin="0,5,0,0" Grid.Row="5"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.Templates;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using SignalGo.Shared.Models;
using SignalGoTest.ViewModels;
using System.Collections;

namespace SignalGoTest.Desktop.Views
{
public class ConnectionInfoView : UserControl
{
public ConnectionInfoView()
{
ConnectionInfoViewModel.ShowJsonTemplateWindowAction = async (value) =>
{
JsonTemplateWindow jsonTemplateWindow = new JsonTemplateWindow();
jsonTemplateWindow.ZIndex = 100;
jsonTemplateWindow.Text = value;
await jsonTemplateWindow.ShowDialog();
};

InitializeComponent();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="JsonTemplateWindow" Width="500" MaxHeight="500">
<TextBox x:Name="TxtJson" AcceptsReturn="True" TextWrapping="Wrap" IsReadOnly="True">

</TextBox>
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace SignalGoTest.Desktop.Views
{
public class JsonTemplateWindow : Window
{
public JsonTemplateWindow()
{
this.InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);

}

public string Text
{
set
{
TextBox TxtJson = this.FindControl<TextBox>("TxtJson");
TxtJson.Text = value;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace SignalGoTest.Models
public class ConnectionInfoViewHelper
{
public ClientProvider Provider { get; private set; } = new ClientProvider();

public string Session { get; set; }
public string AttachmentFile { get; set; }
public ConnectionInfoViewHelper()
{

Expand Down
Loading

0 comments on commit 1de97e5

Please sign in to comment.