From f0b6afefb5a8390123e03e847cba77e2e7b810fd Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Thu, 14 Mar 2019 19:56:01 +0100 Subject: [PATCH] Avoid "Id" in in profile export file --- libse/RulesProfile.cs | 16 +++++++++++++--- src/Forms/Settings.cs | 6 +++--- src/Forms/SettingsProfile.cs | 6 ++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/libse/RulesProfile.cs b/libse/RulesProfile.cs index 8abcdf4813..6570c46893 100644 --- a/libse/RulesProfile.cs +++ b/libse/RulesProfile.cs @@ -4,7 +4,6 @@ namespace Nikse.SubtitleEdit.Core { public class RulesProfile { - public Guid Id { get; set; } public string Name { get; set; } public decimal SubtitleLineMaximumLength { get; set; } public decimal SubtitleOptimalCharactersPerSeconds { get; set; } @@ -16,15 +15,26 @@ public class RulesProfile public bool CpsIncludesSpace { get; set; } public int MaxNumberOfLines { get; set; } public int MergeLinesShorterThan { get; set; } + private Guid _id; public RulesProfile() { - Id = Guid.NewGuid(); + ResetId(); + } + + public Guid GetId() + { + return _id; + } + + public void ResetId() + { + _id = Guid.NewGuid(); } public RulesProfile(RulesProfile profile) { - Id = profile.Id; + _id = profile.GetId(); Name = profile.Name; SubtitleLineMaximumLength = profile.SubtitleLineMaximumLength; SubtitleOptimalCharactersPerSeconds = profile.SubtitleOptimalCharactersPerSeconds; diff --git a/src/Forms/Settings.cs b/src/Forms/Settings.cs index 7391f8180f..3a7d5fc52e 100644 --- a/src/Forms/Settings.cs +++ b/src/Forms/Settings.cs @@ -893,10 +893,10 @@ private void UpdateProfileNames(List profiles) foreach (var profile in profiles) { comboBoxRulesProfileName.Items.Add(profile.Name); - if (_oldProfileId == Guid.Empty && profile.Name == Configuration.Settings.General.CurrentProfile || profile.Id == _oldProfileId) + if (_oldProfileId == Guid.Empty && profile.Name == Configuration.Settings.General.CurrentProfile || profile.GetId() == _oldProfileId) { comboBoxRulesProfileName.SelectedIndex = comboBoxRulesProfileName.Items.Count - 1; - _oldProfileId = profile.Id; + _oldProfileId = profile.GetId(); } } comboBoxRulesProfileName.EndUpdate(); @@ -3040,7 +3040,7 @@ private void comboBoxRulesProfileName_SelectedIndexChanged(object sender, EventA comboBoxMergeShortLineLength.SelectedIndex = 0; } checkBoxCpsIncludeWhiteSpace.Checked = profile.CpsIncludesSpace; - _oldProfileId = profile.Id; + _oldProfileId = profile.GetId(); _editProfileOn = false; } diff --git a/src/Forms/SettingsProfile.cs b/src/Forms/SettingsProfile.cs index 547345ae22..4d1f275ffd 100644 --- a/src/Forms/SettingsProfile.cs +++ b/src/Forms/SettingsProfile.cs @@ -133,7 +133,8 @@ private void buttonRemove_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e) { var gs = new GeneralSettings(); - var profile = new RulesProfile(gs.Profiles.First()) { Name = "New", Id = Guid.NewGuid() }; + var profile = new RulesProfile(gs.Profiles.First()) { Name = "New" }; + profile.ResetId(); RulesProfiles.Add(profile); ShowRulesProfiles(profile, false); textBoxName.Focus(); @@ -148,7 +149,8 @@ private void buttonCopy_Click(object sender, EventArgs e) } var source = RulesProfiles[idx]; - var profile = new RulesProfile(source) { Name = "Copy of " + source.Name, Id = Guid.NewGuid() }; + var profile = new RulesProfile(source) { Name = "Copy of " + source.Name }; + profile.ResetId(); RulesProfiles.Add(profile); ShowRulesProfiles(profile, false); }