Skip to content

Commit

Permalink
Amend OxyPlot theme; Improve LineCandleStickSeries and Xaml cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
BobLd committed Dec 18, 2021
1 parent 0c8c646 commit 7b4d9fc
Show file tree
Hide file tree
Showing 25 changed files with 421 additions and 462 deletions.
398 changes: 288 additions & 110 deletions Panoptes.ViewModels/Charts/LineCandleStickSeries.cs

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions Panoptes.ViewModels/Charts/OxyPlotSelectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private Task ProcessPlot1day(CancellationToken cancelationToken)

private Task SetAndProcessPlot(PlotSerieTypes serieTypes, TimeSpan period, CancellationToken cancelationToken)
{
if (SelectedSeries == null) return Task.CompletedTask;

if (_plotCommands.Any(c => c.IsRunning))
{
foreach (var running in _plotCommands.Where(c=>c.IsRunning))
Expand Down Expand Up @@ -397,7 +399,7 @@ private Task SetAndProcessPlot(PlotSerieTypes serieTypes, TimeSpan period, Cance
PlotSerieTypes = serieTypes;
Period = period;
InvalidatePlotThreadUI();
InvalidatePlotThreadUI(true);
Logger.LogInformation("OxyPlotSelectionViewModel.SetAndProcessPlot: Done({PlotSerieTypes}, {period}->{Period}, {Id}).", PlotSerieTypes, period, Period, Environment.CurrentManagedThreadId);
DisplayLoading = false;
}, cancelationToken);
Expand Down Expand Up @@ -556,7 +558,7 @@ private void InvalidatePlotWithTiming(bool updateData)
_invalidatePlotTiming[SelectedSeries.Title] = current;

_limitRefreshMs = Math.Max(_limitRefreshMsSettings, (int)(current * 500.0)); // 500 times the time in ms it took to render
Log.Debug("It took {current:0.000000}ms to refresh, refresh limit set to {Time}ms for {Title}.", current, _limitRefreshMs, SelectedSeries.Title);
//Log.Debug("It took {current:0.000000}ms to refresh, refresh limit set to {Time}ms for {Title}.", current, _limitRefreshMs, SelectedSeries.Title);
}

private void ResultQueueReader(object sender, DoWorkEventArgs e)
Expand Down Expand Up @@ -789,7 +791,7 @@ private void ParseResult(Result result)
_ordersDic.TryAdd(order.Key, order.Value);
}

InvalidatePlotThreadUI();
InvalidatePlotThreadUI(false);
}

private void TimeSpanAxis1_AxisChanged(object sender, AxisChangedEventArgs e)
Expand Down Expand Up @@ -839,8 +841,14 @@ private void AddPlotThreadUI(PlotModel plot)
}

