Neuerstellung

- Quelle: https://github.com/oxyplot/oxyplot
This commit is contained in:
2023-09-02 09:24:59 +02:00
commit 9520c1fa4a
810 changed files with 117869 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<Application x:Class="ExampleBrowser.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,24 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="App.xaml.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Interaction logic for App.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Windows;
namespace ExampleBrowser
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0-windows;net7.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<OutputType>WinExe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\OxyPlot.SkiaSharp.Wpf\OxyPlot.SkiaSharp.Wpf.csproj" />
<ProjectReference Include="..\..\..\OxyPlot.Wpf\OxyPlot.Wpf.csproj" />
<ProjectReference Include="..\..\..\OxyPlot\OxyPlot.csproj" />
<ProjectReference Include="..\..\ExampleLibrary\ExampleLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="..\..\..\..\Icons\OxyPlot_64.png" Link="OxyPlot_64.png" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,133 @@
<Window x:Class="ExampleBrowser.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:oxyWpf="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
xmlns:oxySkia="clr-namespace:OxyPlot.SkiaSharp.Wpf;assembly=OxyPlot.SkiaSharp.Wpf"
xmlns:local="clr-namespace:ExampleBrowser"
Title="OxyPlot.WPF Example Browser"
Height="720" Width="1280" Icon="OxyPlot_64.png">
<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
<SolidColorBrush x:Key="HotItemBackground" Color="#e6f3f7"/>
<SolidColorBrush x:Key="SelectedItemBorder" Color="#6dbdd1"/>
<SolidColorBrush x:Key="SelectedItemBackground" Color="#cbe6ef"/>
<SolidColorBrush x:Key="NormalItemBackground" Color="White"/>
<DrawingBrush x:Key="CheckerBoard" TileMode="Tile" ViewboxUnits="Absolute" Viewbox="0,0,2,2" Viewport="0,0,10,10" ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,2,2" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="LightGray">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,1,1" />
<RectangleGeometry Rect="1,1,1,1" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<Style x:Key="ListboxItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Background" Value="{StaticResource NormalItemBackground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"
StrokeThickness="{TemplateBinding BorderThickness}" RadiusX="3" RadiusY="3" SnapsToDevicePixels="True"/>
<ContentPresenter Margin="8,5" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsSelected" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource HotItemBackground}" />
</MultiTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{StaticResource SelectedItemBackground}" />
<Setter Property="BorderBrush" Value="{StaticResource SelectedItemBorder}" />
<Setter Property="BorderThickness" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid Background="#20000000">
<ListBox ItemsSource="{Binding ExamplesView}" ItemContainerStyle="{DynamicResource ListboxItemStyle}"
SelectedItem="{Binding SelectedExample}" BorderThickness="0,0,0,1">
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="False" ExpandDirection="Down">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Name}" Padding="0 0 8 0"/>
<TextBlock Text="{Binding ItemCount, StringFormat='({0})'}"/>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
</ListBox>
</Grid>
<Grid Grid.Column="1">
<TabControl TabStripPlacement="Bottom">
<TabControl.Resources>
<Style TargetType="{x:Type TextBox}" x:Key="CodeTextBox">
<Setter Property="AcceptsReturn" Value="True"></Setter>
<Setter Property="FontFamily" Value="Consolas"></Setter>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"></Setter>
</Style>
</TabControl.Resources>
<TabItem Header="Plot">
<Grid>
<Grid.Resources>
<local:NotNullVisibilityConverter x:Key="NotNullVisibilityConverter" />
</Grid.Resources>
<oxySkia:PlotView Model="{Binding SkiaModel}" Controller="{Binding SelectedExample.PlotController}" Visibility="{Binding SkiaModel, Converter={StaticResource NotNullVisibilityConverter}}" />
<oxyWpf:PlotView Model="{Binding CanvasModel}" Controller="{Binding SelectedExample.PlotController}" Visibility="{Binding CanvasModel, Converter={StaticResource NotNullVisibilityConverter}}" />
<local:XamlPlotView Model="{Binding CanvasXamlModel}" Controller="{Binding SelectedExample.PlotController}" Visibility="{Binding CanvasXamlModel, Converter={StaticResource NotNullVisibilityConverter}}" />
</Grid>
</TabItem>
<TabItem Header="Code">
<TextBox Text="{Binding Code, Mode=OneWay}" Style="{StaticResource CodeTextBox}" />
</TabItem>
</TabControl>
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock Text="Renderer:" VerticalAlignment="Center" />
<ComboBox SelectedItem="{Binding Renderer}" ItemsSource="{Binding Renderers}" Margin="3,0,0,0" Width="80" />
<CheckBox IsChecked="{Binding Transposed}" Content="Transposed" VerticalAlignment="Center" Margin="10,0,5,0" IsEnabled="{Binding CanTranspose}" />
<CheckBox IsChecked="{Binding Reversed}" Content="Reversed" VerticalAlignment="Center" Margin="10,0,5,0" IsEnabled="{Binding CanReverse}" />
</StackPanel>
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,34 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MainWindow.xaml.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Interaction logic for MainWindow.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ExampleBrowser
{
using Microsoft.Win32;
using System.Windows;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow" /> class.
/// </summary>
public MainWindow()
{
this.InitializeComponent();
SystemEvents.DisplaySettingsChanged += this.SystemEvents_DisplaySettingsChanged;
}
private void SystemEvents_DisplaySettingsChanged(object sender, System.EventArgs e)
{
(this.DataContext as MainWindowViewModel)?.ActiveModel?.PlotView?.InvalidatePlot(false);
}
}
}

