Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();

            var executingAssembly = Assembly.GetExecutingAssembly();

            Icon  = Icon.ExtractAssociatedIcon(executingAssembly.Location);
            Text += $" - {executingAssembly.GetName().Version}";

            AppendLog(Text);

            _openFileDialog = new OpenFileDialog()
            {
                CheckFileExists = true,
                CheckPathExists = true,
            };

            _saveFileDialog = new SaveFileDialog()
            {
                DefaultExt      = ".png",
                Filter          = "Bitmap|*.bmp|Jpeg|*.jpg|Png|*.png|Gif|*.gif|All files|*.*",
                FilterIndex     = 3, // 1 based
                OverwritePrompt = true,
            };

            _ffmpegWrapper              = new FfmpegWrapper("ffmpeg.exe");
            _imageProcessor             = new ImageProcessor();
            _barCodeParametersValidator = new BarCodeParametersValidator();

            useInputHeightForOutputCheckBox.Checked = true;
            generateButton.Text = GenerateButtonText;
        }
Exemplo n.º 2
0
    public MainForm()
    {
        InitializeComponent();

        var executingAssembly = Assembly.GetExecutingAssembly();

        Icon  = Icon.ExtractAssociatedIcon(executingAssembly.Location);
        Text += $" - {executingAssembly.GetName().Version}";

        _barGenerators = new List <BarGeneratorViewModel>
        {
            new BarGeneratorViewModel(
                new MagicScalerBarGenerator("Normal", average: false),
                "The default mode to generate barcodes.\r\nIt scales images using a resampling algorithm that takes care of gamma correction and produces correct color averages.",
                initialCheckState: true),
            new BarGeneratorViewModel(
                new MagicScalerBarGenerator("Normal (smoothed)", "_smoothed", average: true, InterpolationSettings.CubicSmoother),
                "Almost the same as the 'Normal' mode, but vertically smoothed.\r\nIt also uses a 'cubic smoother' resampling algorithm that generates images sharper than the normal algorithm.",
                initialCheckState: false),
            new BarGeneratorViewModel(
                GdiBarGenerator.CreateLegacy(average: false),
                "The mode used in previous versions.\r\nIt's relatively fast, but the algorithm used to scale images is of poor quality.\r\nThis mode is not recommended, and only here for backward-compatibility.",
                initialCheckState: false),
            new BarGeneratorViewModel(
                GdiBarGenerator.CreateLegacy(average: true),
                "Same as 'Legacy', but vertically smoothed.",
                initialCheckState: false),
        };

        barGeneratorList.DisplayMember = nameof(BarGeneratorViewModel.DisplayName);
        barGeneratorList.Items.Clear();
        foreach (var item in _barGenerators)
        {
            barGeneratorList.Items.Add(item, isChecked: item.Checked);
        }

        barGeneratorList.SelectedItem = _barGenerators.First(x => x.Checked); // So that the right panel displays something.
        barGeneratorList.SelectedItem = null;                                 // Unselect so a click on the line will not uncheck the item.

        AppendLog(Text);

        _openFileDialog = new OpenFileDialog()
        {
            CheckFileExists = true,
            CheckPathExists = true,
        };

        _saveFileDialog = new SaveFileDialog()
        {
            DefaultExt      = ".png",
            Filter          = "Bitmap|*.bmp|Jpeg|*.jpg|Png|*.png|Gif|*.gif|All files|*.*",
            FilterIndex     = 3, // 1 based
            OverwritePrompt = true,
        };

        _ffmpegWrapper              = new FfmpegWrapper("ffmpeg.exe");
        _imageProcessor             = new ImageStreamProcessor();
        _barCodeParametersValidator = new BarCodeParametersValidator();

        useInputHeightForOutputCheckBox.Checked = true;
        generateButton.Text = GenerateButtonText;
    }