Exemplo n.º 1
0
 public static void ExtractSummaryTableWidth(XDocument xDocument, out BridgeDeckDamageSummaryTableWidth bridgeDeckDamageSummaryTableWidth, out SuperSpaceDamageSummaryTableWidth superSpaceDamageSummaryTableWidth, out SubSpaceDamageSummaryTableWidth subSpaceDamageSummaryTableWidth)
 {
     //No="20" Position="30" Component="40" Damage="40" DamageDescription="50" PictureNo="20" Comment="20"
     bridgeDeckDamageSummaryTableWidth = new BridgeDeckDamageSummaryTableWidth
     {
         No = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("No").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Position = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("Position").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Component = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("Component").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Damage = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("Damage").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         DamageDescription = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("DamageDescription").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         PictureNo = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("PictureNo").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Comment = Convert.ToDouble(xDocument.Elements("configuration").Elements("BridgeDeckSummaryTable").FirstOrDefault().Attribute("Comment").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
     };
     superSpaceDamageSummaryTableWidth = new SuperSpaceDamageSummaryTableWidth
     {
         No                  = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("No").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , Position          = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("Position").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , Component         = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("Component").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , Damage            = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("Damage").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , DamageDescription = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("DamageDescription").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , PictureNo         = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("PictureNo").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         , Comment           = Convert.ToDouble(xDocument.Elements("configuration").Elements("SuperSpaceSummaryTable").FirstOrDefault().Attribute("Comment").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
     };
     subSpaceDamageSummaryTableWidth = new SubSpaceDamageSummaryTableWidth
     {
         No = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("No").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Position = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("Position").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Component = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("Component").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Damage = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("Damage").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         DamageDescription = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("DamageDescription").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         PictureNo = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("PictureNo").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
         ,
         Comment = Convert.ToDouble(xDocument.Elements("configuration").Elements("SubSpaceSummaryTable").FirstOrDefault().Attribute("Comment").Value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)
     };
 }
Exemplo n.º 2
0
        public OptionSummaryTablePage(BridgeDeckDamageSummaryTableWidth bridgeDeckDamageSummaryTableWidth, SuperSpaceDamageSummaryTableWidth superSpaceDamageSummaryTableWidth, SubSpaceDamageSummaryTableWidth subSpaceDamageSummaryTableWidth)
        {
            //TODO:增加校验
            //if (bridgeDeckGrouplist is null)
            //{
            //    throw new ArgumentNullException(nameof(bridgeDeckGrouplist));
            //}

            InitializeComponent();

            BridgeDeckStackPanel.DataContext = new BridgeDeckDamageSummaryTableWidth
            {
                No                  = bridgeDeckDamageSummaryTableWidth.No
                , Position          = bridgeDeckDamageSummaryTableWidth.PictureNo
                , Component         = bridgeDeckDamageSummaryTableWidth.Component
                , Damage            = bridgeDeckDamageSummaryTableWidth.Damage
                , DamageDescription = bridgeDeckDamageSummaryTableWidth.DamageDescription
                , PictureNo         = bridgeDeckDamageSummaryTableWidth.PictureNo
                , Comment           = bridgeDeckDamageSummaryTableWidth.Comment
            };

            SuperSpaceStackPanel.DataContext = new SuperSpaceDamageSummaryTableWidth
            {
                No = superSpaceDamageSummaryTableWidth.No
                ,
                Position = superSpaceDamageSummaryTableWidth.PictureNo
                ,
                Component = superSpaceDamageSummaryTableWidth.Component
                ,
                Damage = superSpaceDamageSummaryTableWidth.Damage
                ,
                DamageDescription = superSpaceDamageSummaryTableWidth.DamageDescription
                ,
                PictureNo = superSpaceDamageSummaryTableWidth.PictureNo
                ,
                Comment = superSpaceDamageSummaryTableWidth.Comment
            };
            SubSpaceStackPanel.DataContext = new SubSpaceDamageSummaryTableWidth
            {
                No = subSpaceDamageSummaryTableWidth.No
                ,
                Position = subSpaceDamageSummaryTableWidth.PictureNo
                ,
                Component = subSpaceDamageSummaryTableWidth.Component
                ,
                Damage = subSpaceDamageSummaryTableWidth.Damage
                ,
                DamageDescription = subSpaceDamageSummaryTableWidth.DamageDescription
                ,
                PictureNo = subSpaceDamageSummaryTableWidth.PictureNo
                ,
                Comment = subSpaceDamageSummaryTableWidth.Comment
            };
        }
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            var frame = OptionContentControl.Content as Frame;

            var config = XDocument.Load($"{App.ConfigurationFolder}\\{App.ConfigFileName}");

            if ((string)OptionFrame.Tag == nameof(OptionPicturePage))
            {
                OptionPicturePage frameContent = (OptionPicturePage)frame.Content;
                OptionModel       model        = frameContent.DataContext as OptionModel;

                XElement pictureWidth = config.Elements("configuration").Elements("Picture").Elements("Width").FirstOrDefault();
                pictureWidth.Value = model.PictureWidth;
                XElement pictureHeight = config.Elements("configuration").Elements("Picture").Elements("Height").FirstOrDefault();
                pictureHeight.Value = model.PictureHeight;
                XElement pictureMaxCompressSize = config.Elements("configuration").Elements("Picture").Elements("MaxCompressSize").FirstOrDefault();
                pictureMaxCompressSize.Value = model.PictureMaxCompressSize;
                XElement pictureCompressQuality = config.Elements("configuration").Elements("Picture").Elements("CompressQuality").FirstOrDefault();
                pictureCompressQuality.Value = model.PictureCompressQuality;
            }
            else if ((string)OptionFrame.Tag == nameof(OptionBookmarkPage))
            {
                OptionBookmarkPage frameContent = (OptionBookmarkPage)frame.Content;
                OptionModel        model        = frameContent.DataContext as OptionModel;
                XElement           BridgeDeckBookmarkStartNo = config.Elements("configuration").Elements("Bookmark").Elements("BridgeDeckBookmarkStartNo").FirstOrDefault();
                XElement           SuperSpaceBookmarkStartNo = config.Elements("configuration").Elements("Bookmark").Elements("SuperSpaceBookmarkStartNo").FirstOrDefault();
                XElement           SubSpaceBookmarkStartNo   = config.Elements("configuration").Elements("Bookmark").Elements("SubSpaceBookmarkStartNo").FirstOrDefault();

                BridgeDeckBookmarkStartNo.Value = model.BridgeDeckBookmarkStartNo;
                SuperSpaceBookmarkStartNo.Value = model.SuperSpaceBookmarkStartNo;
                SubSpaceBookmarkStartNo.Value   = model.SubSpaceBookmarkStartNo;
            }
            else if ((string)OptionFrame.Tag == nameof(OptionSummaryTablePage))
            {
                //TODO:修改
                OptionSummaryTablePage            frameContent    = (OptionSummaryTablePage)frame.Content;
                BridgeDeckDamageSummaryTableWidth bridgeDeckModel = frameContent.BridgeDeckStackPanel.DataContext as BridgeDeckDamageSummaryTableWidth;
                SuperSpaceDamageSummaryTableWidth superSpaceModel = frameContent.SuperSpaceStackPanel.DataContext as SuperSpaceDamageSummaryTableWidth;
                SubSpaceDamageSummaryTableWidth   subSpaceModel   = frameContent.SubSpaceStackPanel.DataContext as SubSpaceDamageSummaryTableWidth;
                SetSummaryTableWidth(config, bridgeDeckModel, "BridgeDeckSummaryTable");
                SetSummaryTableWidth(config, superSpaceModel, "SuperSpaceSummaryTable");
                SetSummaryTableWidth(config, subSpaceModel, "SubSpaceSummaryTable");
            }

            else if ((string)OptionFrame.Tag == nameof(OptionGeneralPage))
            {
                //TODO:修改
                OptionGeneralPage frameContent = (OptionGeneralPage)frame.Content;
                var      model = frameContent.OptionGeneralPageStackPanel.DataContext as OptionReportGeneralSettings;
                XElement IntactStructNoInsertSummaryTable = config.Elements("configuration").Elements("General").Elements("IntactStructNoInsertSummaryTable").FirstOrDefault();
                IntactStructNoInsertSummaryTable.Value = model.IntactStructNoInsertSummaryTable.ToString(CultureInfo.InvariantCulture);
            }
            config.Save($"{App.ConfigurationFolder}\\{App.ConfigFileName}");
            _ = MessageBox.Show("保存设置成功!");

            void SetSummaryTableWidth(XDocument xDocument, BridgeDamageSummaryTableWidth model, string elementName)
            {
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("No").Value                = model.No.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("Position").Value          = model.Position.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("Component").Value         = model.Component.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("Damage").Value            = model.Damage.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("DamageDescription").Value = model.DamageDescription.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("PictureNo").Value         = model.PictureNo.ToString(CultureInfo.InvariantCulture);
                config.Elements("configuration").Elements(elementName).FirstOrDefault().Attribute("Comment").Value           = model.Comment.ToString(CultureInfo.InvariantCulture);
            }
        }