private DateTime _lastInvalidatePlot = DateTime.MinValue;
private void InvalidatePlotThreadUI()
private void InvalidatePlotThreadUI(bool force)
{
if (force)
{
_resultBgWorker.ReportProgress(1);
return;
}

var now = DateTime.UtcNow;
if ((now - _lastInvalidatePlot).TotalMilliseconds > _limitRefreshMs)
{
Expand Down
28 changes: 0 additions & 28 deletions Panoptes/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,17 @@

<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
<!--<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseDark.xaml"/>-->
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Default.xaml"/>
<StyleInclude Source="avares://Panoptes/Resources/Themes/BaseDark.axaml"/>
<StyleInclude Source="avares://Panoptes/Resources/TablerIcons.axaml"/>
<StyleInclude Source="avares://Panoptes/Resources/LogoPlain.axaml"/>
<StyleInclude Source="avares://Panoptes/Resources/Themes/OxyPlot.axaml"/>
<!--<StyleInclude Source="resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia"/>-->

<Style Selector="TabItem">
<Setter Property="FontSize" Value="11"/>
<Setter Property="Padding" Value="7,2,7,3"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>

<!--OxyPlot-->
<Style Selector="charts|AxisTrackerControl">
<Setter Property="Background" Value="{StaticResource ThemeAccentColor2}"/>
<Setter Property="LineStroke" Value="{StaticResource ThemeAccentColor}"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalLineVisibility" Value="True"/>
<Setter Property="VerticalLineVisibility" Value="True"/>
<Setter Property="Distance" Value="5"/>
<Setter Property="ShowPointer" Value="False"/>
<Setter Property="Template">
<ControlTemplate TargetType="{x:Type charts:AxisTrackerControl}">
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Line Name="PART_HorizontalLine" IsVisible="{TemplateBinding HorizontalLineVisibility}"
Stroke="{TemplateBinding LineStroke}" StrokeDashArray="{TemplateBinding LineDashArray}"/>
<Line Name="PART_VerticalLine" IsVisible="{TemplateBinding VerticalLineVisibility}"
Stroke="{TemplateBinding LineStroke}" StrokeDashArray="{TemplateBinding LineDashArray}"/>
<Panel Name="PART_ContentContainer">
<Path Name="PART_Path" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0"/>
<ContentPresenter Name="PART_Content" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Panel>
</Canvas>
</ControlTemplate>
</Setter>
</Style>
</Application.Styles>

<Application.Resources>
Expand Down
25 changes: 4 additions & 21 deletions Panoptes/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,17 @@
</Style>
</Window.Styles>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid RowDefinitions="24,*,Auto">
<DockPanel Grid.Row="0">
<Menu DockPanel.Dock="Left">
<MenuItem Header="_File">
<MenuItem Header="_Open..." Command="{Binding OpenSessionCommand}"/> <!--HotKey="Ctrl+O"-->
<MenuItem Header="_Open..." Command="{Binding OpenSessionCommand}" HotKey="Ctrl+O" /> <!--HotKey="Ctrl+O"-->
<Separator/>
<MenuItem Header="_Close" Command="{Binding CloseCommand}"/>
<Separator/>
<MenuItem Header="_Export..." Command="{Binding ExportCommand}"/>
<Separator/>
<MenuItem Header="E_xit" Command="{Binding ExitCommand}"/> <!--HotKey="Alt+F4"-->
<MenuItem Header="E_xit" Command="{Binding ExitCommand}" HotKey="Alt+F"/> <!--HotKey="Alt+F4"-->
</MenuItem>
<MenuItem Header="_View">
<CheckBox Content="_Statistics" IsChecked="{Binding StatisticsPane.IsVisible, Mode=TwoWay}"/>
Expand Down Expand Up @@ -87,18 +81,7 @@
<Label DockPanel.Dock="Right" Content="UTC:" HorizontalAlignment="Right" ToolTip.Tip="UTC"/>
</DockPanel>

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="149*"/>
<RowDefinition Height="113*"/>
<RowDefinition Height="120*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="337*"/>
</Grid.ColumnDefinitions>

<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,337*" RowDefinitions="149*,113*,120*">
<panels:RuntimeStatisticsPanelControl DataContext="{Binding RuntimeStatisticsPane}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

<panels:StatisticsPanelControl DataContext="{Binding StatisticsPane}" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
Expand Down
25 changes: 25 additions & 0 deletions Panoptes/Resources/Themes/OxyPlot.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@


<!-- Add Styles Here -->
<Style Selector="charts|AxisTrackerControl">
<Setter Property="Background" Value="{StaticResource ThemeAccentColor2}"/>
<Setter Property="LineStroke" Value="{StaticResource ThemeAccentColor}"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalLineVisibility" Value="True"/>
<Setter Property="VerticalLineVisibility" Value="True"/>
<Setter Property="Distance" Value="5"/>
<Setter Property="ShowPointer" Value="False"/>
<Setter Property="Template">
<ControlTemplate TargetType="{x:Type charts:AxisTrackerControl}">
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Line Name="PART_HorizontalLine" IsVisible="{TemplateBinding HorizontalLineVisibility}"
Stroke="{TemplateBinding LineStroke}" StrokeDashArray="{TemplateBinding LineDashArray}"/>
<Line Name="PART_VerticalLine" IsVisible="{TemplateBinding VerticalLineVisibility}"
Stroke="{TemplateBinding LineStroke}" StrokeDashArray="{TemplateBinding LineDashArray}"/>
<Panel Name="PART_ContentContainer">
<Path Name="PART_Path" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0"/>
<ContentPresenter Name="PART_Content" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Panel>
</Canvas>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="oxy|TrackerControl">
<Setter Property="Background" Value="#E0FFFFA0" />
<Setter Property="BorderBrush" Value="Black" />
Expand Down
2 changes: 1 addition & 1 deletion Panoptes/Views/Charts/OxyPlot/AxisTrackerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private Geometry CreatePointerBorderGeometry(HorizontalAlignment ha, VerticalAli
}
else
{
throw new ArgumentException("Not possible");
throw new ArgumentException("AxisTrackerControl.CreatePointerBorderGeometry: Not possible");
}

if (points == null)
Expand Down
8 changes: 5 additions & 3 deletions Panoptes/Views/Charts/OxyPlot/MultiTrackerManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public static Series GetSeriesFromPoint(PlotModel plotModel, ScreenPoint point,
double mindist = double.MaxValue;
Series nearestSeries = null;

foreach (var series in plotModel.Series.Reverse().Where(s => s.IsVisible))
var copy = plotModel.Series.ToList();
copy.Reverse();
foreach (var series in copy.Where(s => s.IsVisible))
{
var thr = series.GetNearestPoint(point, true) ?? series.GetNearestPoint(point, false);

Expand All @@ -168,7 +170,7 @@ public static Series GetSeriesFromPoint(PlotModel plotModel, ScreenPoint point,
}
catch (Exception ex)
{
Log.Warning(ex, "MultiTrackerManipulator.GetSeriesFromPoint");
Log.Error(ex, "MultiTrackerManipulator.GetSeriesFromPoint");
return null;
}
}
Expand Down Expand Up @@ -292,7 +294,7 @@ public static TrackerHitResult GetNearestHit(Series series, ScreenPoint point, b
}
catch (Exception ex)
{
Log.Warning(ex, "MultiTrackerManipulator.GetNearestHit");
Log.Error(ex, "MultiTrackerManipulator.GetNearestHit");
return null;
}
}
Expand Down
7 changes: 1 addition & 6 deletions Panoptes/Views/Charts/OxyPlotSelectionControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
xmlns:charts="clr-namespace:Panoptes.Views.Charts"
mc:Ignorable="d"
d:DesignWidth="800" d:DesignHeight="450">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid RowDefinitions="Auto,*">
<StackPanel Margin="4" Orientation="Horizontal">
<Label Content="Series"></Label>
<ComboBox MinWidth="100" Items="{Binding PlotModels}" SelectedItem="{Binding SelectedSeries, Mode=TwoWay}" IsTextSearchEnabled="True"/>
Expand Down
16 changes: 1 addition & 15 deletions Panoptes/Views/NewSession/NewFileSessionControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@
</Style>
</UserControl.Styles>

<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="5"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid Margin="5" ColumnDefinitions="60,*,40" RowDefinitions="Auto,Auto,5,Auto,Auto">
<Label Grid.Row="0" Content="File"/>
<TextBox Name="_textBoxFileName" Grid.Row="0" Grid.Column="1" Text="{Binding FileName}"
IsEnabled="{Binding OpenCommandAsync.IsRunning, Converter={StaticResource InverseBooleanConverter}}"/>
Expand Down
18 changes: 1 addition & 17 deletions Panoptes/Views/NewSession/NewMongoSessionControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,7 @@
</Style>
</UserControl.Styles>

<Grid Margin="5">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid Margin="5" ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Label Grid.Row="0" Content="Host"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Host}"
IsEnabled="{Binding OpenCommandAsync.IsRunning, Converter={StaticResource InverseBooleanConverter}}"/>
Expand Down
7 changes: 1 addition & 6 deletions Panoptes/Views/NewSession/NewSessionWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
</DataTemplate>
</Window.DataTemplates>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="36"></RowDefinition>
</Grid.RowDefinitions>

<Grid RowDefinitions="*,36">
<TabControl Margin="5" Items="{Binding NewSessionViewModels}" SelectedItem="{Binding SelectedViewModel}"
IsEnabled="{Binding IsAnyRunning, Converter={StaticResource InverseBooleanConverter}}">
<TabControl.ItemTemplate>
Expand Down
17 changes: 1 addition & 16 deletions Panoptes/Views/NewSession/NewStreamSessionControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,7 @@
</Style>
</UserControl.Styles>

<Grid Margin="5">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid Margin="5" ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Label Grid.Row="0" Content="Host"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Host}"
IsEnabled="{Binding OpenCommandAsync.IsRunning, Converter={StaticResource InverseBooleanConverter}}"/>
Expand Down
1 change: 1 addition & 0 deletions Panoptes/Views/Panels/CashBookDataGridControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="800" d:DesignHeight="450">

