Exemple #1
0
        public void Open(string filename)
        {
            var document = FSolution.FindDocument(filename) as ITextDocument;

            if (document == null)
            {
                document = DocumentFactory.CreateDocumentFromFile(filename) as ITextDocument;
            }

            if (document != null)
            {
                OpenedFile           = filename;
                FEditor.TextDocument = document;
                AttachedProject      = document.Project;

                if (document is CSDocument)
                {
                    var csDoc = document as CSDocument;
                    FEditor.CompletionBinding  = new CSCompletionBinding(FEditor);
                    FEditor.FormattingStrategy = new CSFormattingStrategy(FEditor);
                    FEditor.FoldingStrategy    = new CSFoldingStrategy();
                    FEditor.LinkDataProvider   = new CSLinkDataProvider(FEditor);
                    FEditor.ToolTipProvider    = new CSToolTipProvider(FEditor);
                }
                else if (document is FXDocument)
                {
                    FEditor.CompletionBinding  = new FXCompletionBinding(FEditor);
                    FEditor.FormattingStrategy = new FXFormattingStrategy(FEditor);
                    FEditor.LinkDataProvider   = new FXLinkDataProvider(Path.GetDirectoryName(filename), Path.Combine(FHDEHost.ExePath, "lib", "nodes"));
                }

                document.ContentChanged += document_ContentChanged;
                document.Saved          += document_Saved;
                document.Renamed        += document_Renamed;
                document.Disposed       += document_Disposed;

                SynchronizationContext.Current.Post((o) => UpdateWindowCaption(document, document.Name), null);
            }
            else
            {
                FLogger.Log(LogType.Warning, "Can't open \0", filename);
            }
        }