Add an option to move styles between categories

This commit is contained in:
OmrSi 2021-03-06 19:09:35 +02:00
parent 17e2d5e7ab
commit 93ae8115a9
6 changed files with 88 additions and 17 deletions

View File

@ -2624,6 +2624,7 @@ Continue?</RestoreDefaultSettingsMsg>
<ChooseCategories>Choose style to {0}</ChooseCategories>
<ImportCategoriesTitle>{0} categories from...</ImportCategoriesTitle>
<ExportCategoriesTitle>Export categories to...</ExportCategoriesTitle>
<MoveTOCategory>Move selected styles to category...</MoveTOCategory>
</SubStationAlphaStyles>
<PointSync>
<Title>Point synchronization</Title>

View File

@ -136,6 +136,8 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.addToFileStylesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemStorageMoveStylesToCategory = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemStorageMoveUp = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStorageMoveDown = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStorageMoveTop = new System.Windows.Forms.ToolStripMenuItem();
@ -1223,6 +1225,8 @@
this.toolStripSeparator2,
this.addToFileStylesToolStripMenuItem,
this.toolStripSeparator7,
this.toolStripMenuItemStorageMoveStylesToCategory,
this.toolStripSeparator9,
this.toolStripMenuItemStorageMoveUp,
this.toolStripMenuItemStorageMoveDown,
this.toolStripMenuItemStorageMoveTop,
@ -1270,6 +1274,17 @@
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(212, 6);
//
// toolStripMenuItemStorageMoveStylesToCategory
//
this.toolStripMenuItemStorageMoveStylesToCategory.Name = "toolStripMenuItemStorageMoveStylesToCategory";
this.toolStripMenuItemStorageMoveStylesToCategory.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemStorageMoveStylesToCategory.Text = "Move selected styles to category...";
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(212, 6);
//
// toolStripMenuItemStorageMoveUp
//
this.toolStripMenuItemStorageMoveUp.Name = "toolStripMenuItemStorageMoveUp";
@ -1603,6 +1618,8 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageRemove;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageRemoveAll;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageMoveStylesToCategory;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageMoveUp;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageMoveDown;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStorageMoveTop;

View File

