/// <summary>
        /// Applies new configuration settings and closes the form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAcceptClick(object sender, EventArgs e)
        {
            _bork = false;

            if (cbResources.Checked)             // handle XCOM resource path(s) configuration ->
            {
                Ufo  = Ufo.Trim();
                Tftd = Tftd.Trim();

                if (Ufo.EndsWith(@"\", StringComparison.Ordinal))                 // NOTE: drive-root directories do funny things. Like append '\'
                {
                    Ufo = Ufo.Substring(0, Ufo.Length - 1);
                }

                if (Tftd.EndsWith(@"\", StringComparison.Ordinal))
                {
                    Tftd = Tftd.Substring(0, Tftd.Length - 1);
                }

                if (String.IsNullOrEmpty(Ufo) && String.IsNullOrEmpty(Tftd))
                {
                    ShowErrorDialog("Both folders cannot be blank.");
                }
                else if (!String.IsNullOrEmpty(Ufo) && !Directory.Exists(Ufo))
                {
                    ShowErrorDialog("The UFO folder does not exist.");
                }
                else if (!String.IsNullOrEmpty(Tftd) && !Directory.Exists(Tftd))
                {
                    ShowErrorDialog("The TFTD folder does not exist.");
                }
                else                 // check for a valid XCOM CursorSprite and create MapResources.yml ->
                {
                    const string CursorPck = SharedSpace.CursorFilePrefix + SpriteCollection.PckExt;
                    const string CursorTab = SharedSpace.CursorFilePrefix + SpriteCollection.TabExt;

                    if ((!File.Exists(Path.Combine(Ufo, CursorPck)) || !File.Exists(Path.Combine(Ufo, CursorTab))) &&
                        (!File.Exists(Path.Combine(Tftd, CursorPck)) || !File.Exists(Path.Combine(Tftd, CursorTab))))
                    {
                        ShowErrorDialog("A valid UFO or TFTD resource directory must exist with"
                                        + Environment.NewLine + Environment.NewLine
                                        + CursorPck + Environment.NewLine
                                        + CursorTab);
                    }
                    else
                    {
                        _pathResources.CreateDirectory();

                        using (var fs = new FileStream(_pathResources.Fullpath, FileMode.Create))
                            using (var sw = new StreamWriter(fs))
                            {
                                object node = new
                                {
                                    ufo = (!String.IsNullOrEmpty(Ufo)  ? Ufo
                                                                                                                                        : PathInfo.NotConfigured),
                                    tftd = (!String.IsNullOrEmpty(Tftd) ? Tftd
                                                                                                                                        : PathInfo.NotConfigured)
                                };

                                var ser = new Serializer();
                                ser.Serialize(sw, node);
                            }

                        DialogResult = DialogResult.OK;
                    }
                }
            }

            if (!_bork && cbTilesets.Checked)             // deal with MapTilesets.yml/.tpl ->
            {
                _pathTilesets.CreateDirectory();

                string pfeTilesets = _pathTilesets.Fullpath;

                if (rbTilesets.Checked)                 // make a backup of the user's MapTilesets.yml if it exists.
                {
                    if (File.Exists(pfeTilesets))
                    {
                        File.Copy(pfeTilesets, Path.Combine(_pathTilesets.DirectoryPath, PathInfo.ConfigTilesetsOld), true);
                    }
                }
                else                 // rbTilesetsTpl.Checked
                {
                    pfeTilesets = Path.Combine(_pathTilesets.DirectoryPath, PathInfo.ConfigTilesetsTpl);
                }

                using (var sr = new StreamReader(Assembly.GetExecutingAssembly()
                                                 .GetManifestResourceStream("MapView._Embedded.MapTilesets.yml")))
                    using (var fs = new FileStream(pfeTilesets, FileMode.Create))
                        using (var sw = new StreamWriter(fs))
                            while (sr.Peek() != -1)
                            {
                                sw.WriteLine(sr.ReadLine());
                            }

                if (rbTilesets.Checked)
                {
                    DialogResult = DialogResult.OK;
                }
                else                 // rbTilesetsTpl.Checked
                {
                    ShowInfoDialog("Tileset template has been created "
                                   + Environment.NewLine + Environment.NewLine
                                   + pfeTilesets);

                    if (!cbResources.Checked)
                    {
                        Close();
                    }
                }
            }
        }