FileBrowserForm.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. using Uestc.Auto6.Dso.ComModel;
  10. using Uni_Trend.MSO7000X.UserControls;
  11. namespace Uestc.Auto6.Dso.U2
  12. {
  13. public partial class FileBrowserForm : Uni_Trend.MSO7000X.UserControls.FileBrowserForm
  14. {
  15. public static FileBrowserForm Instance { get; } = new FileBrowserForm();
  16. private FileBrowserForm()
  17. {
  18. StartPosition = FormStartPosition.CenterScreen;
  19. CanClose = false;
  20. IsShowPin = false;
  21. this.IsShowPin = FixedToolIconInfos[2].IsShow = false;
  22. SetFileTypeExtensionDelegate(new Func<Enum, string>(x => x.GetAlias()));
  23. }
  24. protected override void OnLoad(EventArgs e)
  25. {
  26. base.OnLoad(e);
  27. HeadBackColor = Color.FromArgb(62, 62, 62);
  28. }
  29. public override void SetFileFilter<T>(IEnumerable<T> fts)
  30. {
  31. if (!fts.Any())
  32. {
  33. EventBus.EventBroker.Instance.GetEvent<EventBus.LogEventArgs>().Publish(new Object(), new EventBus.LogEventArgs($"The arugmant '{nameof(fts)}' is empty or null in the function '{nameof(SetFileFilter)}'", EventBus.LogLevel.Error));
  34. #if DEBUG
  35. throw new ArgumentException(null, nameof(fts));
  36. #else
  37. return;
  38. #endif
  39. }
  40. ComboBoxEx cbxfiletype = base.GetFileTypeCb();
  41. cbxfiletype.DataSource = fts.Select(x => new KeyValuePair<String, T>(x.ToString() + $"(.{x.GetAlias()})", x)).ToList();
  42. cbxfiletype.DisplayMember = "Key";
  43. cbxfiletype.ValueMember = "Value";
  44. }
  45. }
  46. }