public override bool HandleKeyPress(SharpDevelopTextAreaControl editor, char ch)
        {
            if (this.CompletionPossible(editor, ch))
            {
                ResourceResolveResult result = ResourceResolverService.Resolve(editor, ch);
                if (result != null)
                {
                    IResourceFileContent content;
                    if ((content = result.ResourceFileContent) != null)
                    {
                        // If the resolved resource set is the local ICSharpCode.Core resource set
                        // (this may happen through the ICSharpCodeCoreNRefactoryResourceResolver),
                        // we will have to merge in the host resource set (if available)
                        // for the code completion window.
                        if (result.ResourceSetReference.ResourceSetName == ICSharpCodeCoreResourceResolver.ICSharpCodeCoreLocalResourceSetName)
                        {
                            IResourceFileContent hostContent = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent;
                            if (hostContent != null)
                            {
                                content = new MergedResourceFileContent(content, new IResourceFileContent[] { hostContent });
                            }
                        }

                        editor.ShowCompletionWindow(new ResourceCodeCompletionDataProvider(content, this.OutputVisitor, result.CallingClass != null ? result.CallingClass.Name + "." : null), ch);
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
        public override bool HandleKeyPress(SharpDevelopTextAreaControl editor, char ch)
        {
            if (ch == ':')
            {
                if (editor.ActiveTextAreaControl.Caret.Offset >= 5 && editor.Document.GetText(editor.ActiveTextAreaControl.Caret.Offset - 5, 5) == "${res")
                {
                    IResourceFileContent content = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreLocalResourceSet(editor.FileName).ResourceFileContent;
                                        #if DEBUG
                    if (content != null)
                    {
                        LoggingService.Debug("ResourceToolkit: Found local ICSharpCode.Core resource file: " + content.FileName);
                    }
                                        #endif

                    IResourceFileContent hostContent = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent;
                    if (hostContent != null)
                    {
                                                #if DEBUG
                        LoggingService.Debug("ResourceToolkit: Found host ICSharpCode.Core resource file: " + hostContent.FileName);
                                                #endif
                        if (content != null)
                        {
                            content = new MergedResourceFileContent(content, new IResourceFileContent[] { hostContent });
                        }
                        else
                        {
                            content = hostContent;
                        }
                    }

                    if (content != null)
                    {
                        editor.ShowCompletionWindow(new ResourceCodeCompletionDataProvider(content, null, null), ch);
                        return(true);
                    }
                }
            }
            else if (ch == '$')
            {
                // Provide ${res: as code completion
                // in an ICSharpCode.Core application
                if (ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent != null ||
                    ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreLocalResourceSet(editor.FileName).ResourceFileContent != null)
                {
                    editor.ShowCompletionWindow(new ICSharpCodeCoreTagCompletionDataProvider(), ch);
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
        {
            if (ch == ':')
            {
                if (editor.Caret.Offset >= 5 && editor.Document.GetText(editor.Caret.Offset - 5, 5) == "${res")
                {
                    IResourceFileContent content = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreLocalResourceSet(editor.FileName).ResourceFileContent;
                                        #if DEBUG
                    if (content != null)
                    {
                        LoggingService.Debug("ResourceToolkit: Found local ICSharpCode.Core resource file: " + content.FileName);
                    }
                                        #endif

                    IResourceFileContent hostContent = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent;
                    if (hostContent != null)
                    {
                                                #if DEBUG
                        LoggingService.Debug("ResourceToolkit: Found host ICSharpCode.Core resource file: " + hostContent.FileName);
                                                #endif
                        if (content != null)
                        {
                            content = new MergedResourceFileContent(content, new IResourceFileContent[] { hostContent });
                        }
                        else
                        {
                            content = hostContent;
                        }
                    }

                    if (content != null)
                    {
                        editor.ShowCompletionWindow(new ResourceCodeCompletionItemList(content, null, null));
                        return(CodeCompletionKeyPressResult.Completed);
                    }
                }
            }
            else if (ch == '$')
            {
                // Provide ${res: as code completion
                // in an ICSharpCode.Core application
                if (ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent != null ||
                    ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreLocalResourceSet(editor.FileName).ResourceFileContent != null)
                {
                    editor.ShowCompletionWindow(new ICSharpCodeCoreTagCompletionItemList(editor));
                    return(CodeCompletionKeyPressResult.Completed);
                }
            }

            return(CodeCompletionKeyPressResult.None);
        }
        public override void Run()
        {
            base.Run();

            IFilterHost <ResourceItem> host = ((ToolBarCheckBox)this.Owner).Caller as IFilterHost <ResourceItem>;

            if (host != null)
            {
                if (this.IsChecked)
                {
                    this.icSharpCodeCoreHostResourceFileName = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(null).FileName;
                    host.RegisterFilter(this);
                }
                else
                {
                    host.UnregisterFilter(this);
                }
            }
        }