private static void Update(string profile, bool delete) { var profiles = AvailableProfiles.ToList(); profiles.RemoveAll( _profile => string.Equals(_profile, profile, StringComparison.OrdinalIgnoreCase) ); if (!delete) { profiles.Insert(0, profile); } try { using (var stream = File.Create(ConfigurationFileName)) { using (var writer = new StreamWriter(stream)) { foreach (var _profile in profiles) { writer.WriteLine(_profile); } } } } catch (Exception e) { Logger.Write(typeof(Profiles), LogLevel.Warn, "Failed to write available profiles: {0}", e.Message); } _AvailableProfiles.Reset(); }
private static void OnFileDeleted(object sender, FileSystemEventArgs e) { string profileName = Path.GetFileNameWithoutExtension(e.FullPath); AvailableProfiles.Remove(profileName); ReloadActiveConfiguration(); }
private static void OnFileChanged(object sender, FileSystemEventArgs e) { string profileName = Path.GetFileNameWithoutExtension(e.FullPath); Profile profile = null; if (AvailableProfiles.TryGetValue(profileName, out profile)) { profile.Reload(); } ReloadActiveConfiguration(); }
private static void OnFileRenamed(object sender, RenamedEventArgs e) { string oldProfileName = Path.GetFileNameWithoutExtension(e.FullPath); AvailableProfiles.Remove(oldProfileName); string profileName = Path.GetFileNameWithoutExtension(e.FullPath); if (!AvailableProfiles.ContainsKey(profileName)) { AvailableProfiles[profileName] = new Profile(e.FullPath); } ReloadActiveConfiguration(); }
private static void OnFileCreated(object sender, FileSystemEventArgs e) { string extension = Path.GetExtension(e.FullPath); if (!extension.Equals(Profile.Extension)) { return; } string profileName = Path.GetFileNameWithoutExtension(e.FullPath); if (!AvailableProfiles.ContainsKey(profileName)) { AvailableProfiles[profileName] = new Profile(e.FullPath); } ReloadActiveConfiguration(); }
private void PopulateProfilesModelCollection() { //clear list (bindable collection) AvailableProfiles.Clear(); //for every read raw profile definition foreach (var item in _originalProfilesList) { AlarmProfileExportModel model = new AlarmProfileExportModel() { ToExport = false, Identity = item.Identity, CreatedBy = item.CreatedBy, ModifiedBy = item.ModifiedBy, ProfileName = item.ProfileName, ProfileComment = item.ProfileComment, }; AvailableProfiles.Add(model); } }
private bool CheckIfAtLeastOneProfileIsSelected() { return(AvailableProfiles.Where(x => x.ToExport == true).Count() > 0); }