ScriptCompletionData.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Media.Imaging;
  7. namespace TeamAAS_VP.Core
  8. {
  9. /// <summary>
  10. /// C#成员类型
  11. /// </summary>
  12. public enum CoreMemberType
  13. {
  14. Field,
  15. Property,
  16. Void,
  17. Event,
  18. }
  19. /// <summary>
  20. /// Implements AvalonEdit ICompletionData interface to provide the entries in the completion drop down.
  21. /// </summary>
  22. public class ScriptCompletionData : ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData
  23. {
  24. public ScriptCompletionData(string text, CoreMemberType member)
  25. {
  26. this.Text = text;
  27. switch (member)
  28. {
  29. case CoreMemberType.Field:
  30. Image= new BitmapImage(new Uri("/Resources/Images/1field.png", UriKind.Relative));
  31. break;
  32. case CoreMemberType.Property:
  33. Image = new BitmapImage(new Uri("/Resources/Images/2property.png", UriKind.Relative));
  34. break;
  35. case CoreMemberType.Void:
  36. Image = new BitmapImage(new Uri("/Resources/Images/3void.png", UriKind.Relative));
  37. break;
  38. case CoreMemberType.Event:
  39. Image = new BitmapImage(new Uri("/Resources/Images/4event.png", UriKind.Relative));
  40. break;
  41. default:
  42. break;
  43. }
  44. }
  45. public System.Windows.Media.ImageSource Image { get;private set; }
  46. public string Text { get; private set; }
  47. // Use this property if you want to show a fancy UIElement in the drop down list.
  48. public object Content
  49. {
  50. get { return this.Text; }
  51. }
  52. public object Description
  53. {
  54. get { return "Description for " + this.Text; }
  55. }
  56. public double Priority { get { return 0; } }
  57. public void Complete(ICSharpCode.AvalonEdit.Editing.TextArea textArea, ICSharpCode.AvalonEdit.Document.ISegment completionSegment, EventArgs insertionRequestEventArgs)
  58. {
  59. textArea.Document.Replace(completionSegment, this.Text);
  60. }
  61. }
  62. }