Beispiel #1
0
        private void OpenDocument(string path)
        {
            var presentation = PresentationCreationService.CreatePresentation(Path.GetDirectoryName(path));

            var processor = new BasicDocumentProcessor(presentation);

            processor.Process(path);

            if (processor.FailedItems.Any())
            {
                var sb = new StringBuilder();
                sb.AppendLine("Following items could not be loaded successfully:");
                sb.AppendLine();
                foreach (var item in processor.FailedItems)
                {
                    sb.AppendLine(string.Format("{0}: {1}", item.FailureReason, item.Item));
                }
                StatusMessageService.Publish(new StatusMessage(sb.ToString()));
            }

            Model.Presentation = presentation;

            myFileWatcher        = new FileSystemWatcher();
            myFileWatcher.Path   = Path.GetDirectoryName(path);
            myFileWatcher.Filter = Path.GetFileName(path);
            // http://stackoverflow.com/questions/19905151/system-io-filesystemwatcher-does-not-watch-file-changed-by-visual-studio-2013
            myFileWatcher.NotifyFilter        = NotifyFilters.LastWrite | NotifyFilters.CreationTime;
            myFileWatcher.Changed            += OnCurrentFileChanged;
            myFileWatcher.Error              += OnFileWatcherError;
            myFileWatcher.EnableRaisingEvents = true;

            // only synchronize presentations where we know the doc type and which were created from this module
            if (Path.GetExtension(path).Equals(".dot", StringComparison.OrdinalIgnoreCase))
            {
                myGraphToDotSynchronizer.Attach(presentation, p =>
                                                // enqueue to have less blocking of UI
                                                Application.Current.Dispatcher.BeginInvoke(new Action(() => SyncToDocument(p, path))));
            }
        }
        private void Open( string path )
        {
            var presentation = PresentationCreationService.CreatePresentation( Path.GetDirectoryName( path ) );

            var processor = new BasicDocumentProcessor( presentation );
            //processor.DocumentCreators[ ".dot" ] = () => new DotLangDocument( new DotToDotPlainConverter( myConfig.DotToolsHome ) );
            processor.DocumentCreators[ ".dot" ] = () => new DotLangPureDocument();

            processor.Process( path );

            if( processor.FailedItems.Any() )
            {
                var sb = new StringBuilder();
                sb.AppendLine( "Following items could not be loaded successfully:" );
                sb.AppendLine();
                foreach( var item in processor.FailedItems )
                {
                    sb.AppendLine( string.Format( "{0}: {1}", item.FailureReason, item.Item ) );
                }
                StatusMessageService.Publish( new StatusMessage( sb.ToString() ) );
            }

            Model.Presentation = presentation;

            if( myFileWatcher != null )
            {
                myFileWatcher.Dispose();
                myFileWatcher = null;
            }

            myFileWatcher = new FileSystemWatcher();
            myFileWatcher.Path = Path.GetDirectoryName( path );
            myFileWatcher.Filter = Path.GetFileName( path );
            myFileWatcher.NotifyFilter = NotifyFilters.LastWrite;
            myFileWatcher.Changed += OnCurrentFileChanged;
            myFileWatcher.EnableRaisingEvents = true;
        }
        private void Open( string path )
        {
            var presentation = PresentationCreationService.CreatePresentation( Path.GetDirectoryName( path ) );

            var processor = new BasicDocumentProcessor( presentation );
            //processor.DocumentCreators[ ".dot" ] = () => new DotLangDocument( new DotToDotPlainConverter( myConfig.DotToolsHome ) );
            processor.DocumentCreators[ ".dot" ] = () => new DotLangPureDocument();

            processor.Process( path );

            if ( processor.FailedItems.Any() )
            {
                var sb = new StringBuilder();
                sb.AppendLine( "Following items could not be loaded successfully:" );
                sb.AppendLine();
                foreach ( var item in processor.FailedItems )
                {
                    sb.AppendLine( string.Format( "{0}: {1}", item.FailureReason, item.Item ) );
                }
                StatusMessageService.Publish( new StatusMessage( sb.ToString() ) );
            }

            Model.Presentation = presentation;
        }