项目结构调整

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,69 @@
<Page x:Class="UWP.CartesianChart.Energy_Predictions.EnergyPredictionExample"
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:lvc="using:LiveCharts.Uwp"
xmlns:interop="using:Windows.UI.Xaml.Interop"
xmlns:energyPredictions="using:UWP.CartesianChart.Energy_Predictions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600"
Background="#ECECEC" d:DataContext="{d:DesignInstance energyPredictions:EnergyPredictionExample}">
<Grid Margin="15">
<Grid.Resources>
<energyPredictions:OpacityConverter x:Key="OpacityConverter"></energyPredictions:OpacityConverter>
<energyPredictions:ReverseConverter x:Key="ReverseConverter"></energyPredictions:ReverseConverter>
<Style TargetType="lvc:StackedAreaSeries">
<Setter Property="PointGeometrySize" Value="0"></Setter>
</Style>
</Grid.Resources>
<Border CornerRadius="5" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontSize="40" Foreground="#404040" Margin="20, 10">Energy Consumption</TextBlock>
<Canvas Grid.Row="1" Name="Canvas" Margin="-4, 0, 0, 20">
<ListBox Name="ListBox" ItemsSource="{Binding Series, Converter={StaticResource ReverseConverter}}"
Canvas.ZIndex="1" Canvas.Left="60" Canvas.Top="20" BorderThickness="0" Background="Transparent">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding (lvc:LineSeries.Title)}"
Foreground="{Binding (lvc:LineSeries.Fill)}"
Opacity="{Binding (lvc:LineSeries.Visibility), Converter={StaticResource OpacityConverter}}"
FontSize="22"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter Tapped="UIElement_OnTapped" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<lvc:CartesianChart Height="{Binding ElementName=Canvas, Path=ActualHeight}" Width="{Binding ElementName=Canvas, Path=ActualWidth}"
Series="{Binding Series}" Hoverable="False" DataTooltip="{x:Null}">
<lvc:CartesianChart.AxisX>
<lvc:Axis IsEnabled="False" ShowLabels="False"></lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis IsMerged="True" FontSize="14"></lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Canvas>
</Grid>
</Border>
</Grid>
</Page>

View File

@@ -0,0 +1,56 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using LiveCharts;
using LiveCharts.Uwp;
namespace UWP.CartesianChart.Energy_Predictions
{
/// <summary>
/// Interaction logic for EnergyPredictionExample.xaml
/// </summary>
public partial class EnergyPredictionExample
{
public EnergyPredictionExample()
{
InitializeComponent();
Series = new SeriesCollection
{
new StackedAreaSeries
{
Values = new ChartValues<double> {20, 30, 35, 45, 65, 85},
Title = "Electricity"
},
new StackedAreaSeries
{
Values = new ChartValues<double> {10, 12, 18, 20, 38, 40},
Title = "Water"
},
new StackedAreaSeries
{
Values = new ChartValues<double> {5, 8, 12, 15, 22, 25},
Title = "Solar"
},
new StackedAreaSeries
{
Values = new ChartValues<double> {10, 12, 18, 20, 38, 40},
Title = "Gas"
}
};
DataContext = this;
}
public SeriesCollection Series { get; set; }
private void UIElement_OnTapped(object sender, TappedRoutedEventArgs e)
{
var series = (StackedAreaSeries) ((ContentPresenter) sender).Content;
if (series != null)
series.Visibility = series.Visibility == Visibility.Visible
? Visibility.Collapsed
: Visibility.Visible;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace UWP.CartesianChart.Energy_Predictions
{
public class OpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (Visibility)value == Visibility.Visible
? 1d
: .2d;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Linq;
using Windows.UI.Xaml.Data;
using LiveCharts;
namespace UWP.CartesianChart.Energy_Predictions
{
public class ReverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return ((SeriesCollection)value).Reverse();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}