项目结构调整

This commit is contained in:
艾竹
2023-04-16 20:11:40 +08:00
parent cbfbf96033
commit 81f91f3f35
2124 changed files with 218 additions and 5516 deletions

View File

@@ -0,0 +1,52 @@
<UserControl x:Class="Wpf.CartesianChart.WindowAxis.WindowAxisExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:Wpf.CartesianChart.WindowAxis"
xmlns:wpf="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Background="#FFC107" HorizontalAlignment="Right" Padding="10 5" FontWeight="Bold">Experimental</TextBlock>
<StackPanel Grid.Row="1">
</StackPanel>
<wpf:CartesianChart Zoom="X" Grid.Row="4" DisableAnimations="False" Series="{Binding SeriesCollection}">
<wpf:CartesianChart.AxisX>
<wpf:WindowAxis
MinValue="1970"
MaxValue="1990"
LabelsRotation="45"
Foreground="DarkSlateBlue"
HeaderForeground="OrangeRed"
ShowLabels="True">
<wpf:WindowAxis.Windows>
<local:PresidentWindow/>
<local:OtherWindow/>
</wpf:WindowAxis.Windows>
<wpf:WindowAxis.Separator>
<wpf:Separator StrokeThickness="10" Stroke="Black"/>
</wpf:WindowAxis.Separator>
</wpf:WindowAxis>
</wpf:CartesianChart.AxisX>
<wpf:CartesianChart.AxisY>
<wpf:Axis MinValue="0" MaxValue="300000000"></wpf:Axis>
</wpf:CartesianChart.AxisY>
</wpf:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Definitions.Charts;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.WindowAxis
{
public class OtherWindow : AxisWindow
{
public override double MinimumSeparatorWidth
{
get { return 10; }
}
public override bool IsHeader(double x)
{
return x % 100 == 0;
}
public override bool IsSeparator(double x)
{
return x % 10 == 0;
}
public override string FormatAxisLabel(double x)
{
return x.ToString(CultureInfo.InvariantCulture);
}
}
public class PresidentWindow : AxisWindow
{
private Dictionary<double, string> _presidents = new Dictionary<double, string>();
public PresidentWindow()
{
_presidents.Add(1789, "George Washington");
_presidents.Add(1797, "John Adams");
_presidents.Add(1801, "Thomas Jefferson");
_presidents.Add(1809, "James Madison");
_presidents.Add(1817, "James Monroe");
_presidents.Add(1825, "John Quincy Adams");
_presidents.Add(1829, "Andrew Jackson");
_presidents.Add(1837, "Martin van Buren");
_presidents.Add(1841, "John Tyler"); // William Henry Harrison died in the first month
_presidents.Add(1845, "James K. Polk");
_presidents.Add(1849, "Zachary Taylor");
_presidents.Add(1850, "Millard Fillmore");
_presidents.Add(1853, "Franklin Pierce");
_presidents.Add(1857, "James Buchanan");
_presidents.Add(1861, "Abraham Lincoln");
_presidents.Add(1865, "Andrew Johnson");
_presidents.Add(1869, "Ulysses S. Grant");
_presidents.Add(1877, "Rutherford B. hayes");
_presidents.Add(1881, "Chester A. Arthur"); // James A. Garfield was assassinated in this first year of office
_presidents.Add(1885, "Grover Cleveland");
_presidents.Add(1889, "Benjamin Harrison");
_presidents.Add(1893, "Grover Cleveland");
_presidents.Add(1897, "William McKinley");
_presidents.Add(1901, "Theodore Roosevelt");
_presidents.Add(1909, "William Howard Taft");
_presidents.Add(1913, "Woodrow Wilson");
_presidents.Add(1921, "Warren G. Harding");
_presidents.Add(1923, "Calvin Coolidge");
_presidents.Add(1929, "Herbert Hoover");
_presidents.Add(1933, "Franklin D. Roosevelt");
_presidents.Add(1945, "Harry S. Truman");
_presidents.Add(1953, "Dwight D. Eisenhower");
_presidents.Add(1961, "John F. Kennedy");
_presidents.Add(1963, "Lyndon B. Johnson");
_presidents.Add(1969, "Richard nixon");
_presidents.Add(1974, "Gerald Ford");
_presidents.Add(1977, "Jimmy Carter");
_presidents.Add(1981, "Ronald Reagan");
_presidents.Add(1989, "George H. W. Bush");
_presidents.Add(1993, "Bill Clinton");
_presidents.Add(2001, "George W. Bush");
_presidents.Add(2009, "Barack Obama");
}
public override double MinimumSeparatorWidth
{
get { return 30; }
}
public override bool IsHeader(double x)
{
return Math.Floor(x) % 10 == 0;
}
public override bool IsSeparator(double x)
{
// Return if this is a president, or if this is a period of 10 years
return _presidents.ContainsKey(x) || Math.Floor(x) % 10 == 0;
}
public override string FormatAxisLabel(double x)
{
string president;
return _presidents.TryGetValue(x, out president)
? string.Format("{0}-{1}", x.ToString(CultureInfo.InvariantCulture), president)
: x.ToString(CultureInfo.InvariantCulture);
}
}
/// <summary>
/// Interaction logic for WindowAxisExample.xaml
/// </summary>
public partial class WindowAxisExample : UserControl, INotifyPropertyChanged
{
public SeriesCollection SeriesCollection { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public WindowAxisExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new LineSeries
{
Title = "Population",
Values = new ChartValues<ObservablePoint>
{
new ObservablePoint(1790, 3513183),
new ObservablePoint(1800, 5010172),
new ObservablePoint(1810, 6710919),
new ObservablePoint(1820, 9090219),
new ObservablePoint(1830, 12556760),
new ObservablePoint(1840, 16676537),
new ObservablePoint(1850, 22652981),
new ObservablePoint(1860, 30664152),
new ObservablePoint(1870, 38115641),
new ObservablePoint(1880, 49371340),
new ObservablePoint(1890, 74607225),
new ObservablePoint(1900, 74607225),
new ObservablePoint(1910, 91109542),
new ObservablePoint(1920, 105273049),
new ObservablePoint(1930, 122288177),
new ObservablePoint(1940, 131006184),
new ObservablePoint(1950, 149895183),
new ObservablePoint(1960, 178559219),
new ObservablePoint(1970, 202545363),
new ObservablePoint(1980, 225903767),
new ObservablePoint(1990, 248102973),
new ObservablePoint(2000, 280849847),
},
PointGeometry = null
},
};
DataContext = this;
}
protected virtual void OnPropertyChanged(string propertyName = null)
{
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}