private void categoryToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult dires = _catName.ShowDialog();
if (string.IsNullOrEmpty(_catName.CategoryName) || !dires.Equals(DialogResult.OK))
return;
bool pageExists;
// attempt validation of the category's existence, warn user if it doesn't exist
try
{
// TODO:ApiEdit PageExists/similar function (wrapper for this, we don't need/care about page text)
IApiEdit editor = TheSession.Editor.SynchronousEditor.Clone();
editor.Open(_catName.CategoryName, false);
pageExists = editor.Page.Exists;
}
catch
{
MessageBox.Show("Unable to check category existence");
return;
}
if (pageExists ||
MessageBox.Show(_catName.CategoryName + " does not exist. Add it to the page anyway?",
"Non-existent category", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
txtEdit.Text += "\r\n\r\n[[" + _catName.CategoryName + "]]";
// remove any {{uncategorised}} tag now – tagger still counts categories based on saved page revision
txtEdit.Text = WikiRegexes.Uncat.Replace(txtEdit.Text, "");
ReparseEditBox();
}
}