protected IHost HostFromDocumentData(string documentData, string documentExpression) { IHost host = FrontendSession.CreateHost(); try { Deserializer deserializer = FrontendSession.CreateDeserializer(); INode instance = GetNewDesignNode(); try { deserializer.Deserialize(documentData, instance); Dataphoria.Warnings.AppendErrors(this, deserializer.Errors, true); host.Children.Add(instance); host.Document = documentExpression; } catch { instance.Dispose(); throw; } host.Open(); return(host); } catch { host.Dispose(); throw; } }
protected virtual INode GetNewDesignNode() { var form = (IWindowsFormInterface)FrontendSession.CreateForm(); Dataphoria.AddDesignerForm(form, this); return(form); }
public virtual void New() { IHost host = FrontendSession.CreateHost(); try { INode node = GetNewDesignNode(); host.Children.Add(node); host.Open(); InternalNew(host, true); } catch { host.Dispose(); throw; } }
protected override void OnClosing(CancelEventArgs args) { base.OnClosing(args); try { _service.CheckModified(); if (_isDesignHostOwner && (!FrontendSession.CloseAllForms(_designHost, CloseBehavior.AcceptOrClose))) { // if we are hosting, close the child forms throw new AbortException(); } } catch { args.Cancel = true; throw; } }
protected virtual void RequestSave(DesignService service, DesignBuffer buffer) { Serializer serializer = FrontendSession.CreateSerializer(); var document = new XDocument(); serializer.Serialize(document, _designHost.Children[0]); Dataphoria.Warnings.AppendErrors(this, serializer.Errors, true); var stream = new MemoryStream(); var xmlTextWriter = XmlWriter.Create(stream, new XmlWriterSettings() { Encoding = Encoding.UTF8, Indent = true }); document.Save(xmlTextWriter); xmlTextWriter.Flush(); byte[] writerString = stream.ToArray(); buffer.SaveData(Encoding.UTF8.GetString(writerString, 0, writerString.Length)); UpdateHostsDocument(buffer); }
protected override void RequestSave(DesignService service, DesignBuffer buffer) { var document = new DilxDocument(); if (_ancestors != null) { document.Ancestors = _ancestors; } var content = new XDocument(); Serializer serializer = FrontendSession.CreateSerializer(); serializer.Serialize(content, DesignHost.Children[0]); Dataphoria.Warnings.AppendErrors(this, serializer.Errors, true); if (_ancestors != null) { content = Inheritance.Diff(MergeAncestors(document.Ancestors), content); } document.Content = content.Root.ToString(); // only the document node buffer.SaveData(document.Write()); UpdateHostsDocument(buffer); }