Update file association code a little

This commit is contained in:
niksedk 2021-12-22 14:40:51 +01:00
parent db9cda1082
commit ebc47626ef
2 changed files with 25 additions and 11 deletions

View File

@ -420,6 +420,7 @@
this.buttonUpdateFileTypeAssociations = new System.Windows.Forms.Button(); this.buttonUpdateFileTypeAssociations = new System.Windows.Forms.Button();
this.listViewFileTypeAssociations = new System.Windows.Forms.ListView(); this.listViewFileTypeAssociations = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 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.imageListFileTypeAssociations = new System.Windows.Forms.ImageList(this.components);
this.panelGeneral.SuspendLayout(); this.panelGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout(); this.groupBoxMiscellaneous.SuspendLayout();
@ -5030,16 +5031,16 @@
// labelUpdateFileTypeAssociationsStatus // labelUpdateFileTypeAssociationsStatus
// //
this.labelUpdateFileTypeAssociationsStatus.AutoSize = true; 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.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.TabIndex = 24;
this.labelUpdateFileTypeAssociationsStatus.Text = "label2"; this.labelUpdateFileTypeAssociationsStatus.Text = "Status";
// //
// buttonUpdateFileTypeAssociations // buttonUpdateFileTypeAssociations
// //
this.buttonUpdateFileTypeAssociations.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.Name = "buttonUpdateFileTypeAssociations";
this.buttonUpdateFileTypeAssociations.Size = new System.Drawing.Size(218, 23); this.buttonUpdateFileTypeAssociations.Size = new System.Drawing.Size(218, 23);
this.buttonUpdateFileTypeAssociations.TabIndex = 23; this.buttonUpdateFileTypeAssociations.TabIndex = 23;
@ -5051,13 +5052,15 @@
// //
this.listViewFileTypeAssociations.CheckBoxes = true; this.listViewFileTypeAssociations.CheckBoxes = true;
this.listViewFileTypeAssociations.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listViewFileTypeAssociations.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1}); this.columnHeader1,
this.columnHeader2});
this.listViewFileTypeAssociations.HideSelection = false; this.listViewFileTypeAssociations.HideSelection = false;
this.listViewFileTypeAssociations.Location = new System.Drawing.Point(0, 4); this.listViewFileTypeAssociations.Location = new System.Drawing.Point(0, 4);
this.listViewFileTypeAssociations.Name = "listViewFileTypeAssociations"; 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.TabIndex = 22;
this.listViewFileTypeAssociations.UseCompatibleStateImageBehavior = false; this.listViewFileTypeAssociations.UseCompatibleStateImageBehavior = false;
this.listViewFileTypeAssociations.View = System.Windows.Forms.View.Details;
// //
// imageListFileTypeAssociations // imageListFileTypeAssociations
// //
@ -5605,5 +5608,6 @@
private System.Windows.Forms.ImageList imageListFileTypeAssociations; private System.Windows.Forms.ImageList imageListFileTypeAssociations;
private System.Windows.Forms.Button buttonUpdateFileTypeAssociations; private System.Windows.Forms.Button buttonUpdateFileTypeAssociations;
private System.Windows.Forms.Label labelUpdateFileTypeAssociationsStatus; private System.Windows.Forms.Label labelUpdateFileTypeAssociationsStatus;
private System.Windows.Forms.ColumnHeader columnHeader2;
} }
} }

View File

@ -118,7 +118,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
UiUtil.FixFonts(this); UiUtil.FixFonts(this);
UiUtil.FixLargeFonts(this, buttonOK); UiUtil.FixLargeFonts(this, buttonOK);
Init(); Init();
FillFileTypeAssociationsListView();
} }
public void Init() public void Init()
@ -2679,6 +2678,11 @@ namespace Nikse.SubtitleEdit.Forms.Options
break; break;
case FileTypeAssociationSection: case FileTypeAssociationSection:
section = panelFileTypeAssociations; section = panelFileTypeAssociations;
if (listViewFileTypeAssociations.Items.Count == 0)
{
FillFileTypeAssociationsListView();
}
break; break;
} }
@ -3976,19 +3980,25 @@ namespace Nikse.SubtitleEdit.Forms.Options
} }
var iconFileNames = Directory.GetFiles(iconDir, "*.ico"); 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) foreach (var iconFileName in iconFileNames)
{ {
var friendlyName = "." + Path.GetFileNameWithoutExtension(iconFileName).ToUpperInvariant(); var friendlyName = "." + Path.GetFileNameWithoutExtension(iconFileName).ToUpperInvariant();
var icon = new Icon(iconFileName); var icon = new Icon(iconFileName);
imageListFileTypeAssociations.Images.Add(icon); 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.ImageIndex = imageListFileTypeAssociations.Images.Count - 1;
item.Checked = FileTypeAssociations.GetChecked("." + Path.GetFileNameWithoutExtension(iconFileName).ToLowerInvariant(), "Subtitle Edit"); item.Checked = FileTypeAssociations.GetChecked("." + Path.GetFileNameWithoutExtension(iconFileName).ToLowerInvariant(), "Subtitle Edit");
item.Tag = iconFileName; item.Tag = iconFileName;
listViewFileTypeAssociations.Items.Add(item); listViewFileTypeAssociations.Items.Add(item);
} }
listViewFileTypeAssociations.Refresh(); listViewFileTypeAssociations.EndUpdate();
} }
private void buttonUpdateFileTypeAssociations_Click(object sender, EventArgs e) private void buttonUpdateFileTypeAssociations_Click(object sender, EventArgs e)