コード例 #1
0
ファイル: FileController.cs プロジェクト: zheng1748/wpf
        /// <summary>
        /// <see cref="MS.Internal.Documents.Application.IDocumentController"/>
        /// </summary>
        bool IDocumentController.Rebind(Document document)
        {
            FileDocument doc = (FileDocument)document;

            if (doc.IsRebindNeeded)
            {
                doc.SourceProxy.Close();
                doc.SourceProxy = null;

                try
                {
                    doc.SourceProxy = DocumentStream.Open(doc, false);
                }
                catch (UnauthorizedAccessException uae)
                {
                    FilePresentation.ShowNoAccessToSource();
                    doc.SourceProxy = null;

                    Trace.SafeWrite(
                        Trace.File,
                        "Unable to reopen specified location.\nException: {0}",
                        uae);

                    return(false);
                }
                catch (IOException ioe)
                {
                    FilePresentation.ShowNoAccessToSource();
                    doc.SourceProxy = null;

                    Trace.SafeWrite(
                        Trace.File,
                        "Unable to reopen specified location.\nException: {0}",
                        ioe);

                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: FileController.cs プロジェクト: zheng1748/wpf
        /// <summary>
        /// <see cref="MS.Internal.Documents.Application.IDocumentController"/>
        /// </summary>
        bool IDocumentController.Open(Document document)
        {
            FileDocument doc = (FileDocument)document;

            if (doc.Source == null)
            {
                try
                {
                    doc.SourceProxy = DocumentStream.Open(doc, false);
                }
                catch (UnauthorizedAccessException uae)
                {
                    FilePresentation.ShowNoAccessToSource();
                    doc.SourceProxy = null;

                    Trace.SafeWrite(
                        Trace.File,
                        "Unable to open specified location.\nException: {0}",
                        uae);

                    return(false);
                }
                catch (IOException ioe)
                {
                    FilePresentation.ShowNoAccessToSource();
                    doc.SourceProxy = null;

                    Trace.SafeWrite(
                        Trace.File,
                        "Unable to open specified location.\nException: {0}",
                        ioe);

                    return(false);
                }
            }

            DocumentProperties.InitializeCurrentDocumentProperties(doc.Uri);

            return(true);
        }