Пример #1
0
        /*
         * Verify
         */

        /// <summary>
        /// Verifies whether the data entered by the user is valid.
        /// </summary>
        /// <returns><see langword="true"/> if the entered data is valid; otherwise, <see langword="false"/>.</returns>
        public bool Verify()
        {
            if (!NuGenArgument.IsValidDirectoryName(this.directorySelector.Path))
            {
                MessageBox.Show(
                    string.Format(Properties.Resources.Argument_InvalidDirectory, new string(Path.GetInvalidPathChars())),
                    Properties.Resources.Message_Alert,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );

                return(false);
            }

            if (!NuGenArgument.IsValidFilename(this.filenameTextBox.Text))
            {
                MessageBox.Show(
                    string.Format(Properties.Resources.Argument_InvalidFilename, new string(Path.GetInvalidFileNameChars())),
                    Properties.Resources.Message_Alert,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                    );

                this.filenameTextBox.SelectionStart = 0;
                this.filenameTextBox.SelectAll();

                return(false);
            }

            return(true);
        }
Пример #2
0
        public void IsValidDirectoryNameTest()
        {
            String validDirectory = "directory";

            Assert.IsTrue(NuGenArgument.IsValidDirectoryName(validDirectory));

            String invalidDirectory = String.Concat(validDirectory, new String(Path.GetInvalidPathChars()[0], 1));

            Assert.IsFalse(NuGenArgument.IsValidDirectoryName(invalidDirectory));
        }
Пример #3
0
 public void IsValidDirectoryNameEmptyStringTest()
 {
     Assert.IsFalse(NuGenArgument.IsValidDirectoryName(null));
     Assert.IsFalse(NuGenArgument.IsValidDirectoryName(""));
 }
Пример #4
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
                );
        }