public void IsValidFilenameTest()
        {
            string validFilename = "filename";

            Assert.IsTrue(NuGenArgument.IsValidFileName(validFilename));

            string invalidFilename = string.Concat(validFilename, new string(Path.GetInvalidFileNameChars()[0], 1));

            Assert.IsFalse(NuGenArgument.IsValidFileName(invalidFilename));
        }
 public void IsValidFilenameEmptyStringTest()
 {
     Assert.IsFalse(NuGenArgument.IsValidFileName(null));
     Assert.IsFalse(NuGenArgument.IsValidFileName(""));
 }
Example #3
0
        private void _controlPanel_Export(object sender, EventArgs e)
        {
            if (!NuGenArgument.IsValidDirectoryName(_pathSelector.SelectedPath))
            {
                MessageBox.Show(
                    string.Format(res.Argument_InvalidDirectory, new string(Path.GetInvalidPathChars()))
                    , res.Message_Alert
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Exclamation
                    );
                return;
            }

            if (!NuGenArgument.IsValidFileName(_templateTextBox.Text))
            {
                MessageBox.Show(
                    string.Format(res.Argument_InvalidFilename, new string(Path.GetInvalidFileNameChars()))
                    , res.Message_Alert
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Exclamation
                    );

                _templateTextBox.SelectAll();
                _templateTextBox.Focus();
                return;
            }

            this.SetExportStep();
            Image[] images;

            if (_thumbnailContainer.SelectedImages.Count > 0)
            {
                images = new Image[_thumbnailContainer.SelectedImages.Count];
                _thumbnailContainer.SelectedImages.CopyTo(images, 0);
            }
            else
            {
                images = new Image[_thumbnailContainer.Images.Count];
                _thumbnailContainer.Images.CopyTo(images, 0);
            }

            this.SetExportParams(
                _exportProgressBar
                , images
                , _typeCombo.ImageType
                , _formatCombo.FileFormat
                , _numWatermarkCheckBox.Checked
                , _watermarkFontBlock.SelectedFont
                , NuGenControlPaint.ColorFromArgb(100 - _watermarkOpacitySpin.Value, _watermarkColorBox.SelectedColor)
                , _watermarkAlignDropDown.SelectedAlignment
                , _pathSelector.SelectedPath
                , _templateTextBox.Text
                );

            MethodInvoker methodInvoker = new MethodInvoker(this.ExportImages);

            methodInvoker.BeginInvoke(
                new AsyncCallback(
                    delegate
            {
                this.BeginInvoke(
                    new MethodInvoker(
                        delegate
                {
                    this.SetFinishStep();
                }
                        )
                    );
            }
                    )
                , null
                );
        }