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

Ported to Avalonia for Mac/Linux usage #52

Open
wants to merge 2 commits 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
16 changes: 11 additions & 5 deletions Netling.Client/App.xaml → Netling.Client/App.axaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<Application x:Class="Netling.Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<FluentTheme Mode="Light" />
<!-- Add the line below to get OxyPlot UI theme applied. -->
<StyleInclude Source="resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia" />

</Application.Styles>

<Application.Resources>
<VisualBrush x:Key="RedBrush" TileMode="Tile" Viewport="0,0,8,8" ViewportUnits="Absolute" Viewbox="0,0,8,8" ViewboxUnits="Absolute">
<VisualBrush x:Key="RedBrush" TileMode="Tile">
<VisualBrush.Visual>
<Grid Background="Red">
<Path Data="M 0 8 L 8 0" Stroke="White" StrokeThickness="1" />
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Application.Resources>
</Application>
</Application>
24 changes: 24 additions & 0 deletions Netling.Client/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace Netling.Client
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}

base.OnFrameworkInitializationCompleted();
}
}
}
11 changes: 0 additions & 11 deletions Netling.Client/App.xaml.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<UserControl x:Class="Netling.Client.LineGraphControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<UserControl x:Class="Netling.Client.LineGraphControl"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oxy="clr-namespace:OxyPlot.Avalonia;assembly=OxyPlot.Avalonia"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="300">
<Grid>
<oxy:PlotView x:Name="Graph" Background="Transparent" Margin="0, -1, -8, 0"></oxy:PlotView>
</Grid>
</UserControl>
</UserControl>
69 changes: 69 additions & 0 deletions Netling.Client/LineGraphControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections.Generic;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;

namespace Netling.Client;

public partial class LineGraphControl : UserControl
{
public LineGraphControl()
{
InitializeComponent();
}

public void Draw(IEnumerable<DataPoint> points, string? trackerFormatString = null)
{
var plotModel = new PlotModel
{
PlotMargins = new OxyThickness(0),
PlotAreaBorderThickness = new OxyThickness(0)
};

plotModel.Axes.Add(new LinearAxis
{
MinimumPadding = 0.01,
MaximumPadding = 0.01,
IsAxisVisible = false,
IsZoomEnabled = false,
IsPanEnabled = false,
Position = AxisPosition.Bottom
});

plotModel.Axes.Add(new LinearAxis
{
Minimum = 0.0,
MaximumPadding = 0.1,
TickStyle = TickStyle.None,
MajorGridlineStyle = LineStyle.Solid,
MinorGridlineStyle = LineStyle.Dot,
IsZoomEnabled = false,
IsPanEnabled = false,
LabelFormatter = d => "",
AxisTickToLabelDistance = 0
});

var ls = new LineSeries
{
Color = OxyColor.Parse("#ff0079c5"),
CanTrackerInterpolatePoints = false
};

if (trackerFormatString != null)
{
ls.TrackerFormatString = trackerFormatString;
}

foreach (var point in points)
{
ls.Points.Add(point);
}

plotModel.Series.Add(ls);
Graph.Model = plotModel;
}
}
66 changes: 0 additions & 66 deletions Netling.Client/LineGraphControl.xaml.cs

This file was deleted.

41 changes: 29 additions & 12 deletions Netling.Client/MainWindow.xaml → Netling.Client/MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
<Window x:Class="Netling.Client.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Netling" Width="500" Height="223" ResizeMode="NoResize">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Title="Netling" Width="500" Height="223">
<Grid Margin="10">
<StackPanel Orientation="Horizontal">
<StackPanel Margin="0,0,20,0">
<TextBlock Text="Threads" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<ComboBox x:Name="Threads" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" Height="25" Margin="0,5,0,0" />
<TextBlock Text="Threads" VerticalAlignment="Top" HorizontalAlignment="Left" />
<ComboBox x:Name="Threads" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"
Margin="0,5,0,0">

<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Margin="0,0,20,0">
<TextBlock Text="Duration" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<ComboBox x:Name="Duration" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" Height="25" Margin="0,5,0,0">
<TextBlock Text="Duration" VerticalAlignment="Top" HorizontalAlignment="Left" />
<ComboBox x:Name="Duration" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"
Margin="0,5,0,0">
<ComboBoxItem IsSelected="True">10 seconds</ComboBoxItem>
<ComboBoxItem>20 seconds</ComboBoxItem>
<ComboBoxItem>1 minute</ComboBoxItem>
Expand All @@ -25,11 +37,16 @@
</ComboBox>
</StackPanel>
</StackPanel>

<TextBlock Text="URL" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,61,0,0"/>
<TextBox x:Name="Url" VerticalAlignment="Stretch" KeyUp="Urls_OnKeyUp" HorizontalAlignment="Stretch" Padding="6" Margin="0,82,0,50" />

<Button Content="Run" x:Name="StartButton" Background="#ff0079c5" BorderThickness="0" Foreground="White" Click="StartButton_Click" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="100" Height="30"/>
<ProgressBar x:Name="StatusProgressbar" VerticalAlignment="Bottom" Minimum="0" Maximum="100" HorizontalAlignment="Stretch" Visibility="Hidden" Height="16" Margin="120,0,0,7" />
<TextBlock Text="URL" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,61,0,0" />
<TextBox x:Name="Url" VerticalAlignment="Stretch" KeyUp="Urls_OnKeyUp"
HorizontalAlignment="Stretch"
Padding="6" Margin="0,82,0,50" />
<Button Content="Run" x:Name="StartButton" Background="#ff0079c5" BorderThickness="0"
Foreground="White"
Click="StartButton_Click" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="100"
Height="30" />
<ProgressBar x:Name="StatusProgressbar" VerticalAlignment="Bottom" Minimum="0" Maximum="100"
HorizontalAlignment="Stretch" IsVisible="False" Height="16" Margin="120,0,0,7" />
</Grid>
</Window>
</Window>
Loading