TradePopupForm.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using SteamAuth;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace Steam_Desktop_Authenticator
  12. {
  13. public partial class TradePopupForm : Form
  14. {
  15. private SteamGuardAccount acc;
  16. private List<Confirmation> confirms = new List<Confirmation>();
  17. private bool deny2, accept2;
  18. public TradePopupForm()
  19. {
  20. InitializeComponent();
  21. lblStatus.Text = "";
  22. }
  23. public SteamGuardAccount Account
  24. {
  25. get { return acc; }
  26. set { acc = value; lblAccount.Text = acc.AccountName; }
  27. }
  28. public Confirmation[] Confirmations
  29. {
  30. get { return confirms.ToArray(); }
  31. set { confirms = new List<Confirmation>(value); }
  32. }
  33. private void TradePopupForm_Load(object sender, EventArgs e)
  34. {
  35. this.Location = (Point)Size.Subtract(Screen.GetWorkingArea(this).Size, this.Size);
  36. }
  37. private void btnAccept_Click(object sender, EventArgs e)
  38. {
  39. if (!accept2)
  40. {
  41. // Allow user to confirm first
  42. lblStatus.Text = "Press Accept again to confirm";
  43. btnAccept.BackColor = Color.FromArgb(128, 255, 128);
  44. accept2 = true;
  45. }
  46. else
  47. {
  48. lblStatus.Text = "Accepting...";
  49. acc.AcceptConfirmation(confirms[0]);
  50. confirms.RemoveAt(0);
  51. Reset();
  52. }
  53. }
  54. private void btnDeny_Click(object sender, EventArgs e)
  55. {
  56. if (!deny2)
  57. {
  58. lblStatus.Text = "Press Deny again to confirm";
  59. btnDeny.BackColor = Color.FromArgb(255, 255, 128);
  60. deny2 = true;
  61. }
  62. else
  63. {
  64. lblStatus.Text = "Denying...";
  65. acc.DenyConfirmation(confirms[0]);
  66. confirms.RemoveAt(0);
  67. Reset();
  68. }
  69. }
  70. private void Reset()
  71. {
  72. deny2 = false;
  73. accept2 = false;
  74. btnAccept.BackColor = Color.FromArgb(192, 255, 192);
  75. btnDeny.BackColor = Color.FromArgb(255, 255, 192);
  76. btnAccept.Text = "Accept";
  77. btnDeny.Text = "Deny";
  78. lblAccount.Text = "";
  79. lblStatus.Text = "";
  80. if (confirms.Count == 0)
  81. {
  82. this.Hide();
  83. }
  84. else
  85. {
  86. //TODO: Re-add confirmation description support to SteamAuth.
  87. lblDesc.Text = "Confirmation";
  88. }
  89. }
  90. public void Popup()
  91. {
  92. Reset();
  93. this.Show();
  94. }
  95. }
  96. }