コード例 #1
0
        public void DisplaySource(
            string sourceFilePath,
            string text,
            int lineNumber    = 0,
            int column        = 0,
            Action preprocess = null,
            NavigationHelper navigationHelper = null,
            bool displayPath = true)
        {
            var existing = Find(sourceFilePath);

            if (existing != null)
            {
                IsVisible = true;
                tabControl.SelectedItem = existing;
                var textViewer = existing.Content;
                if (textViewer != null)
                {
                    textViewer.SetPathDisplay(displayPath);

                    if (textViewer.Text != text)
                    {
                        textViewer.SetText(text);
                    }

                    textViewer.DisplaySource(lineNumber, column);
                }

                return;
            }

            var textViewerControl = new TextViewerControl();

            textViewerControl.DisplaySource(sourceFilePath, text, lineNumber, column, preprocess, navigationHelper);
            var tab = new SourceFileTab
            {
                FilePath = sourceFilePath,
                Content  = textViewerControl,
            };

            tab.CloseRequested += t => Tabs.Remove(t);
            textViewerControl.SetPathDisplay(displayPath);

            Tabs.Add(tab);
            tabControl.SelectedItem = tab;
        }
コード例 #2
0
        public void DisplaySource(string sourceFilePath, string text, int lineNumber = 0, int column = 0, Action preprocess = null, bool displayPath = true)
        {
            var existing = Find(sourceFilePath);

            if (existing != null)
            {
                IsVisible = true;
                tabControl.SelectedItem = existing;
                var textViewer = existing.Content as TextViewerControl;
                if (textViewer != null)
                {
                    textViewer.SetPathDisplay(displayPath);

                    if (textViewer.Text != text)
                    {
                        textViewer.SetText(text);
                    }

                    textViewer.DisplaySource(lineNumber, column);
                }

                return;
            }

            var textViewerControl = new TextViewerControl();

            textViewerControl.DisplaySource(sourceFilePath, text, lineNumber, column, preprocess);
            var tab = new SourceFileTab()
            {
                FilePath = sourceFilePath,
                Text     = text,
                Content  = textViewerControl,
            };
            var header = new SourceFileTabHeader(tab);

            tab.Header             = header;
            header.CloseRequested += t => Tabs.Remove(t);
            // TODO: template
            //tab.HeaderTemplate = (DataTemplate)Application.Current.Resources["SourceFileTabHeaderTemplate"];
            textViewerControl.SetPathDisplay(displayPath);

            Tabs.Add(tab);
            tabControl.SelectedItem = tab;
        }