Пример #1
0
        protected void saveButtonHandler(object sender, EventArgs e)
        {
            string path = _folderText.Text;

            if (path[path.Length - 1] != '\\')
            {
                path += '\\';
            }

            string name = _nameBox.Text;

            if (_appendBtn.Checked)
            {
                name += _appendBox.Text + _wnd.ExportExtension;

                string[] fileList = Directory.GetFiles(path);
                for (int i = 0; i < fileList.Length; i++)
                {
                    fileList[i] = Path.GetFileName(fileList[i]);
                }

                try {
                    var   suff       = new Suffix(name);
                    int[] exportList = suff.ListOfValues(fileList);

                    int nextNum = 0;
                    if (exportList != null)
                    {
                        nextNum = exportList[exportList.Length - 1] + 1;
                    }

                    name = suff.Generate(nextNum);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                name += _wnd.ExportExtension;
            }

            string fullPath = path + name;

            _wnd.Export(fullPath, (int)_scaleBox.Value);

            string abrvName;

            if (path.Length >= 10)
            {
                abrvName = path.Substring(0, 7) + "...\\" + name;
            }
            else
            {
                abrvName = fullPath;
            }

            _saveMsg.Text = "Saved " + abrvName;
        }