Skip to content

Commit

Permalink
Add Trade Confirmations form
Browse files Browse the repository at this point in the history
  • Loading branch information
geel9 committed Nov 27, 2015
1 parent 8c17ca7 commit 39884a1
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 4 deletions.
100 changes: 100 additions & 0 deletions Steam Desktop Authenticator/ConfirmationForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions Steam Desktop Authenticator/ConfirmationForm.cs
Original file line number Diff line number Diff line change
@@ -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)
{

}
}
}
123 changes: 123 additions & 0 deletions Steam Desktop Authenticator/ConfirmationForm.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
6 changes: 3 additions & 3 deletions Steam Desktop Authenticator/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Steam Desktop Authenticator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<Compile Include="LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon>
</Compile>
<Compile Include="ConfirmationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConfirmationForm.Designer.cs">
<DependentUpon>ConfirmationForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -89,6 +95,9 @@
<EmbeddedResource Include="LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ConfirmationForm.resx">
<DependentUpon>ConfirmationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down

0 comments on commit 39884a1

Please sign in to comment.