public MatrixThresholdFilterDialog(
            MatrixThresholdFilter existingModule)
            : base(existingModule)
        {
            module = modifiedModule as MatrixThresholdFilter;
            if (module == null) {
                modifiedModule = new MatrixThresholdFilter();
                module = modifiedModule as MatrixThresholdFilter;
            }

            matrixPanel = new ThresholdMatrixPanel(
                (uint)module.Matrix.Height,
                (uint)module.Matrix.Width);
            matrixPanel.Matrix = module.Matrix.DefinitionMatrix;
            matrixPanel.Scaled = !module.Matrix.Incremental;

            table = new Table(2, 1, false)
                { ColumnSpacing = 5, RowSpacing = 5, BorderWidth = 5 };
            table.Attach(new Label("Threshold matrix:") { Xalign = 0.0f },
                0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Shrink,
                0, 0);
            table.Attach(matrixPanel, 0, 1, 1, 2,
                AttachOptions.Fill | AttachOptions.Expand,
                AttachOptions.Fill | AttachOptions.Expand, 0, 0);
            table.ShowAll();
            VBox.PackStart(table);
        }
            public ThresholdTableRecordDialog(DynamicMatrixThresholdFilter.ThresholdRecord
                editedRecord)
            {
                Title = "Threshold record editing";
                Modal = true;
                AddButton("OK", ResponseType.Ok);
                AddButton("Cancel", ResponseType.Cancel);

                record = editedRecord;
                if (record == null) {
                    record = new DynamicMatrixThresholdFilter.ThresholdRecord();
                }

                intensitySpinButton = new SpinButton(0, 255, 1);
                intensitySpinButton.Value = record.keyRangeStart;

                matrixPanel = new ThresholdMatrixPanel((uint)record.matrix.Height,
                (uint)record.matrix.Width);
                matrixPanel.Matrix = record.matrix.DefinitionMatrix;
                matrixPanel.Scaled = !record.matrix.Incremental;

                noiseHScale = new HScale(0, 1, 0.01);
                noiseHScale.Value = record.noiseAmplitude;

                table = new Table(4, 2, false)
                    { ColumnSpacing = 5, RowSpacing = 5, BorderWidth = 5 };

                table.Attach(new Label("Intensity range start:")
                    { Xalign = 0.0f }, 0, 1, 0, 1, AttachOptions.Fill,
                    AttachOptions.Shrink, 0, 0);
                table.Attach(intensitySpinButton, 1, 2, 0, 1,
                    AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

                table.Attach(new Label("Threshold matrix:") { Xalign = 0.0f },
                    0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

                table.Attach(matrixPanel, 0, 2, 2, 3,
                    AttachOptions.Fill | AttachOptions.Expand,
                    AttachOptions.Fill | AttachOptions.Expand, 0, 0);

                table.Attach(new Label("Noise amplitude:") { Xalign = 0.0f },
                    0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
                table.Attach(noiseHScale, 1, 2, 3, 4,
                    AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

                table.ShowAll();
                VBox.PackStart(table);
            }