diff --git a/Steam Desktop Authenticator/ConfirmationForm.Designer.cs b/Steam Desktop Authenticator/ConfirmationForm.Designer.cs new file mode 100644 index 00000000..e4b6e9a0 --- /dev/null +++ b/Steam Desktop Authenticator/ConfirmationForm.Designer.cs @@ -0,0 +1,100 @@ +namespace Steam_Desktop_Authenticator +{ + using MetroFramework; + using MetroFramework.Forms; + + partial class ConfirmationForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.listConfirmations = new System.Windows.Forms.ListBox(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.btnAcceptConfirmation = new System.Windows.Forms.Button(); + this.btnDenyConfirmation = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listConfirmations + // + this.listConfirmations.FormattingEnabled = true; + this.listConfirmations.Items.AddRange(new object[] { + "test", + "test"}); + this.listConfirmations.Location = new System.Drawing.Point(23, 94); + this.listConfirmations.Name = "listConfirmations"; + this.listConfirmations.Size = new System.Drawing.Size(305, 134); + this.listConfirmations.TabIndex = 3; + this.listConfirmations.SelectedValueChanged += new System.EventHandler(this.listAccounts_SelectedValueChanged); + // + // btnAcceptConfirmation + // + this.btnAcceptConfirmation.Enabled = false; + this.btnAcceptConfirmation.Location = new System.Drawing.Point(23, 58); + this.btnAcceptConfirmation.Name = "btnAcceptConfirmation"; + this.btnAcceptConfirmation.Size = new System.Drawing.Size(138, 31); + this.btnAcceptConfirmation.TabIndex = 4; + this.btnAcceptConfirmation.Text = "Accept"; + this.btnAcceptConfirmation.UseVisualStyleBackColor = true; + this.btnAcceptConfirmation.Click += new System.EventHandler(this.btnAcceptConfirmation_Click); + // + // btnDenyConfirmation + // + this.btnDenyConfirmation.Location = new System.Drawing.Point(190, 58); + this.btnDenyConfirmation.Name = "btnDenyConfirmation"; + this.btnDenyConfirmation.Size = new System.Drawing.Size(138, 31); + this.btnDenyConfirmation.TabIndex = 5; + this.btnDenyConfirmation.Text = "Deny"; + this.btnDenyConfirmation.UseVisualStyleBackColor = true; + this.btnDenyConfirmation.Click += new System.EventHandler(this.btnDenyConfirmation_Click); + // + // ConfirmationForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(351, 247); + this.Controls.Add(this.btnDenyConfirmation); + this.Controls.Add(this.btnAcceptConfirmation); + this.Controls.Add(this.listConfirmations); + this.MaximizeBox = false; + this.Name = "ConfirmationForm"; + this.Resizable = false; + this.ShadowType = MetroFramework.Forms.MetroForm.MetroFormShadowType.SystemShadow; + this.Text = "Trade Confirmations"; + this.Load += new System.EventHandler(this.ConfirmationForm_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListBox listConfirmations; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Button btnAcceptConfirmation; + private System.Windows.Forms.Button btnDenyConfirmation; + } +} + diff --git a/Steam Desktop Authenticator/ConfirmationForm.cs b/Steam Desktop Authenticator/ConfirmationForm.cs new file mode 100644 index 00000000..af05e9c1 --- /dev/null +++ b/Steam Desktop Authenticator/ConfirmationForm.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using SteamAuth; +using System.Diagnostics; + +namespace Steam_Desktop_Authenticator +{ + public partial class ConfirmationForm : MetroFramework.Forms.MetroForm + { + private SteamGuardAccount mCurrentAccount; + + private Confirmation[] Confirmations; + private Confirmation mCurrentConfirmation = null; + + public ConfirmationForm(SteamGuardAccount account) + { + InitializeComponent(); + this.mCurrentAccount = account; + btnDenyConfirmation.Enabled = btnAcceptConfirmation.Enabled = false; + loadConfirmations(); + } + + private void listAccounts_SelectedValueChanged(object sender, EventArgs e) + { + mCurrentConfirmation = null; + + if (listConfirmations.SelectedIndex == -1) return; + + // Triggered when list item is clicked + for (int i = 0; i < Confirmations.Length; i++) + { + if (Confirmations[i].ConfirmationDescription == (string)listConfirmations.Items[listConfirmations.SelectedIndex]) + { + mCurrentConfirmation = Confirmations[i]; + } + } + btnDenyConfirmation.Enabled = btnAcceptConfirmation.Enabled = mCurrentConfirmation != null; + + } + + private void loadConfirmations() + { + listConfirmations.Items.Clear(); + listConfirmations.SelectedIndex = -1; + + Confirmations = mCurrentAccount.FetchConfirmations(); + if (Confirmations.Length > 0) + { + for (int i = 0; i < Confirmations.Length; i++) + { + listConfirmations.Items.Add(Confirmations[i].ConfirmationDescription); + } + } + } + + private void btnAcceptConfirmation_Click(object sender, EventArgs e) + { + if (mCurrentConfirmation == null) return; + bool success = mCurrentAccount.AcceptConfirmation(mCurrentConfirmation); + if (success) + { + MessageBox.Show("Confirmation successfully accepted."); + } + else + { + MessageBox.Show("Unable to accept confirmation."); + } + this.loadConfirmations(); + } + + private void btnDenyConfirmation_Click(object sender, EventArgs e) + { + if (mCurrentConfirmation == null) return; + bool success = mCurrentAccount.DenyConfirmation(mCurrentConfirmation); + if (success) + { + MessageBox.Show("Confirmation successfully denied."); + } + else + { + MessageBox.Show("Unable to deny confirmation."); + } + this.loadConfirmations(); + } + + private void ConfirmationForm_Load(object sender, EventArgs e) + { + + } + } +} diff --git a/Steam Desktop Authenticator/ConfirmationForm.resx b/Steam Desktop Authenticator/ConfirmationForm.resx new file mode 100644 index 00000000..1f666f26 --- /dev/null +++ b/Steam Desktop Authenticator/ConfirmationForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Steam Desktop Authenticator/MainForm.Designer.cs b/Steam Desktop Authenticator/MainForm.Designer.cs index 3bd06171..89bea8dd 100644 --- a/Steam Desktop Authenticator/MainForm.Designer.cs +++ b/Steam Desktop Authenticator/MainForm.Designer.cs @@ -82,7 +82,7 @@ private void InitializeComponent() this.txtLoginToken.TabIndex = 0; this.txtLoginToken.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // - // listAccounts + // listConfirmations // this.listAccounts.FormattingEnabled = true; this.listAccounts.Items.AddRange(new object[] { @@ -100,7 +100,7 @@ private void InitializeComponent() this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // btnTradeConfirmations + // btnAcceptConfirmation // this.btnTradeConfirmations.Enabled = false; this.btnTradeConfirmations.Location = new System.Drawing.Point(23, 185); @@ -111,7 +111,7 @@ private void InitializeComponent() this.btnTradeConfirmations.UseVisualStyleBackColor = true; this.btnTradeConfirmations.Click += new System.EventHandler(this.btnTradeConfirmations_Click); // - // btnDelete + // btnDenyConfirmation // this.btnDelete.Location = new System.Drawing.Point(190, 185); this.btnDelete.Name = "btnDelete"; diff --git a/Steam Desktop Authenticator/MainForm.cs b/Steam Desktop Authenticator/MainForm.cs index 183731e9..cc68818d 100644 --- a/Steam Desktop Authenticator/MainForm.cs +++ b/Steam Desktop Authenticator/MainForm.cs @@ -88,12 +88,15 @@ private void timer1_Tick(object sender, EventArgs e) loadAccountInfo(); if (mCurrentAccount != null) - pbTimeout.Value = secondsUntilChange; + pbTimeout.Value = 30 - secondsUntilChange; } private void btnTradeConfirmations_Click(object sender, EventArgs e) { + if (mCurrentAccount == null) return; + ConfirmationForm confirmations = new ConfirmationForm(mCurrentAccount); + confirmations.ShowDialog(); } private void btnDelete_Click(object sender, EventArgs e) diff --git a/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj b/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj index f91cc969..e3cc33b6 100644 --- a/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj +++ b/Steam Desktop Authenticator/Steam Desktop Authenticator.csproj @@ -74,6 +74,12 @@ LoginForm.cs + + Form + + + ConfirmationForm.cs + Form @@ -89,6 +95,9 @@ LoginForm.cs + + ConfirmationForm.cs + MainForm.cs