SIL.FieldWorks.XWorks.ExportDialog.EnsureViewInfo C# (CSharp) Method

EnsureViewInfo() private method

In case the requested export requires a particular view and we aren't showing it, create a temporary one and update the appropriate variables from it. If this returns a non-null value, it is a newly created object which must be disposed. (See LT-11066.)
private EnsureViewInfo ( ) : Control
return System.Windows.Forms.Control
		Control EnsureViewInfo()
		{
			string area = "lexicon";
			string tool = "lexiconDictionary";
			m_areaOrig = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
			if (m_rgFxtTypes.Count == 0)
				return null; // only non-Fxt exports available (like Discourse chart?)
			// var ft = m_rgFxtTypes[FxtIndex((string) m_exportList.SelectedItems[0].Tag)].m_ft;
			var ft = m_rgFxtTypes[FxtIndex((string)m_exportItems[0].Tag)].m_ft;
			if (m_areaOrig == "notebook")
			{
				if (ft != FxtTypes.kftConfigured)
					return null;	// nothing to do.
				area = m_areaOrig;
				tool = "notebookDocument";
			}
			else
			{
				switch (ft)
				{
					case FxtTypes.kftConfigured:
						break;
					case FxtTypes.kftReversal:
						tool = "reversalToolEditComplete";
						break;
					case FxtTypes.kftClassifiedDict:
						// Should match the tool in DistFiles/Language Explorer/Configuration/RDE/toolConfiguration.xml, the value attribute in
						// <tool label="Classified Dictionary" value="lexiconClassifiedDictionary" icon="DocumentView">.
						// We use this to create that tool and base this export on its objects and saved configuration.
						tool = "lexiconClassifiedDictionary";
						break;
					case FxtTypes.kftGrammarSketch:
						area = "grammar";
						tool = "grammarSketch";
						break;
					default:
						return null; // nothing to do.
				}
			}
			var collector = new XmlNode[1];
			var parameter = new Tuple<string, string, XmlNode[]>(area, tool, collector);
			m_mediator.SendMessage("GetContentControlParameters", parameter);
			var controlNode = collector[0];
			Debug.Assert(controlNode != null);
			XmlNode dynLoaderNode = controlNode.SelectSingleNode("dynamicloaderinfo");
			var contentAssemblyPath = XmlUtils.GetAttributeValue(dynLoaderNode, "assemblyPath");
			var contentClass = XmlUtils.GetAttributeValue(dynLoaderNode, "class");
			Control mainControl = (Control)DynamicLoader.CreateObject(contentAssemblyPath, contentClass);
			var parameters = controlNode.SelectSingleNode("parameters");
			((IxCoreColleague)mainControl).Init(m_mediator, parameters);
			InitFromMainControl(mainControl);
			return mainControl;
		}