Example #1
0
        public static XamlDocument FromFile(string fullPath)
        {
            if (File.Exists(fullPath))
            {
                string sourceText = File.ReadAllText(fullPath);

                XamlDocument document = null;

                if (sourceText.Contains("http://schemas.microsoft.com/winfx/2006/xaml/presentation"))
                {
                    document = new WpfDocument(Path.GetDirectoryName(fullPath), sourceText);
                }
                else
                {
                    document = new AgDocument(Path.GetDirectoryName(fullPath), sourceText);
                }


                document.FullPath = fullPath;
                return(document);
            }

            return(null);
        }
Example #2
0
        public bool SaveAs(XamlDocument document)
        {
            if (_SaveDialog == null)
            {
                _SaveDialog = new SaveFileDialog();
                _SaveDialog.AddExtension = true;
                _SaveDialog.DefaultExt = ".xaml";
                _SaveDialog.Filter = "XAML file|*.xaml|All files|*.*";
            }

            _SaveDialog.FileName = document.Filename;

            if ((bool)_SaveDialog.ShowDialog())
            {
                if (document.SaveAs(_SaveDialog.FileName))
                {
                    return true;
                }

                MessageBox.Show("The file could not be saved as " + _SaveDialog.FileName + ".");
                return false;
            }

            return false;
        }
Example #3
0
 public bool Save(XamlDocument document)
 {
     if (document.UsingTemporaryFilename)
     {
         return SaveAs(document);
     }
     else
     {
         return document.Save();
     }
 }
Example #4
0
 public void Close(XamlDocument document)
 {
 }