This was cause in the validation process I dont only check if the document is ok. But also got some parameters from the document. (eg. check if a view exist, and also get that view). I managed to solve this like this:
FORM.CS
public class ProcesoValidacion
{
public Document doc;
public bool validez;
public int parámetro1;
public int parámetro2;
public int parámetro3;
public ProcesoValidacion(Document doc)
{
//CODE: "this.validez = false, this.parametro1 = 88", etc.
}
public bool getValidez()
{
return validez;
}
public int getParametro1()
{
return Parametro1;
}
public int getParametro2()
{
return Parametro2;
}
public int getParametro3()
{
return Parametro3;
}
}
And then COMMAND.CS:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
using (MiForm Form = new MiForm(commandData))
{
MiForm.ProcesoValidacion ProcesoInicio = new MiForm.ProcesoValidacion(doc);
if (ProcesoInicio.getValidez() == true)
{
Form.ShowDialog();
if (Form.DialogResult == System.Windows.Forms.DialogResult.Cancel)
{
return Result.Cancelled;
}
}
else
{
return Result.Cancelled;
}
}
return Result.Succeeded;
}
Then I can handle cancelations directly in command.cs and not in form.cs.
Thanks for your help. Regards.