private void CreateCustomPanelList(AttachedPanelsItem currentRootObject, CustomPanel parentCustomPanel) { if (parentCustomPanel == null) { parentCustomPanel = new CustomPanel() { Hight = currentRootObject.PanelHeight, Width = currentRootObject.PanelWidth, Offset = Converters.DoubleStringToIntWithRound(currentRootObject.HingeOffset), Name = currentRootObject.PanelName, AT = currentRootObject.AttachedToSide, IsRotatedFlag = true, RotationState = RotationState.none }; customPanels.Add(parentCustomPanel); } foreach (var n in currentRootObject.AttachedPanelsItems.AttachedPanelsItem) { var nPanel = new CustomPanel() { Name = n.PanelName, Width = n.PanelWidth, Hight = n.PanelHeight, Offset = Converters.DoubleStringToIntWithRound(n.HingeOffset), AT = n.AttachedToSide, Parent = parentCustomPanel, IsRotatedFlag = false, RotationState = RotationState.none }; parentCustomPanel.ChildPanels.Add(nPanel); customPanels.Add(nPanel); CreateCustomPanelList(n, nPanel); } }
private void ReadXMLFile_Click(object sender, RoutedEventArgs e) { try { RootObject rootObject = new RootObject(); rootObject = XmlProcessor.GetXmlRootObject(@"" + XmlSelector.GetSelectedXmlPath()); //rootObject = XmlProcessor.GetXmlRootObject(@"C:\Projects\BeerPack.xml"); SetUpBitmapDimensions(int.Parse(rootObject.OriginalDocumentWidth), int.Parse(rootObject.OriginalDocumentHeight)); AttachedPanelsItem rootAttached = new AttachedPanelsItem() { PanelName = rootObject.Panels.PanelsItem.PanelName, PanelWidth = rootObject.Panels.PanelsItem.PanelWidth, PanelHeight = rootObject.Panels.PanelsItem.PanelHeight, AttachedPanelsItems = rootObject.Panels.PanelsItem.AttachedPanelsItems }; CreateCustomPanelList(rootAttached, null); customPanelsAfterTransformation = PanelTransformation.RotatePanels(customPanels); customPanelsAfterXYCoordinates = PanelCoordinateCalculation.ChangeReferencePointOfRoot(customPanels, rootObject); UserMessage.Content = "File info: Xml file was successfully read!"; CreatePreview.IsEnabled = true; SavePreview.IsEnabled = true; } catch (Exception ex) { UserMessage.Content = "File error: " + ex.Message + "!"; } }