コード例 #1
0
        private void menuItemImport_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openfiledlg = new OpenFileDialog();

            openfiledlg.InitialDirectory = "c:\\";
            openfiledlg.Filter           = "XAML(*.xaml)|*.xaml";
            openfiledlg.RestoreDirectory = true;
            if (openfiledlg.ShowDialog() == true)
            {
                System.IO.FileStream fStream;

                if (System.IO.File.Exists(openfiledlg.FileName))
                {
                    fStream = new System.IO.FileStream(openfiledlg.FileName, System.IO.FileMode.OpenOrCreate);
                    richTextBoxXaml.Document.Blocks.Clear();
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent             = true;
                    settings.OmitXmlDeclaration = true;
                    XamlDesignerSerializationManager designSerialization = new XamlDesignerSerializationManager(XmlWriter.Create(fStream, settings));
                    designSerialization.XamlWriterMode = XamlWriterMode.Expression;
                    StreamReader sr  = new StreamReader(fStream);
                    String       str = sr.ReadToEnd();
                    richTextBoxXaml.Document.Blocks.Add(XAMLParser.GetFomattedXAML(str));
                    richTextBoxXaml.ScrollToHome();
                    fStream.Close();
                    ImportXaml();
                }
            }
        }
コード例 #2
0
ファイル: UIObject.cs プロジェクト: DanielEverland/Mono-XAML
        internal UIObject(UserControl content)
        {
            _elements = new List <RenderableElement>();

            XAMLParser.Parse(content, this);
            XAMLManager.Instance.AddObject(this);
        }
コード例 #3
0
        /// <summary>
        /// Loads the XAML.
        /// </summary>
        void LoadXAML()
        {
            StringBuilder outputString = new StringBuilder();

            richTextBoxXaml.Document.Blocks.Clear();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.OmitXmlDeclaration = true;
            XamlDesignerSerializationManager designSerialization = new XamlDesignerSerializationManager(XmlWriter.Create(outputString, settings));

            designSerialization.XamlWriterMode = XamlWriterMode.Expression;
            XamlWriter.Save(this.ImageSourceContent, designSerialization);
            richTextBoxXaml.Document.Blocks.Add(XAMLParser.GetFomattedXAML(outputString.ToString()));
            richTextBoxXaml.ScrollToHome();
        }