该图包括显示温室中压力的变化,可以是每天,每周或每月。
但是显示日期的字段(例如今天)不会更新,有时会与当前日期相差一个月。
这是背后的代码。
public partial class SelecionarGrafico : Window
{
public int StepGrafico = 0;
public DateTime DataInicial;
public DateTime DataMinima;
public DateTime DataMaxima;
public SelecionarGrafico(DateTime dataMinima, DateTime dataMaxima)
{
InitializeComponent();
DataMinima = dataMinima;
DataInicial = dataMinima;
DataMaxima = dataMaxima;
DtDataInicial.Value = dataMinima;
DtDataInicial.Minimum = dataMinima;
DtDataInicial.Maximum = DataMaxima;
}
private void BtnAbrirGrafico_OnClick(object sender, RoutedEventArgs e)
{
var chk = -1;
if (BtnDiario.IsChecked == true) chk = 0;
else if (BtnSemanal.IsChecked == true) chk = 1;
else if (BtnMensal.IsChecked == true) chk = 2;
if (chk == -1)
{
MessageBox.Show("Você deve selecionar um tipo de gráfico!", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Stop);
return;
}
if (DtDataInicial.Value == DateTime.MinValue)
{
MessageBox.Show("Você deve especificar uma data inicial!", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Stop);
return;
}
if (chk == 0)
StepGrafico = 1440;
else if (chk == 1)
{
StepGrafico = 10080;
}
else if (chk == 2)
{
StepGrafico = 43200;
}
DataInicial = DtDataInicial.Value ?? DateTime.MinValue;
Close();
}
}
和xaml:
<Window.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF0087E4"/>
<GradientStop Color="#FF29A3DC" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Foreground="White" Margin="0,10" FontWeight="Bold" HorizontalAlignment="Center" Text="Que tipo de gráfico deseja visualizar?" Grid.ColumnSpan="2"/>
<Grid Grid.Row="1" HorizontalAlignment="Center">
<Grid.Resources>
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<RadioButton x:Name="BtnDiario" IsChecked="True" Grid.Column="0" Padding="5" Foreground="White" FontWeight="Bold" Content="Diário" BorderBrush="White">
<RadioButton.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF03649C" Offset="0"/>
<GradientStop Color="#FF00A9DA" Offset="1"/>
</LinearGradientBrush>
</RadioButton.Background>
</RadioButton>
<RadioButton x:Name="BtnSemanal" Margin="10,0" Grid.Column="1" Padding="5" Foreground="White" FontWeight="Bold" Content="Semanal" BorderBrush="White">
<RadioButton.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF03649C" Offset="0"/>
<GradientStop Color="#FF00A9DA" Offset="1"/>
</LinearGradientBrush>
</RadioButton.Background>
</RadioButton>
<RadioButton x:Name="BtnMensal" Grid.Column="2" Padding="5" Foreground="White" FontWeight="Bold" Content="Mensal" BorderBrush="White">
<RadioButton.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF03649C" Offset="0"/>
<GradientStop Color="#FF00A9DA" Offset="1"/>
</LinearGradientBrush>
</RadioButton.Background>
</RadioButton>
</Grid>
<TextBlock Grid.Row="2" Margin="0,10" HorizontalAlignment="Center" Foreground="White" FontWeight="Bold" Text="Selecione a data e o horário iniciais"/>
<xctk:DateTimePicker x:Name="DtDataInicial" Grid.Row="3" Margin="10,0" HorizontalAlignment="Stretch" AutoCloseCalendar="True"/>
<Button Click="BtnAbrirGrafico_OnClick" x:Name="BtnAbrirGrafico" Grid.Row="4" Margin="0,10" Padding="5" HorizontalAlignment="Center" Foreground="White" FontWeight="Bold" BorderBrush="White">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF03649C" Offset="0"/>
<GradientStop Color="#FF00B2DA" Offset="1"/>
</LinearGradientBrush>
</Button.Background> Abrir Gráfico
</Button>
</Grid>
日期字段中的返回值应为“ 05/04/2019,Friday,11:27”(今天和我写这篇文章的时间)
但在06/03/2019左右。