@ -2413,31 +2413,79 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
}
private void contextMenuStripFile_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
var isNotEmpty = listViewStyles.Items.Count > 0;
toolStripMenuItemRemoveAll.Visible = isNotEmpty;
toolStripSeparator4.Visible = isNotEmpty;
toolStripMenuItemExport.Visible = isNotEmpty;
var oneOrMoreSelected = listViewStyles.SelectedItems.Count > 0;
deleteToolStripMenuItem.Visible = oneOrMoreSelected;
addToStorageToolStripMenuItem1.Visible = oneOrMoreSelected;
copyToolStripMenuItemCopy.Visible = oneOrMoreSelected;
var moreThanOneExists = listViewStyles.Items.Count > 1;
moveUpToolStripMenuItem.Visible = oneOrMoreSelected && moreThanOneExists;
moveBottomToolStripMenuItem.Visible = oneOrMoreSelected && moreThanOneExists;
moveTopToolStripMenuItem.Visible = oneOrMoreSelected && moreThanOneExists;
moveDownToolStripMenuItem.Visible = oneOrMoreSelected && moreThanOneExists;
toolStripSeparator3.Visible = oneOrMoreSelected && moreThanOneExists;
}
private void contextMenuStripStorage_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
var isNotEmpty = listViewStorage.Items.Count > 0;
toolStripMenuItemStorageRemove.Visible = isNotEmpty;
toolStripMenuItemStorageRemoveAll.Visible = isNotEmpty;
toolStripSeparator2.Visible = isNotEmpty;
toolStripMenuItemStorageCopy.Visible = isNotEmpty;
toolStripMenuItemStorageExport.Visible = isNotEmpty;
var moreThanOne = listViewStorage.Items.Count > 1;
toolStripMenuItemStorageMoveUp.Visible = moreThanOne;
toolStripMenuItemStorageMoveBottom.Visible = moreThanOne;
toolStripMenuItemStorageMoveTop.Visible = moreThanOne;
toolStripMenuItemStorageMoveDown.Visible = moreThanOne;
toolStripSeparator5.Visible = moreThanOne;
var oneOrMoreSelected = listViewStorage.SelectedItems.Count > 0;
toolStripMenuItemStorageRemove.Visible = oneOrMoreSelected;
addToFileStylesToolStripMenuItem.Visible = oneOrMoreSelected;
toolStripSeparator7.Visible = oneOrMoreSelected;
toolStripMenuItemStorageCopy.Visible = oneOrMoreSelected;
var moreThanOneExists = listViewStorage.Items.Count > 1;
toolStripMenuItemStorageMoveUp.Visible = oneOrMoreSelected && moreThanOneExists;
toolStripMenuItemStorageMoveDown.Visible = oneOrMoreSelected && moreThanOneExists;
toolStripMenuItemStorageMoveTop.Visible = oneOrMoreSelected && moreThanOneExists;
toolStripMenuItemStorageMoveBottom.Visible = oneOrMoreSelected && moreThanOneExists;
toolStripSeparator5.Visible = oneOrMoreSelected && moreThanOneExists;
var canMove = oneOrMoreSelected && _storageCategories.Count > 1 && (!_currentCategory.IsDefault || _currentCategory.IsDefault && listViewStorage.SelectedItems.Count < _currentCategory.Styles.Count);
toolStripMenuItemStorageMoveStylesToCategory.Visible = canMove;
toolStripSeparator9.Visible = canMove;
if (canMove)
{
toolStripMenuItemStorageMoveStylesToCategory.DropDownItems.Clear();
foreach (var assaStorageCategory in _storageCategories)
{
if (assaStorageCategory != _currentCategory)
{
var menuItem = new ToolStripMenuItem(assaStorageCategory.Name) { Tag = assaStorageCategory };
menuItem.Click += (s, args) => { MoveStylesToCategory(assaStorageCategory); };
toolStripMenuItemStorageMoveStylesToCategory.DropDownItems.Add(menuItem);
}
}
UiUtil.FixFonts(toolStripMenuItemStorageMoveStylesToCategory);
}
}
private void contextMenuStripFile_Opening(object sender, System.ComponentModel.CancelEventArgs e)
private void MoveStylesToCategory(AssaStorageCategory destinationCategory)
{
var moreThanOne = listViewStyles.Items.Count > 1;
moveUpToolStripMenuItem.Visible = moreThanOne;
moveBottomToolStripMenuItem.Visible = moreThanOne;
moveTopToolStripMenuItem.Visible = moreThanOne;
moveDownToolStripMenuItem.Visible = moreThanOne;
toolStripSeparator3.Visible = moreThanOne;
toolStripMenuItemRemoveAll.Visible = moreThanOne;
var lastItemIndex = listViewStorage.SelectedItems[listViewStorage.SelectedItems.Count - 1].Index;
listViewStorage.BeginUpdate();
foreach (ListViewItem item in listViewStorage.SelectedItems)
{
var style = _currentCategory.Styles[item.Index];
_currentCategory.Styles.Remove(style);
listViewStorage.Items.RemoveAt(item.Index);
destinationCategory.Styles.Add(style);
}
listViewStorage.EndUpdate();
UpdateSelectedIndices(listViewStorage, lastItemIndex);
}
private void buttonApply_Click(object sender, EventArgs e)

View File

@ -2962,7 +2962,8 @@ can edit in same subtitle file (collaboration)",
CategoriesManage = "Manage",
ChooseCategories = "Choose style to {0}",
ImportCategoriesTitle = "{0} categories from...",
ExportCategoriesTitle = "Export categories to..."
ExportCategoriesTitle = "Export categories to...",
MoveTOCategory = "Move selected styles to category..."
};
PointSync = new LanguageStructure.PointSync

View File

@ -7186,6 +7186,9 @@ namespace Nikse.SubtitleEdit.Logic
case "SubStationAlphaStyles/ExportCategoriesTitle":
language.SubStationAlphaStyles.ExportCategoriesTitle = reader.Value;
break;
case "SubStationAlphaStyles/MoveTOCategory":
language.SubStationAlphaStyles.MoveTOCategory = reader.Value;
break;
case "PointSync/Title":
language.PointSync.Title = reader.Value;
break;

View File

@ -2819,6 +2819,7 @@
public string ChooseCategories { get; set; }
public string ImportCategoriesTitle { get; set; }
public string ExportCategoriesTitle { get; set; }
public string MoveTOCategory { get; set; }
}
public class PointSync