From ebc47626ef8a83d99286b7bfc6b74929dfa03238 Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 22 Dec 2021 14:40:51 +0100 Subject: [PATCH] Update file association code a little --- src/ui/Forms/Options/Settings.Designer.cs | 16 ++++++++++------ src/ui/Forms/Options/Settings.cs | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/ui/Forms/Options/Settings.Designer.cs b/src/ui/Forms/Options/Settings.Designer.cs index 5a29a0685..6e4d1a06d 100644 --- a/src/ui/Forms/Options/Settings.Designer.cs +++ b/src/ui/Forms/Options/Settings.Designer.cs @@ -420,6 +420,7 @@ this.buttonUpdateFileTypeAssociations = new System.Windows.Forms.Button(); this.listViewFileTypeAssociations = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.imageListFileTypeAssociations = new System.Windows.Forms.ImageList(this.components); this.panelGeneral.SuspendLayout(); this.groupBoxMiscellaneous.SuspendLayout(); @@ -5030,16 +5031,16 @@ // labelUpdateFileTypeAssociationsStatus // this.labelUpdateFileTypeAssociationsStatus.AutoSize = true; - this.labelUpdateFileTypeAssociationsStatus.Location = new System.Drawing.Point(16, 294); + this.labelUpdateFileTypeAssociationsStatus.Location = new System.Drawing.Point(433, 503); this.labelUpdateFileTypeAssociationsStatus.Name = "labelUpdateFileTypeAssociationsStatus"; - this.labelUpdateFileTypeAssociationsStatus.Size = new System.Drawing.Size(35, 13); + this.labelUpdateFileTypeAssociationsStatus.Size = new System.Drawing.Size(38, 13); this.labelUpdateFileTypeAssociationsStatus.TabIndex = 24; - this.labelUpdateFileTypeAssociationsStatus.Text = "label2"; + this.labelUpdateFileTypeAssociationsStatus.Text = "Status"; // // buttonUpdateFileTypeAssociations // this.buttonUpdateFileTypeAssociations.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUpdateFileTypeAssociations.Location = new System.Drawing.Point(16, 260); + this.buttonUpdateFileTypeAssociations.Location = new System.Drawing.Point(209, 497); this.buttonUpdateFileTypeAssociations.Name = "buttonUpdateFileTypeAssociations"; this.buttonUpdateFileTypeAssociations.Size = new System.Drawing.Size(218, 23); this.buttonUpdateFileTypeAssociations.TabIndex = 23; @@ -5051,13 +5052,15 @@ // this.listViewFileTypeAssociations.CheckBoxes = true; this.listViewFileTypeAssociations.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1}); + this.columnHeader1, + this.columnHeader2}); this.listViewFileTypeAssociations.HideSelection = false; this.listViewFileTypeAssociations.Location = new System.Drawing.Point(0, 4); this.listViewFileTypeAssociations.Name = "listViewFileTypeAssociations"; - this.listViewFileTypeAssociations.Size = new System.Drawing.Size(849, 241); + this.listViewFileTypeAssociations.Size = new System.Drawing.Size(199, 516); this.listViewFileTypeAssociations.TabIndex = 22; this.listViewFileTypeAssociations.UseCompatibleStateImageBehavior = false; + this.listViewFileTypeAssociations.View = System.Windows.Forms.View.Details; // // imageListFileTypeAssociations // @@ -5605,5 +5608,6 @@ private System.Windows.Forms.ImageList imageListFileTypeAssociations; private System.Windows.Forms.Button buttonUpdateFileTypeAssociations; private System.Windows.Forms.Label labelUpdateFileTypeAssociationsStatus; + private System.Windows.Forms.ColumnHeader columnHeader2; } } \ No newline at end of file diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index f38bc5ca9..72e8290b8 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -114,11 +114,10 @@ namespace Nikse.SubtitleEdit.Forms.Options public Settings() { UiUtil.PreInitialize(this); - InitializeComponent(); + InitializeComponent(); UiUtil.FixFonts(this); UiUtil.FixLargeFonts(this, buttonOK); Init(); - FillFileTypeAssociationsListView(); } public void Init() @@ -2679,6 +2678,11 @@ namespace Nikse.SubtitleEdit.Forms.Options break; case FileTypeAssociationSection: section = panelFileTypeAssociations; + if (listViewFileTypeAssociations.Items.Count == 0) + { + FillFileTypeAssociationsListView(); + } + break; } @@ -3976,19 +3980,25 @@ namespace Nikse.SubtitleEdit.Forms.Options } var iconFileNames = Directory.GetFiles(iconDir, "*.ico"); - listViewFileTypeAssociations.LargeImageList = imageListFileTypeAssociations; + imageListFileTypeAssociations.Images.Clear(); + listViewFileTypeAssociations.HeaderStyle = ColumnHeaderStyle.None; + //listViewFileTypeAssociations.LargeImageList = imageListFileTypeAssociations; + listViewFileTypeAssociations.SmallImageList = imageListFileTypeAssociations; + listViewFileTypeAssociations.BeginUpdate(); + listViewFileTypeAssociations.Items.Clear(); foreach (var iconFileName in iconFileNames) { var friendlyName = "." + Path.GetFileNameWithoutExtension(iconFileName).ToUpperInvariant(); var icon = new Icon(iconFileName); imageListFileTypeAssociations.Images.Add(icon); - var item = new ListViewItem(friendlyName); + var item = new ListViewItem(string.Empty); + item.SubItems.Add(friendlyName); item.ImageIndex = imageListFileTypeAssociations.Images.Count - 1; item.Checked = FileTypeAssociations.GetChecked("." + Path.GetFileNameWithoutExtension(iconFileName).ToLowerInvariant(), "Subtitle Edit"); item.Tag = iconFileName; listViewFileTypeAssociations.Items.Add(item); } - listViewFileTypeAssociations.Refresh(); + listViewFileTypeAssociations.EndUpdate(); } private void buttonUpdateFileTypeAssociations_Click(object sender, EventArgs e)