void Initialize() { CommitInfo1 = new CommitInfo(); CommitInfo2 = new CommitInfo(); CommitInfo3 = new CommitInfo(); if (!File.Exists(filePath)) CreateDefaultFile(); Update(); }
void Update(CommitInfo commitInfo) { if (commitInfo == null) return; if(!Dispatcher.CheckAccess()) { Dispatcher.Invoke(() => Update(commitInfo)); return; } if (!string.IsNullOrEmpty(commitInfo.Branch)) BranchText.Text = commitInfo.Branch; if (!string.IsNullOrEmpty(commitInfo.Message)) CommitText.Text = commitInfo.Message; if (commitInfo.UserImage != null) UserImage.Source = commitInfo.UserImage.ToImageSource(); }
private void ReadFromFile() { var jsonString = File.ReadAllText(filePath); var jObject = JObject.Parse(jsonString); var imageConverter = new ImageConverter(); var jCommits = jObject["Commits"].Values<string>().ToList(); CommitInfo1 = JsonConvert.DeserializeObject<CommitInfo>(jCommits[0], imageConverter); CommitInfo2 = JsonConvert.DeserializeObject<CommitInfo>(jCommits[1], imageConverter); CommitInfo3 = JsonConvert.DeserializeObject<CommitInfo>(jCommits[2], imageConverter); if (CommitInfo1.UserImage == null) CommitInfo1.UserImage = Resources.DefaultUserImage; if (CommitInfo2.UserImage == null) CommitInfo2.UserImage = Resources.DefaultUserImage; if (CommitInfo3.UserImage == null) CommitInfo3.UserImage = Resources.DefaultUserImage; }