<DataGrid x:Name="_dataGrid" IsReadOnly="True" GridLinesVisibility="None" AutoGenerateColumns="False"
CanUserReorderColumns="True" CanUserResizeColumns="True"
HeadersVisibility="Column" DoubleTapped="OnDataGridDoubleTapped"
Expand Down
7 changes: 1 addition & 6 deletions Panoptes/Views/Panels/CashBookPanelControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
</Style>
</UserControl.Styles>

<Grid Margin="0,2,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid Margin="0,2,0,0" RowDefinitions="*,25">
<local:CashBookDataGridControl Items="{Binding CurrentCashes, Mode=OneWay}"/>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
IsVisible="{Binding DisplayLoading}" IsEnabled="{Binding DisplayLoading}">
Expand All @@ -30,7 +26,6 @@
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label Content="Symbol "/>
<TextBox Text="{Binding Search}" Watermark="Search..."/>

<Label Content=" Account Ccy: " ToolTip.Tip="{Binding AccountCurrencySymbol}"/>
<Label Content="{Binding AccountCurrency}" ToolTip.Tip="{Binding AccountCurrencySymbol}"/>
</StackPanel>
Expand Down
6 changes: 1 addition & 5 deletions Panoptes/Views/Panels/HoldingsPanelControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
</Style>
</UserControl.Styles>

<Grid Margin="0,2,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid Margin="0,2,0,0" RowDefinitions="*,25">
<local:HoldingsDataGridControl Items="{Binding CurrentHoldings, Mode=OneWay}"/>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
IsVisible="{Binding DisplayLoading}" IsEnabled="{Binding DisplayLoading}">
Expand Down
Loading

0 comments on commit 7b4d9fc

Please sign in to comment.