private void StartSousVide() { var profile = new BrewProfile(); profile.Steps.Add(new MashingStep { Temperature = Temperature, LengthMinutes = Minutes, } ); _logic = new BrewLogic(profile); _logic.Start(); Task.Run(async() => { int count = Minutes * 60; while (_logic.IsRunning) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { TimeRemaining = new TimeSpan(0, 0, count--); CurrentTemperature = TemperatureController.Instance.Controller.Temperature.ToString(); }); await Task.Delay(1000); } }); }
public void AddProfile(BrewProfile profile) { var profileBytes = ProfileWriter.Write(profile); if(profileBytes == null) { return; } if (!ProfileExists(profile)) { _conn.Insert(new BrewDatabaseTable { ProfileId = profile.Id.ToString(), Profile = profileBytes }); } else { UpdateProfile(profile); } //backup of file _profileFile?.CopyAsync(_profileFolder, DATABSE_NAME, NameCollisionOption.ReplaceExisting); }
public void UpdateProfile(BrewProfile profile) { BrewDatabaseTable entry = _entries.FirstOrDefault(t => t.ProfileId == profile.Id.ToString()); if (entry != null) { entry.Profile = ProfileWriter.Write(profile); _conn.Update(entry); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { _profile = (e.Parameter as BrewProfile); foreach (var step in _profile.Steps) { Items.Add(step); } base.OnNavigatedTo(e); }
private void UnSuccessfulBrewContinueClick(object sender, RoutedEventArgs e) { BrewProfile profile = BrewState.Instance.GetState(); if (profile != null) { //Use the delayedStart property to force //an automatic start of the brew process profile.DelayedStart = true; this.Frame.Navigate(typeof(Brew), profile); } BrewState.Instance.Dispose(); }
private void AddProfile_Click(object sender, RoutedEventArgs e) { IStep step = new BoilStep { LengthMinutes = BoilMinutes, Temperature = BrewProfileSettings.Instance.MinimumBoilingTemperature, }; Items.Add(step); var profile = new BrewProfile(ProfileName, BoilMinutes, Items.ToList()); this.Frame.Navigate(typeof(AddIngredients), profile); }
public static BrewProfile Read(byte[] p) { var profile = new BrewProfile(); try { using (var ms = new MemoryStream(p)) { using (var reader = new BinaryReader(ms)) { var json = reader.ReadString(); return(JsonConvert.DeserializeObject <BrewProfile>(json, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects })); } } } catch (Exception e) { return(null); } }
public static byte[] Write(BrewProfile profile) { try { using (var ms = new MemoryStream()) { using (var writer = new BinaryWriter(ms)) { string json = JsonConvert.SerializeObject(profile, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects, TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple }); writer.Write(json); } return(ms.ToArray()); } } catch (Exception ex) { return(null); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { _profile = e.Parameter as BrewProfile; }
private byte[] SerialieToJson(BrewProfile profile) { string json = JsonConvert.SerializeObject(profile); return Encoding.UTF8.GetBytes(json); }
public bool ProfileExists(BrewProfile profile) { BrewDatabaseTable entry = _entries.FirstOrDefault(t => t.ProfileId == profile.Id.ToString()); return entry != null; }
public void DeleteProfile(BrewProfile profile) { BrewDatabaseTable entry = _entries.FirstOrDefault(t => t.ProfileId == profile.Id.ToString()); if(entry != null) _conn.Delete(entry); }
private void DebugTest() { var prof = BrewProfile.GetTestProfile(); Profiles.Add(prof); }