mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2025-01-07 08:42:51 +01:00
Add BrotliBuilder dialog to configure current serialization parameters
This commit is contained in:
parent
73fef4c8e0
commit
0bfd7ebf3a
144
BrotliBuilder/Dialogs/FormSerializationParameters.Designer.cs
generated
Normal file
144
BrotliBuilder/Dialogs/FormSerializationParameters.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
namespace BrotliBuilder.Dialogs {
|
||||
partial class FormSerializationParameters {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.checkBoxComplexTreeSkipCode = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxComplexTreeRepeatCode = new System.Windows.Forms.CheckBox();
|
||||
this.groupHuffmanTrees = new System.Windows.Forms.GroupBox();
|
||||
this.groupContextMaps = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxContextMapIMTF = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxContextMapRLE = new System.Windows.Forms.CheckBox();
|
||||
this.buttonReserialize = new System.Windows.Forms.Button();
|
||||
//
|
||||
// checkBoxComplexTreeSkipCode
|
||||
//
|
||||
this.checkBoxComplexTreeSkipCode.AutoSize = true;
|
||||
this.checkBoxComplexTreeSkipCode.Checked = true;
|
||||
this.checkBoxComplexTreeSkipCode.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxComplexTreeSkipCode.Location = new System.Drawing.Point(12, 22);
|
||||
this.checkBoxComplexTreeSkipCode.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
|
||||
this.checkBoxComplexTreeSkipCode.Name = "checkBoxComplexTreeSkipCode";
|
||||
this.checkBoxComplexTreeSkipCode.Size = new System.Drawing.Size(176, 19);
|
||||
this.checkBoxComplexTreeSkipCode.TabIndex = 0;
|
||||
this.checkBoxComplexTreeSkipCode.Text = "Use Complex Tree Skip Code";
|
||||
this.checkBoxComplexTreeSkipCode.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxComplexTreeRepeatCode
|
||||
//
|
||||
this.checkBoxComplexTreeRepeatCode.AutoSize = true;
|
||||
this.checkBoxComplexTreeRepeatCode.Checked = true;
|
||||
this.checkBoxComplexTreeRepeatCode.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxComplexTreeRepeatCode.Location = new System.Drawing.Point(12, 47);
|
||||
this.checkBoxComplexTreeRepeatCode.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
|
||||
this.checkBoxComplexTreeRepeatCode.Name = "checkBoxComplexTreeRepeatCode";
|
||||
this.checkBoxComplexTreeRepeatCode.Size = new System.Drawing.Size(190, 19);
|
||||
this.checkBoxComplexTreeRepeatCode.TabIndex = 1;
|
||||
this.checkBoxComplexTreeRepeatCode.Text = "Use Complex Tree Repeat Code";
|
||||
this.checkBoxComplexTreeRepeatCode.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupHuffmanTrees
|
||||
//
|
||||
this.groupHuffmanTrees.Controls.Add(this.checkBoxComplexTreeSkipCode);
|
||||
this.groupHuffmanTrees.Controls.Add(this.checkBoxComplexTreeRepeatCode);
|
||||
this.groupHuffmanTrees.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupHuffmanTrees.Name = "groupHuffmanTrees";
|
||||
this.groupHuffmanTrees.Size = new System.Drawing.Size(219, 75);
|
||||
this.groupHuffmanTrees.TabIndex = 0;
|
||||
this.groupHuffmanTrees.TabStop = false;
|
||||
this.groupHuffmanTrees.Text = "Huffman Trees";
|
||||
//
|
||||
// groupContextMaps
|
||||
//
|
||||
this.groupContextMaps.Controls.Add(this.checkBoxContextMapIMTF);
|
||||
this.groupContextMaps.Controls.Add(this.checkBoxContextMapRLE);
|
||||
this.groupContextMaps.Location = new System.Drawing.Point(237, 12);
|
||||
this.groupContextMaps.Name = "groupContextMaps";
|
||||
this.groupContextMaps.Size = new System.Drawing.Size(247, 75);
|
||||
this.groupContextMaps.TabIndex = 1;
|
||||
this.groupContextMaps.TabStop = false;
|
||||
this.groupContextMaps.Text = "Context Maps";
|
||||
//
|
||||
// checkBoxContextMapIMTF
|
||||
//
|
||||
this.checkBoxContextMapIMTF.AutoSize = true;
|
||||
this.checkBoxContextMapIMTF.Checked = true;
|
||||
this.checkBoxContextMapIMTF.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxContextMapIMTF.Location = new System.Drawing.Point(12, 22);
|
||||
this.checkBoxContextMapIMTF.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
|
||||
this.checkBoxContextMapIMTF.Name = "checkBoxContextMapIMTF";
|
||||
this.checkBoxContextMapIMTF.Size = new System.Drawing.Size(226, 19);
|
||||
this.checkBoxContextMapIMTF.TabIndex = 0;
|
||||
this.checkBoxContextMapIMTF.Text = "Use Inverse Move-To-Front Transform";
|
||||
this.checkBoxContextMapIMTF.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxContextMapRLE
|
||||
//
|
||||
this.checkBoxContextMapRLE.AutoSize = true;
|
||||
this.checkBoxContextMapRLE.Checked = true;
|
||||
this.checkBoxContextMapRLE.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxContextMapRLE.Location = new System.Drawing.Point(12, 47);
|
||||
this.checkBoxContextMapRLE.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
|
||||
this.checkBoxContextMapRLE.Name = "checkBoxContextMapRLE";
|
||||
this.checkBoxContextMapRLE.Size = new System.Drawing.Size(164, 19);
|
||||
this.checkBoxContextMapRLE.TabIndex = 1;
|
||||
this.checkBoxContextMapRLE.Text = "Use Run-Length Encoding";
|
||||
this.checkBoxContextMapRLE.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonReserialize
|
||||
//
|
||||
this.buttonReserialize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonReserialize.Location = new System.Drawing.Point(391, 93);
|
||||
this.buttonReserialize.Name = "buttonReserialize";
|
||||
this.buttonReserialize.Size = new System.Drawing.Size(93, 23);
|
||||
this.buttonReserialize.TabIndex = 2;
|
||||
this.buttonReserialize.Text = "Reserialize";
|
||||
this.buttonReserialize.UseVisualStyleBackColor = true;
|
||||
this.buttonReserialize.Click += new System.EventHandler(this.buttonReserialize_Click);
|
||||
//
|
||||
// FormParameters
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(496, 128);
|
||||
this.Controls.Add(this.buttonReserialize);
|
||||
this.Controls.Add(this.groupContextMaps);
|
||||
this.Controls.Add(this.groupHuffmanTrees);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "FormSerializationParameters";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Serialization Parameters";
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox checkBoxComplexTreeSkipCode;
|
||||
private System.Windows.Forms.CheckBox checkBoxComplexTreeRepeatCode;
|
||||
private System.Windows.Forms.GroupBox groupHuffmanTrees;
|
||||
private System.Windows.Forms.GroupBox groupContextMaps;
|
||||
private System.Windows.Forms.CheckBox checkBoxContextMapIMTF;
|
||||
private System.Windows.Forms.CheckBox checkBoxContextMapRLE;
|
||||
private System.Windows.Forms.Button buttonReserialize;
|
||||
}
|
||||
}
|
63
BrotliBuilder/Dialogs/FormSerializationParameters.cs
Normal file
63
BrotliBuilder/Dialogs/FormSerializationParameters.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using BrotliLib.Brotli.Parameters;
|
||||
using DecideComplexTreeFeature = BrotliLib.Brotli.Parameters.BrotliSerializationParameters.DecideComplexTreeFeature;
|
||||
using DecideContextMapFeature = BrotliLib.Brotli.Parameters.BrotliSerializationParameters.DecideContextMapFeature;
|
||||
|
||||
namespace BrotliBuilder.Dialogs{
|
||||
public partial class FormSerializationParameters : Form{
|
||||
public event EventHandler? Reserialize;
|
||||
|
||||
private readonly BrotliSerializationParameters parameters;
|
||||
|
||||
public FormSerializationParameters(BrotliSerializationParameters parameters){
|
||||
InitializeComponent();
|
||||
|
||||
this.parameters = parameters;
|
||||
this.Disposed += FormParameters_Disposed;
|
||||
|
||||
LoadOptions();
|
||||
SetupOptionEvents();
|
||||
}
|
||||
|
||||
private void FormParameters_Disposed(object? sender, EventArgs e){
|
||||
Reserialize = null;
|
||||
}
|
||||
|
||||
private void buttonReserialize_Click(object sender, EventArgs e){
|
||||
Reserialize?.Invoke(this, e);
|
||||
}
|
||||
|
||||
// Option handling
|
||||
|
||||
private static readonly DecideComplexTreeFeature ComplexTreeFeatureEnable = _ => true;
|
||||
private static readonly DecideComplexTreeFeature ComplexTreeFeatureDisable = _ => false;
|
||||
|
||||
private static readonly DecideContextMapFeature ContextMapFeatureEnable = _ => true;
|
||||
private static readonly DecideContextMapFeature ContextMapFeatureDisable = _ => false;
|
||||
|
||||
private void SetupOptionEvents(){
|
||||
this.checkBoxComplexTreeSkipCode.CheckedChanged += OnOptionChanged;
|
||||
this.checkBoxComplexTreeRepeatCode.CheckedChanged += OnOptionChanged;
|
||||
|
||||
this.checkBoxContextMapIMTF.CheckedChanged += OnOptionChanged;
|
||||
this.checkBoxContextMapRLE.CheckedChanged += OnOptionChanged;
|
||||
}
|
||||
|
||||
private void LoadOptions(){
|
||||
checkBoxComplexTreeSkipCode.Checked = !ReferenceEquals(parameters.UseComplexTreeSkipCode, ComplexTreeFeatureDisable);
|
||||
checkBoxComplexTreeRepeatCode.Checked = !ReferenceEquals(parameters.UseComplexTreeRepeatCode, ComplexTreeFeatureDisable);
|
||||
|
||||
checkBoxContextMapIMTF.Checked = !ReferenceEquals(parameters.UseContextMapIMTF, ContextMapFeatureDisable);
|
||||
checkBoxContextMapRLE.Checked = !ReferenceEquals(parameters.UseContextMapRLE, ContextMapFeatureDisable);
|
||||
}
|
||||
|
||||
private void OnOptionChanged(object? sender, EventArgs e){
|
||||
parameters.UseComplexTreeSkipCode = checkBoxComplexTreeSkipCode.Checked ? ComplexTreeFeatureEnable : ComplexTreeFeatureDisable;
|
||||
parameters.UseComplexTreeRepeatCode = checkBoxComplexTreeRepeatCode.Checked ? ComplexTreeFeatureEnable : ComplexTreeFeatureDisable;
|
||||
|
||||
parameters.UseContextMapIMTF = checkBoxContextMapIMTF.Checked ? ContextMapFeatureEnable : ContextMapFeatureDisable;
|
||||
parameters.UseContextMapRLE = checkBoxContextMapRLE.Checked ? ContextMapFeatureEnable : ContextMapFeatureDisable;
|
||||
}
|
||||
}
|
||||
}
|
30
BrotliBuilder/FormMain.Designer.cs
generated
30
BrotliBuilder/FormMain.Designer.cs
generated
@ -39,10 +39,12 @@
|
||||
this.menuItemStaticDictionary = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemCompareMarkers = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemSeparatorT1 = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemSeparatorT2 = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemCloneGeneratedToOriginal = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemCloneOriginalToGenerated = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemEncodeFile = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemTransform = new System.Windows.Forms.MenuItem();
|
||||
this.menuItemConfigureSerializationParameters = new System.Windows.Forms.MenuItem();
|
||||
this.flowPanelBlocks = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.statusBar = new System.Windows.Forms.StatusBar();
|
||||
this.statusBarPanelPadding1 = new System.Windows.Forms.StatusBarPanel();
|
||||
@ -164,16 +166,25 @@
|
||||
//
|
||||
this.menuItemTools.Index = 2;
|
||||
this.menuItemTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.menuItemConfigureSerializationParameters,
|
||||
this.menuItemSeparatorT1,
|
||||
this.menuItemStaticDictionary,
|
||||
this.menuItemCompareMarkers,
|
||||
this.menuItemSeparatorT1,
|
||||
this.menuItemSeparatorT2,
|
||||
this.menuItemCloneGeneratedToOriginal,
|
||||
this.menuItemCloneOriginalToGenerated});
|
||||
this.menuItemTools.Text = "&Tools";
|
||||
//
|
||||
// menuItemConfigureParameters
|
||||
//
|
||||
this.menuItemConfigureSerializationParameters.Index = 0;
|
||||
this.menuItemConfigureSerializationParameters.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
|
||||
this.menuItemConfigureSerializationParameters.Text = "Configure Serialization Parameters";
|
||||
this.menuItemConfigureSerializationParameters.Click += new System.EventHandler(this.menuItemConfigureSerializationParameters_Click);
|
||||
//
|
||||
// menuItemStaticDictionary
|
||||
//
|
||||
this.menuItemStaticDictionary.Index = 0;
|
||||
this.menuItemStaticDictionary.Index = 2;
|
||||
this.menuItemStaticDictionary.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
|
||||
this.menuItemStaticDictionary.Text = "Static Dictionary";
|
||||
this.menuItemStaticDictionary.Click += new System.EventHandler(this.menuItemStaticDictionary_Click);
|
||||
@ -181,27 +192,32 @@
|
||||
// menuItemCompareMarkers
|
||||
//
|
||||
this.menuItemCompareMarkers.Enabled = false;
|
||||
this.menuItemCompareMarkers.Index = 1;
|
||||
this.menuItemCompareMarkers.Index = 3;
|
||||
this.menuItemCompareMarkers.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
|
||||
this.menuItemCompareMarkers.Text = "Compare Markers";
|
||||
this.menuItemCompareMarkers.Click += new System.EventHandler(this.menuItemCompareMarkers_Click);
|
||||
//
|
||||
// menuItemSeparatorT1
|
||||
//
|
||||
this.menuItemSeparatorT1.Index = 2;
|
||||
this.menuItemSeparatorT1.Index = 1;
|
||||
this.menuItemSeparatorT1.Text = "-";
|
||||
//
|
||||
// menuItemSeparatorT2
|
||||
//
|
||||
this.menuItemSeparatorT2.Index = 4;
|
||||
this.menuItemSeparatorT2.Text = "-";
|
||||
//
|
||||
// menuItemCloneGeneratedToOriginal
|
||||
//
|
||||
this.menuItemCloneGeneratedToOriginal.Enabled = false;
|
||||
this.menuItemCloneGeneratedToOriginal.Index = 3;
|
||||
this.menuItemCloneGeneratedToOriginal.Index = 5;
|
||||
this.menuItemCloneGeneratedToOriginal.Text = "Generated >> Original";
|
||||
this.menuItemCloneGeneratedToOriginal.Click += new System.EventHandler(this.menuItemCloneGeneratedToOriginal_Click);
|
||||
//
|
||||
// menuItemCloneOriginalToGenerated
|
||||
//
|
||||
this.menuItemCloneOriginalToGenerated.Enabled = false;
|
||||
this.menuItemCloneOriginalToGenerated.Index = 4;
|
||||
this.menuItemCloneOriginalToGenerated.Index = 6;
|
||||
this.menuItemCloneOriginalToGenerated.Text = "Generated << Original";
|
||||
this.menuItemCloneOriginalToGenerated.Click += new System.EventHandler(this.menuItemCloneOriginalToGenerated_Click);
|
||||
//
|
||||
@ -476,7 +492,9 @@
|
||||
private System.Windows.Forms.StatusBarPanel statusBarPanelPadding3;
|
||||
private System.Windows.Forms.MenuItem menuItemSaveOutput;
|
||||
private System.Windows.Forms.MenuItem menuItemSeparatorT1;
|
||||
private System.Windows.Forms.MenuItem menuItemSeparatorT2;
|
||||
private System.Windows.Forms.MenuItem menuItemCloneGeneratedToOriginal;
|
||||
private System.Windows.Forms.MenuItem menuItemCloneOriginalToGenerated;
|
||||
private System.Windows.Forms.MenuItem menuItemConfigureSerializationParameters;
|
||||
}
|
||||
}
|
@ -480,6 +480,21 @@ namespace BrotliBuilder{
|
||||
}
|
||||
}
|
||||
|
||||
private void menuItemConfigureSerializationParameters_Click(object? sender, EventArgs e){
|
||||
using FormSerializationParameters form = new FormSerializationParameters(fileGenerated.SerializationParameters);
|
||||
form.Reserialize += fileGenerated_Reserialize;
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void fileGenerated_Reserialize(object? sender, EventArgs e){
|
||||
if (lastGeneratedFile == null){
|
||||
MessageBox.Show("No previously generated file available.", "Reserialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else{
|
||||
fileGenerated.LoadStructure(lastGeneratedFile, lastOriginalFileBytes);
|
||||
}
|
||||
}
|
||||
|
||||
private void menuItemCompareMarkers_Click(object? sender, EventArgs e){
|
||||
if (brotliFilePanelOriginal.MarkerRoot == null || brotliFilePanelGenerated.MarkerRoot == null){
|
||||
MessageBox.Show("No original file opened.", "Compare Markers Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
Loading…
Reference in New Issue
Block a user