Пример #1
0
        private void CheckTypeStyle(object sender, EventArgs e)
        {
            var menuItem = sender as ToolStripMenuItem;

            if (listViewFixes.Items.Count <= 0 || menuItem == null)
            {
                return;
            }
            if (menuItem.Text == "Check all")
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = true;
                }
            }
            else if (menuItem.Text == "Uncheck all")
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = false;
                }
            }
            else if (menuItem.Text == "Invert check")
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = !listViewFixes.Items[i].Checked;
                }
            }
            else if (menuItem.Text == "Copy")
            {
                var text = (listViewFixes.FocusedItem.Tag as Paragraph).ToString();
                Clipboard.SetText(text);
            }
            else
            {
                for (int idx = listViewFixes.SelectedIndices.Count - 1; idx >= 0; idx--)
                {
                    var index = listViewFixes.SelectedIndices[idx];
                    var p     = listViewFixes.Items[idx].Tag as Paragraph;
                    if (p != null)
                    {
                        _subtitle.RemoveLine(p.Number);
                    }
                    listViewFixes.Items.RemoveAt(index);
                }
                _subtitle.Renumber();
            }
        }
Пример #2
0
        private void CheckTypeStyle(object sender, EventArgs e)
        {
            if (listViewFixes.Items.Count <= 0 || !(sender is ToolStripMenuItem menuItem))
            {
                return;
            }

            switch (menuItem.Text)
            {
            case "Check all":
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = true;
                }

                break;
            }

            case "Uncheck all":
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = false;
                }

                break;
            }

            case "Invert check":
            {
                for (int i = 0; i < listViewFixes.Items.Count; i++)
                {
                    listViewFixes.Items[i].Checked = !listViewFixes.Items[i].Checked;
                }

                break;
            }

            case "Copy":
            {
                string text = ((Paragraph)listViewFixes.FocusedItem.Tag).ToString();
                Clipboard.SetText(text, TextDataFormat.UnicodeText);
                break;
            }

            default:
            {
                for (int idx = listViewFixes.SelectedIndices.Count - 1; idx >= 0; idx--)
                {
                    int index = listViewFixes.SelectedIndices[idx];
                    if (listViewFixes.Items[idx].Tag is Paragraph p)
                    {
                        _subtitle.RemoveLine(p.Number);
                    }
                    listViewFixes.Items.RemoveAt(index);
                }
                _subtitle.Renumber();
                break;
            }
            }
        }