public void LoadTimeline(TimelineViewModel timelineViewModel = null) { // If no viewmodel is given, create a new viewmodel if (timelineViewModel == null) { timelineViewModel = new TimelineViewModel(); timelineViewModel.SetViewModel(new TimelineModel() { Title = "New Timeline", ThemeID = 3 }); } if (this.model != null) { this.model = null; } this.model = timelineViewModel; // Set the XAML DataContext this.DataContext = model; // Create the Window this.CreateRenderWindow(); // Set the Zoom this.ResetZoom(); }
public void OpenFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { string json = File.ReadAllText(openFileDialog.FileName); TimelineViewModel timelineViewModel = new TimelineViewModel(); timelineViewModel.SetViewModel(JsonConvert.DeserializeObject <TimelineModel>(json)); this.LoadTimeline(timelineViewModel); } }