View File

@@ -0,0 +1,165 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MainWindowViewModel.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ExampleBrowser
{
using ExampleLibrary;
using OxyPlot;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Data;
public class MainWindowViewModel : INotifyPropertyChanged
{
private bool _CanTranspose;
private bool _CanReverse;
private string _Code;
private Renderer _Renderer;
private PlotModel _PlotModel;
private bool _Transposed;
private bool _Reversed;
private IEnumerable<ExampleInfo> examples;
private ExampleInfo selectedExample;
public MainWindowViewModel()
{
this.Examples = ExampleLibrary.Examples.GetList();
this.ExamplesView = CollectionViewSource.GetDefaultView(this.Examples.OrderBy(e => e.Category));
this.ExamplesView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
}
public event PropertyChangedEventHandler PropertyChanged;
public PlotModel ActiveModel => this.CanvasModel ?? this.SkiaModel;
public bool CanTranspose
{
get => this._CanTranspose;
private set
{
this._CanTranspose = value;
this.RaisePropertyChanged(nameof(this.CanTranspose));
}
}
public bool CanReverse
{
get => this._CanReverse;
private set
{
this._CanReverse = value;
this.RaisePropertyChanged(nameof(this.CanReverse));
}
}
public PlotModel CanvasModel => this.Renderer == Renderer.Canvas ? this._PlotModel : null;
public string Code
{
get => this._Code;
set
{
this._Code = value;
this.RaisePropertyChanged(nameof(this.Code));
}
}
public IEnumerable<ExampleInfo> Examples
{
get => this.examples;
set
{
this.examples = value;
this.RaisePropertyChanged(nameof(this.Examples));
}
}
public ICollectionView ExamplesView { get; set; }
public Renderer Renderer
{
get => this._Renderer;
set
{
this._Renderer = value;
this.CoerceRenderer();
this.RaisePropertyChanged(nameof(this.Renderer));
}
}
private void CoerceRenderer()
{
((IPlotModel)this._PlotModel)?.AttachPlotView(null);
this.RaisePropertyChanged(nameof(this.SkiaModel));
this.RaisePropertyChanged(nameof(this.CanvasXamlModel));
this.RaisePropertyChanged(nameof(this.CanvasModel));
}
public IEnumerable<Renderer> Renderers => Enum.GetValues(typeof(Renderer)).Cast<Renderer>();
public ExampleInfo SelectedExample
{
get => this.selectedExample;
set
{
this.selectedExample = value;
this.CoerceSelectedExample();
this.RaisePropertyChanged(nameof(this.SelectedExample));
}
}
public PlotModel SkiaModel => this.Renderer == Renderer.SkiaSharp ? this._PlotModel : null;
public PlotModel CanvasXamlModel => this.Renderer == Renderer.Canvas_XAML ? this._PlotModel : null;
public bool Transposed
{
get => this._Transposed;
set
{
this._Transposed = value;
this.UpdatePlotModel();
this.RaisePropertyChanged(nameof(this.Transposed));
}
}
public bool Reversed
{
get => this._Reversed;
set
{
this._Reversed = value;
this.UpdatePlotModel();
this.RaisePropertyChanged(nameof(this.Reversed));
}
}
protected void RaisePropertyChanged(string property)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}
private void CoerceSelectedExample()
{
this.CanTranspose = this.SelectedExample?.IsTransposable == true;
this.CanReverse = this.SelectedExample?.IsReversible == true;
this.UpdatePlotModel();
}
private void UpdatePlotModel()
{
var flags = ExampleInfo.PrepareFlags(
this.CanTranspose && this.Transposed,
this.CanReverse && this.Reversed);
this._PlotModel = this.SelectedExample?.GetModel(flags);
this.Code = this.SelectedExample?.GetCode(flags);
this.CoerceRenderer();
}
}
}

View File

@@ -0,0 +1,28 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NotNullVisibilityConverter.cs" company="OxyPlot">
// Copyright (c) 2020 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ExampleBrowser
{
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
public sealed class NotNullVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null
? Visibility.Collapsed
: Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new InvalidOperationException();
}
}
}

View File

@@ -0,0 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System.Windows;
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

View File

@@ -0,0 +1,15 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Renderer.cs" company="OxyPlot">
// Copyright (c) 2020 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ExampleBrowser
{
public enum Renderer
{
Canvas,
Canvas_XAML,
SkiaSharp
}
}

View File

@@ -0,0 +1,22 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="XamlPlotView.cs" company="OxyPlot">
// Copyright (c) 2020 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ExampleBrowser
{
using OxyPlot;
using OxyPlot.Wpf;
/// <summary>
/// Represents a PlotView which uses the XamlRenderContext for rendering.
/// </summary>
public class XamlPlotView : PlotView
{
protected override IRenderContext CreateRenderContext()
{
return new XamlRenderContext(this.Canvas);
}
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="foo"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
</assembly>