// Set new visualization method private void visualizationTypeMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; if (item.Tag is VisualizationType) { imageProcessor.VisualizationType = (VisualizationType)item.Tag; lock (this) { if (imageProcessor.VisualizationType == VisualizationType.Model) { if (arForm == null) { arForm = new AugmentedRealityForm( ); arForm.FormClosing += new FormClosingEventHandler(arForm_FormClosing); arForm.Show( ); } } else { if (arForm != null) { arForm.Close( ); } } } } }
// On closing the Augmented Reality form private void arForm_FormClosing(object sender, FormClosingEventArgs e) { arForm.FormClosing -= new FormClosingEventHandler(arForm_FormClosing); arForm = null; // reset visualization type if form was closed by user if (imageProcessor.VisualizationType == VisualizationType.Model) { imageProcessor.VisualizationType = VisualizationType.Name; } }