예제 #1
0
        void ShowCompletionWindow(object param, int beginCaretIndex)
        {
            if (!Kaxaml.Properties.Settings.Default.EnableCodeCompletion)
            {
                return;
            }

            if (!CodeCompletionPopup.IsOpenSomewhere)
            {
                _BeginCaretIndex = beginCaretIndex;

                if (param is char)
                {
                    char ch = (char)param;

                    if (IsCodeCompletionEnabled)
                    {
                        if (ch == char.MaxValue)
                        {
                            if ((App.Current as App).Snippets != null)
                            {
                                ArrayList s = (App.Current as App).Snippets.GetSnippetCompletionItems();

                                if (s.Count > 0)
                                {
                                    this.Dispatcher.BeginInvoke(
                                        System.Windows.Threading.DispatcherPriority.ApplicationIdle,
                                        new OneArgDelegate(ShowCompletionWindowUI),
                                        s);
                                }
                            }
                        }
                        else
                        {
                            XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider();

                            ICollection c = completionDataProvider.GenerateCompletionData("", TextEditor.ActiveTextAreaControl.TextArea, ch);

                            if (c != null)
                            {
                                ArrayList items = new ArrayList(c);
                                items.Sort();

                                this.Dispatcher.BeginInvoke(
                                    System.Windows.Threading.DispatcherPriority.ApplicationIdle,
                                    new OneArgDelegate(ShowCompletionWindowUI),
                                    items);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        public void SetUpFixture()
        {
            Form parentForm = new Form();

            parentForm.CreateControl();

            XmlSchemaCompletionData           schema  = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema());
            XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();

            schemas.Add(schema);
            provider = new XmlCompletionDataProvider(schemas, schema, String.Empty);
            TextEditorControl textEditor = new TextEditorControl();

            completionDataItems = provider.GenerateCompletionData(@"C:\Test.xml", textEditor.ActiveTextAreaControl.TextArea, '<');
            using (CodeCompletionWindow completionWindow = CodeCompletionWindow.ShowCompletionWindow(parentForm, textEditor, @"C:\Test.xml", provider, '<')) {
                CodeCompletionListView listView = (CodeCompletionListView)completionWindow.Controls[0];
                selectedCompletionData = listView.SelectedCompletionData;
                completionWindow.Close();
            }
        }