USB.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Uestc.Auto6.Dso.Core;
  7. using Uestc.Auto6.Dso.ComModel;
  8. using System.Drawing;
  9. using Uestc.Auto6.Dso.Core.Decode;
  10. using System.Windows.Forms;
  11. using Uni_Trend.MSO7000X.Common.Helper;
  12. namespace Uestc.Auto6.Dso.Protocol.USB
  13. {
  14. internal class USB : DecodeView
  15. {
  16. public override IProtocolView ProtocolView => new USBSetControl();
  17. public override ITriggerSerialView TriggerSerialView => new USBTriggerSetControl();
  18. public override SerialProtocolType ProtocolType => SerialProtocolType.USB;
  19. public override void DrawDecodeInfo(Graphics graphics, Rectangle rectangle, IProtocolPrsnt prsnt, Color ForeColor, Font font)
  20. {
  21. if (prsnt is USBDecodePrsnt decodePrsnt)
  22. {
  23. TextRenderer.DrawText(graphics, decodePrsnt.SignalRate switch
  24. {
  25. ProtocolUSB.SignalRate.LowRate => "USB 1.0",
  26. ProtocolUSB.SignalRate.FullRate => "USB 1.1",
  27. ProtocolUSB.SignalRate.HighRate => "USB 2.0",
  28. _ => "USB 1.0",
  29. }, font, GetRowRectangle(0), ForeColor, TextFormatFlags.Right | TextFormatFlags.VerticalCenter);
  30. TextRenderer.DrawText(graphics, $"{decodePrsnt.Source1}->{SIHelper.ValueChangeToSI(decodePrsnt.Source1Threshold, 2, "V")}", font, GetRowRectangle(1), ForeColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
  31. TextRenderer.DrawText(graphics, $"{decodePrsnt.Source2}->{SIHelper.ValueChangeToSI(decodePrsnt.Source2Threshold, 2, "V")}", font, GetRowRectangle(2), ForeColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
  32. }
  33. }
  34. }
  35. }