Fix a bug in storage copy and update default note

This commit is contained in:
OmrSi 2021-03-07 18:21:16 +02:00
parent 659999095a
commit 2d23d3df61
4 changed files with 11 additions and 12 deletions

View File

@ -2617,7 +2617,7 @@ Continue?</RestoreDefaultSettingsMsg>
<NewCategory>New category</NewCategory> <NewCategory>New category</NewCategory>
<CategoryName>Category name</CategoryName> <CategoryName>Category name</CategoryName>
<CategorySetDefault>Set as default</CategorySetDefault> <CategorySetDefault>Set as default</CategorySetDefault>
<CategoryNote>Note: "Default" styles will be applied to new ASSA files</CategoryNote> <CategoryNote>Note: The styles in the default category (colored in green) will be applied to new ASSA files</CategoryNote>
<CategoryDelete>Are you sure you want to delete this category?</CategoryDelete> <CategoryDelete>Are you sure you want to delete this category?</CategoryDelete>
<CategoryRename>Rename category</CategoryRename> <CategoryRename>Rename category</CategoryRename>
<CategoriesManage>Manage</CategoriesManage> <CategoriesManage>Manage</CategoriesManage>

View File

@ -1366,7 +1366,7 @@
this.labelCategoryDefaultNote.Name = "labelCategoryDefaultNote"; this.labelCategoryDefaultNote.Name = "labelCategoryDefaultNote";
this.labelCategoryDefaultNote.Size = new System.Drawing.Size(265, 13); this.labelCategoryDefaultNote.Size = new System.Drawing.Size(265, 13);
this.labelCategoryDefaultNote.TabIndex = 5; this.labelCategoryDefaultNote.TabIndex = 5;
this.labelCategoryDefaultNote.Text = "Note: \"Default\" styles will be applied to new ASSA files"; this.labelCategoryDefaultNote.Text = "Note: The styles in the default category (colored in green) will be applied to new ASSA files";
// //
// buttonStorageManageCategories // buttonStorageManageCategories
// //

View File

@ -804,8 +804,8 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private void AddDefaultStyleToStorage() private void AddDefaultStyleToStorage()
{ {
var defaultStyle = new SsaStyle(); var defaultStyle = new SsaStyle();
AddStyle(listViewStorage, defaultStyle, Subtitle, _isSubStationAlpha);
_currentCategory.Styles.Add(defaultStyle); _currentCategory.Styles.Add(defaultStyle);
AddStyle(listViewStorage, defaultStyle, Subtitle, _isSubStationAlpha);
} }
private void UpdateSelectedIndices(ListView listview, int startingIndex = -1, int numberOfSelectedItems = 1) private void UpdateSelectedIndices(ListView listview, int startingIndex = -1, int numberOfSelectedItems = 1)
@ -1167,7 +1167,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
_doUpdate = true; _doUpdate = true;
} }
UpdateSelectedIndices(listViewStyles, selectionCount); UpdateSelectedIndices(listViewStyles, numberOfSelectedItems: selectionCount);
} }
} }
@ -1899,18 +1899,17 @@ namespace Nikse.SubtitleEdit.Forms.Styles
{ {
foreach (ListViewItem selectedItem in listViewStorage.SelectedItems) foreach (ListViewItem selectedItem in listViewStorage.SelectedItems)
{ {
var index = selectedItem.Index; var styleName = selectedItem.Text;
SsaStyle oldStyle = _currentCategory.Styles[index]; var oldStyle = _currentCategory.Styles[selectedItem.Index];
var style = new SsaStyle(oldStyle) { Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyOfY, oldStyle.Name) }; // Copy contructor var style = new SsaStyle(oldStyle) { Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyOfY, styleName) }; // Copy contructor
var styleName = style.Name; if (_currentCategory.Styles.Any(p => p.Name == style.Name))
if (_currentCategory.Styles.Any(p => p.Name == styleName))
{ {
int count = 2; int count = 2;
bool doRepeat = true; bool doRepeat = true;
while (doRepeat) while (doRepeat)
{ {
style.Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyXOfY, count, styleName); style.Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyXOfY, count, styleName);
doRepeat = _currentCategory.Styles.Any(p => p.Name == styleName); doRepeat = _currentCategory.Styles.Any(p => p.Name == style.Name);
count++; count++;
} }
} }
@ -1921,7 +1920,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
_doUpdate = true; _doUpdate = true;
} }
UpdateSelectedIndices(listViewStorage, selectionCount); UpdateSelectedIndices(listViewStorage, numberOfSelectedItems: selectionCount);
} }
} }

View File

@ -2956,7 +2956,7 @@ can edit in same subtitle file (collaboration)",
NewCategory = "New category", NewCategory = "New category",
CategoryName = "Category name", CategoryName = "Category name",
CategorySetDefault = "Set as default", CategorySetDefault = "Set as default",
CategoryNote = "Note: \"Default\" styles will be applied to new ASSA files", CategoryNote = "Note: The styles in the default category (colored in green) will be applied to new ASSA files",
CategoryDelete = "Are you sure you want to delete this category?", CategoryDelete = "Are you sure you want to delete this category?",
CategoryRename = "Rename category", CategoryRename = "Rename category",
CategoriesManage = "Manage", CategoriesManage = "Manage",