Skip to content

Commit

Permalink
Avoid "Id" in in profile export file
Browse files Browse the repository at this point in the history
  • Loading branch information
niksedk committed Mar 14, 2019
1 parent e301e1b commit f0b6afe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
16 changes: 13 additions & 3 deletions libse/RulesProfile.cs
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Forms/Settings.cs
Expand Up @@ -893,10 +893,10 @@ private void UpdateProfileNames(List<RulesProfile> 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();
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 4 additions & 2 deletions src/Forms/SettingsProfile.cs
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down

3 comments on commit f0b6afe

@marb99
Copy link
Contributor

@marb99 marb99 commented on f0b6afe Mar 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niksedk

crash when try export the profile

Capturar

@marb99
Copy link
Contributor

@marb99 marb99 commented on f0b6afe Mar 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I translated the error message above:

"Nikse.SubtitleEdit.Core.RulesProfile is not accessible due to the respective level of protection. Only public types can be processed"

@niksedk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.