コード例 #1
0
ファイル: DataConvert.cs プロジェクト: MrChengM/BGFusion_Tool
        public static string ToString(ElementXaml elementXamls)
        {
            string outputstring = null;

            foreach (BgElementCommonXaml element in elementXamls.BgElementCommons)
            {
                if (outputstring == null)
                {
                    outputstring += element.ToString();
                }
                else
                {
                    outputstring += "\n" + element.ToString();
                }
            }
            foreach (BgTextBlock element in elementXamls.BgTextBlocks)
            {
                if (outputstring == null)
                {
                    outputstring += element.ToString();
                }
                else
                {
                    outputstring += "\n" + element.ToString();
                }
            }
            return(outputstring);
        }
コード例 #2
0
        /// <summary>
        /// WPF XAML数据输出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void XMLOutputbutton_Click(object sender, RoutedEventArgs e)
        {
            string sFileStyle = "WPF (.Xaml)|*.Xaml";
            string UIKey      = "XMLOutPutFilePathteBox";
            string UIKey1     = "OutPutDatasteBox";
            string UIKey2     = "L1raButton";
            string UIKey3     = "L2raButton";
            string UIKey4     = "TeBlackraButton";
            string UIKey5     = "ElementradioButton";
            string UIKey6     = "ViewNameteBox";
            string sFilePath  = UIdictionary[UIKey].MyString;

            UIdictionary[UIKey1].MyString = "";
            try
            {
                bool bOpenEnable = Outputfile(ref sFilePath, sFileStyle);
                if (bOpenEnable == true)
                {
                    BaseFactory factory = new BaseFactory();
                    factory.BaseParameter = CreateConvertParameter();
                    XamlData Data = (XamlData)factory.CreatDataClass("XamlData");
                    CreateDataMath <BgElementCommonXaml, ConveyorRow> bgXmalMath;
                    CreateDataMath <BgTextBlock, ConveyorRow>         blockTextMath;

                    List <BgElementCommonXaml> bgXamlGroup    = new List <BgElementCommonXaml>();
                    List <BgTextBlock>         textBlockGroup = new List <BgTextBlock>();

                    if (UIdictionary[UIKey2].Mybool == true)
                    {
                        bgXmalMath  = Data.CreatL1CommonXaml12307;
                        bgXamlGroup = Data.CreateList(bgXmalMath);
                    }
                    else if (UIdictionary[UIKey3].Mybool == true)
                    {
                        if (UIdictionary[UIKey5].Mybool == true)
                        {
                            bgXmalMath  = Data.CreatL2CommonXaml;
                            bgXamlGroup = Data.CreateList(bgXmalMath);
                        }
                        else if (UIdictionary[UIKey4].Mybool == true)
                        {
                            blockTextMath  = Data.CreatTextBlock;
                            textBlockGroup = Data.CreateList(blockTextMath);
                        }
                    }
                    ElementXaml elementXaml = new ElementXaml(bgXamlGroup, textBlockGroup, UIdictionary[UIKey6].MyString);
                    XmlSerialiaztion.XmlSerial(@sFilePath, elementXaml);
                    UIdictionary[UIKey].MyString  = sFilePath;
                    UIdictionary[UIKey1].MyString = "Build Xaml Successful!";
                    //System.IO.File.WriteAllText(@sFilePath, UIdictionary[UIKey1].MyString, Encoding.UTF8);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Build XML Data Error: " + ex.Message);
            }
            GC.Collect();
        }