示例#1
0
        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, () => ViewDesigner(document)));
            }
        }
示例#2
0
        void ViewCode(ITextDocument document)
        {
            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());
        }
示例#3
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(null)
        {
            this.package    = package;
            this.textBuffer = textBuffer;
            FileName        = fileName;

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

            SetupCommands();
        }