コード例 #1
0
        private void OnPathFound(string dotFile)
        {
            if (!File.Exists(dotFile))
            {
                MessageBox.Show("No paths found");
                return;
            }

            myDocumentLoader.Load(dotFile);
        }
コード例 #2
0
        public async Task <IDocument> OpenDocument(string fileName, string loaderHint = "")
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }

            if (IsOpen(fileName))
            {
                ActivateDocument(GetDocumentByFileName(fileName));
                return(null);
            }

            IDocumentLoader loader = null;

            if (!String.IsNullOrWhiteSpace(loaderHint))
            {
                loader = _loaders.FirstOrDefault(x => x.GetType().Name == loaderHint);
            }
            if (loader == null)
            {
                loader = _loaders.FirstOrDefault(x => x.CanLoad(fileName));
            }

            if (loader != null)
            {
                var doc = await loader.Load(fileName);

                if (doc != null)
                {
                    OpenDocument(doc);
                }
                return(doc);
            }

            return(null);
        }