private void SaveConfiguration(string profile, TeamNotifierModel model, ObservableCollectionEx <CommandViewModel> commands) { lock (m_ConfigurationLock) { var sb = new StringBuilder(); string modeldata = TeamNotifierLogic.Serialize(model); sb.Append(modeldata); foreach (var cmd in commands) { sb.Append("~~~"); sb.Append(TeamNotifierLogic.Serialize(cmd.Model)); } TeamNotifierLogic.AddOrUpdateAppSettings(profile, sb.ToString()); var sb2 = new StringBuilder(); foreach (var prof in Profiles) { sb2.Append(TeamNotifierLogic.Serialize(prof)); sb2.Append("~~~"); } if (sb2.ToString(sb2.Length - 3, 3) == "~~~") { sb2.Remove(sb2.Length - 3, 3); } TeamNotifierLogic.AddOrUpdateAppSettings("Profiles", sb2.ToString()); var selectedprofile = TeamNotifierLogic.Serialize(SelectedProfile); TeamNotifierLogic.AddOrUpdateAppSettings("SelectedProfile", selectedprofile); } }
public void AddNewProfileHandler() { var profilename = Microsoft.VisualBasic.Interaction.InputBox("Profile Name", "Add a new profile"); if (string.IsNullOrEmpty(profilename) || Profiles.Any(x => x.Name == profilename)) { return; } var newprofile = new Profile { Name = profilename }; Profiles.Add(newprofile); var model = new TeamNotifierModel { AutoDelete = Model.AutoDelete, MaxMessages = Model.MaxMessages, User = Model.User, SoundNotificationType = Model.SoundNotificationType, Room = "" }; var commands = new ObservableCollectionEx <CommandViewModel>(); lock (m_ConfigurationLock) SaveConfiguration(newprofile.Name, model, commands); SelectedProfile = newprofile; }