public static HydroDocument Load(Stream stream) { var doc = new HydroDocument(); var xdoc = XDocument.Load(stream); var version = xdoc.Root.Attribute("Version").Value; if (version != "1.0.0.0") throw new FileFormatException("Unsupported file version!"); var xroot = xdoc.Element("HydroObjectFile"); doc.hydroObjectGraph.LoadFromXmlFile(xroot); foreach (var xelement in xroot.Element("ElementInfo").Elements("FrameworkElement")) { doc.XmlDeserializeElement(xelement); } return doc; }
public MainWindow() { InitializeComponent(); ChangeStateCommandBinding = new CommandBinding(ChangeState); SaveAsCommandBinding = new CommandBinding(ApplicationCommands.SaveAs); SaveAsCommandBinding.Executed += SaveAsCommandBindingExecuted; OpenCommandBinding = new CommandBinding(ApplicationCommands.Open); OpenCommandBinding.Executed += OpenCommandBindingExecuted; CommandBindings.Add(ChangeStateCommandBinding); CommandBindings.Add(SaveAsCommandBinding); CommandBindings.Add(OpenCommandBinding); mainWindowState = new MainWindowSelecting(this); //hydroObjectGraph = new HydroObjectGraph(); //elementDictionary = new Dictionary<FrameworkElement, HydroObject>(); Transform = new TranslateTransform(); HydroDocument = new HydroDocument(); elementDataDic = new Dictionary<FrameworkElement, ElementData>(); }