Beispiel #1
0
        void ViewCode(ITextDocument document)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            var builderInfo = BuilderInfo.Find(document.FilePath);

            if (builderInfo == null)
            {
                return;
            }
            var codeFile = builderInfo.GetCodeFile(document.FilePath);

            if (!File.Exists(codeFile))
            {
                return;
            }

            IVsWindowFrame frame;
            IVsUIHierarchy hierarchy;
            uint           itemid;

            if (!VsShellUtilities.IsDocumentOpen(ServiceProvider, codeFile, VSConstants.LOGVIEWID.Primary_guid, out hierarchy, out itemid, out frame) &&
                !VsShellUtilities.IsDocumentOpen(ServiceProvider, codeFile, VSConstants.LOGVIEWID.TextView_guid, out hierarchy, out itemid, out frame))
            {
                VsShellUtilities.OpenDocumentWithSpecificEditor(ServiceProvider, codeFile, VSConstants.VsEditorFactoryGuid.TextEditor_guid, VSConstants.LOGVIEWID.Primary_guid, out hierarchy, out itemid, out frame);
            }
            ErrorHandler.ThrowOnFailure(frame.Show());
        }
Beispiel #2
0
        /// <summary>
        /// Constructor that calls the Microsoft.VisualStudio.Shell.WindowPane constructor then
        /// our initialization functions.
        /// </summary>
        /// <param name="package">Our Package instance.</param>
        public EtoPreviewPane(EtoPreviewPackage package, string fileName, IVsTextLines textBuffer)
            : base(package)
        {
            this.package    = package;
            this.textBuffer = textBuffer;
            FileName        = fileName;

            builderInfo = BuilderInfo.Find(fileName);
            if (builderInfo == null)
            {
                throw new InvalidOperationException(string.Format("Could not find builder for file {0}", fileName));
            }
            builder = builderInfo.CreateBuilder();

            editorControl  = new Panel();
            previewControl = new Panel();

            var split = new Splitter {
                Panel1 = previewControl, Panel2 = editorControl, Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, RelativePosition = 0.5
            };
            var native = split.ToNative(true);

            host.Child = native;

            control = split;
        }
Beispiel #3
0
        //static readonly object ViewCodeKey = new object();

        public void TextViewCreated(IWpfTextView textView)
        {
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }

            var info = BuilderInfo.Find(document.FilePath);

            if (info != null)
            {
                // add commands to view form or code
                //textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesigner(document)));
                //textView.Properties.AddProperty(ViewCodeKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewCode, () => ViewCode(document)));
                if (string.Equals(info.Extension, ".xeto", StringComparison.OrdinalIgnoreCase))
                {
                    textView.Properties.GetOrCreateSingletonProperty(() => new XamlCompletionHandler(textViewAdapter, textView, this));
                }
            }
            else if (BuilderInfo.IsCodeBehind(document.FilePath))
            {
                textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => {
                    Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
                    ViewDesigner(document);
                }));
            }
        }