internal object OpenNamedWindow(FormDefinition formDef, XElement xml, ActivityHarness sourceHarness) { string url = FormsURL + formDef.Path; object o = null; try { System.Xml.XmlTextReader rdr = UrlAsXmlTextReader(url); o = XamlReader.Load(rdr); } catch (Exception ex) { ApplicationEx.DebugException(ex, url); return(null); } if (o is WindowEx) { WindowEx w = (WindowEx)o; if (sourceHarness == null) { w.Initialise(xml); } else { w.InitialiseCopy(sourceHarness); } w.Show(); } else if (o is TabItem) { TabItem ti = (TabItem)o; if (ti is TabItemEx) { TabItemEx ati = (TabItemEx)ti; ati.IsDynamic = true; if (sourceHarness == null) { ati.Initialise(xml); } else { ati.InitialiseCopy(sourceHarness); ati.Harness.IsActivityOwner = false; } } //homeTabControl.Items.Add(ti); //homeTabControl.SelectedItem = ti; } return(o); }
partial void CreateActivityContainerInternal(string activity, string style, XElement xml, ActivityHarness sourceHarness) { // If the container is a Page, navigate to it. If it is a ChildWindow, display it. FormDefinition fd = FormMappings.GetFormDefinition(activity, style); if (fd == null) { DisplayMessageBox("No mapping found for " + activity + " (" + style + ")", "Create Activity Error"); return; } if (fd.IsLocal) { string formFullName = FormMappings.GetFormFullName(fd); Assembly assembly = Assembly.GetCallingAssembly(); //var wex = assembly.CreateInstance(formFullName) as IActivityContainer; Type type = assembly.GetType(formFullName); if (type == null) { assembly = Application.Current.GetType().Assembly; //wex = assembly.CreateInstance(formFullName) as IActivityContainer; type = assembly.GetType(formFullName); } if (type != null) { if (type.IsSubclassOf(typeof(Page)) && XamlFileDetailsCollection.ContainsKey(formFullName)) { // This is a Page, so navigate to the view NavigationCacheActivityXML = xml; XAMLFileDetails fileDetails = XamlFileDetailsCollection[formFullName]; string xamlFileName = fileDetails.FileName; ActivityHostFrame.Navigate(new Uri("/" + xamlFileName, UriKind.Relative)); } else { var view = assembly.CreateInstance(formFullName) as IActivityContainer; if (view != null) { view.ActivityName = activity; view.ActivityStyle = style; view.Initialise(xml); ShowActivityContainer(view); } else { throw new Exception(String.Format("Activity '{0}' could not be created. Check your FormMapping.xml. Ensure the namespaces element matches your project's namespace and your activity elements are configured to map Server Activities to local Views.", formFullName)); } } } } else//load 'loose' { object o = OpenNamedWindow(fd, xml, sourceHarness); } }