Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
 public bool Save(XamlDocument document)
 {
     if (document.UsingTemporaryFilename)
     {
         return SaveAs(document);
     }
     else
     {
         return document.Save();
     }
 }
Exemplo n.º 4
0
 public void Close(XamlDocument document)
 {
 }