Код: Выделить всё
OnPropertyChanged()
В другом вопрос в стеке Я видел, что кто-то предложил использовать ItemSource, но я не уверен, как я могу использовать его в коде, и также кажется, что простое аннулирование графика должно сработать.
Сам проект состоит из нескольких файлов, но я думаю, что для решения проблемы важны два:
MainWindow.xaml:
Код: Выделить всё
Leg preassures
Left leg pressure
Right leg pressure
Pillow pressures
Left pillow pressure
Right pillow pressure
Front pillow pressure
Back pillow pressure
Game event types
None game events
Dodge game events
Crash game events
Other game events
Код: Выделить всё
using NeoracerLogsExplorer.Charts;
using NeoracerLogsExplorer.GameEvents;
using OxyPlot;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Diagnostics;
namespace NeoracerLogsExplorer
{
public partial class MainWindow : Window, INotifyPropertyChanged
{
private const char DIRECTORY_NAME_SEPARATOR = '\\';
private const char FILE_EXTENTION_SEPARATOR = '.';
private const string GAME_EVENTS_LOG_DIRECTORY = "GameEventsLogs";
private const string GAME_EVENTS_LOG_FILE_NAME = "neoracer_game_events";
private const string GAME_EVENTS_LOG_FILE_EXTENTION = "log";
public event PropertyChangedEventHandler PropertyChanged;
private GameEventsManager gameEventsManager;
private ChartManager chartManager;
private Chart mainChart;
public MainWindow()
{
//InitializeComponent();
gameEventsManager = new GameEventsManager();
string gameEventsLogFilePath = GetGameEventsLogFilePath();
gameEventsManager.RetrieveGameEventsFromFile(gameEventsLogFilePath);
Debug.WriteLine("TEST!");
Debug.WriteLine(gameEventsLogFilePath);
List gameEvents = gameEventsManager.GameEvents;
chartManager = new ChartManager(gameEvents);
mainChart = chartManager.CreateAllSensorsChart();
this.DataContext = this;
}
//[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
public Chart MainChart
{
get { return mainChart; }
set { mainChart = value; }
}
private void LeftLegCheckBox_CheckedChanged(object sender, RoutedEventArgs args)
{
if (LeftLegCheckBox.IsChecked == true)
{
mainChart.LeftLegPressureLineSeriesVisibility(true);
}
else
{
mainChart.LeftLegPressureLineSeriesVisibility(false);
}
//MainChart = mainChart;
MainChart.InvalidatePlot(false);
OnPropertyChanged(nameof(MainChart));
}
public string GetGameEventsLogFilePath()
{
string currentGameEventsLogDirectoryPath =
Environment.CurrentDirectory
+ DIRECTORY_NAME_SEPARATOR
+ GAME_EVENTS_LOG_DIRECTORY
+ DIRECTORY_NAME_SEPARATOR;
string currentGameEventsLogFileName =
GAME_EVENTS_LOG_FILE_NAME
+ FILE_EXTENTION_SEPARATOR
+ GAME_EVENTS_LOG_FILE_EXTENTION;
string gameEventsLogFilePath =
currentGameEventsLogDirectoryPath
+ currentGameEventsLogFileName;
return gameEventsLogFilePath;
}
}
}
Код: Выделить всё
Chart
LeftLegPressureLineSeriesVisibility выглядит следующим образом:
Код: Выделить всё
public void LeftLegPressureLineSeriesVisibility(bool isVisible)
{
leftLegPressureLineSeries.IsVisible = isVisible;
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... g-the-plot