コード例 #1
0
ファイル: TestTest.cs プロジェクト: Bgoon/WinsCode
        public AutoCompleteSet GetAutoCompleteSet(AutoCompleteContext context)
        {
            try {
                string input = context.Input;

                //Get last black space substring of the input.
                for (int index = context.Input.Length - 1; index >= 0; --index)
                {
                    if (char.IsWhiteSpace(context.Input, index))
                    {
                        input = context.Input.Substring(index + 1);
                        break;
                    }
                }

                var prefix   = Path.GetFileName(input);
                var rootPath = Path.GetDirectoryName(Path.Combine(context.WorkingDirectory + '/', input));
                var root     = new DirectoryInfo(rootPath.Length == 0 ? Path.Combine(context.WorkingDirectory + '/', input) : rootPath);

                var files = from file in root.GetFiles()
                            where file.Name.StartsWith(prefix)
                            select file.Name.Substring(prefix.Length);

                var dirs = from dir in root.GetDirectories()
                           where dir.Name.StartsWith(prefix)
                           select dir.Name.Substring(prefix.Length);

                var list = files.Concat(dirs).ToList();

                if (files.Count() == 0 && dirs.Count() == 1)
                {
                    list[0] += '/';
                }

                return(new AutoCompleteSet(context, list));
            } catch {
                return(null);
            }
        }
コード例 #2
0
        private void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName, bool p1, bool p2)
        {
            _context = context;
            ICompletionData[] completionData = _context.CompletionProvider.GenerateCompletionData(fileName, _context.Editor.ActiveTextAreaControl.TextArea, _context.FirstChar);
            if (completionData == null || completionData.Length == 0)
            {
                _context = null;
                HideBox();
            }
            else
            {
                this.ImageList = _context.CompletionProvider.ImageList;

                int width = 0;
                this.Items.Clear();
                foreach (ICompletionData it in completionData)
                {
                    AutoCompletionListBoxItem litem = new AutoCompletionListBoxItem();
                    litem.Text       = it.Text;
                    litem.ImageIndex = it.ImageIndex;
                    litem.Tag        = it;

                    this.Items.Add(litem);
                    int length = TextRenderer.MeasureText(it.Text, this.Font).Width + 30; //For icon size
                    if (length > width)
                    {
                        width = length;
                    }
                }
                this.Width = width + 30;
                this.BringToFront();
                this.Show();
                this.IsShown = true;
                Point pt = _context.GetCaretPoint();
                this.Location = pt;
            }
        }
コード例 #3
0
ファイル: AutoCompletion.cs プロジェクト: kanbang/Colt
        private void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName, bool p1, bool p2)
        {
            _context = context;
            ICompletionData[] completionData = _context.CompletionProvider.GenerateCompletionData(fileName, _context.Editor.ActiveTextAreaControl.TextArea, _context.FirstChar);
            if (completionData == null || completionData.Length == 0)
            {
                _context = null;
                HideBox();
            }
            else
            {
                this.ImageList = _context.CompletionProvider.ImageList;

                int width = 0;
                this.Items.Clear();
                foreach (ICompletionData it in completionData)
                {
                    AutoCompletionListBoxItem litem = new AutoCompletionListBoxItem();
                    litem.Text = it.Text;
                    litem.ImageIndex = it.ImageIndex;
                    litem.Tag = it;

                    this.Items.Add(litem);
                    int length = TextRenderer.MeasureText(it.Text, this.Font).Width + 30; //For icon size
                    if (length > width)
                        width = length;
                }
                this.Width = width + 30;
                this.BringToFront();
                this.Show();
                this.IsShown = true;
                Point pt = _context.GetCaretPoint();
                this.Location = pt;
            }
        }
コード例 #4
0
ファイル: AutoCompletion.cs プロジェクト: kanbang/Colt
 internal void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName)
 {
     SetCompletionItems(parent, context, fileName, true, true);
 }
コード例 #5
0
 internal void SetCompletionItems(Form parent, AutoCompleteContext context, string fileName)
 {
     SetCompletionItems(parent, context, fileName, true, true);
 }