Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hmemcpy committed May 21, 2015
1 parent 16bf529 commit 0857c83
Show file tree
Hide file tree
Showing 16 changed files with 1,022 additions and 6 deletions.
Binary file added lib/DotNetOpenAuth.dll
Binary file not shown.
Binary file added lib/TechSmith.Forms.dll
Binary file not shown.
Binary file added logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions src/SnagitImgur/Dialogs/AccountForm.Designer.cs

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

102 changes: 102 additions & 0 deletions src/SnagitImgur/Dialogs/AccountForm.cs
@@ -0,0 +1,102 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;
using SnagitImgur.Properties;

namespace SnagitImgur.Dialogs
{
public partial class AccountForm : Form
{
private readonly OAuthHelper oauthHelper;

public AccountForm(OAuthHelper oauthHelper)
{
this.oauthHelper = oauthHelper;

InitializeComponent();
}

private void AccountFormLoad(object sender, EventArgs e)
{
if (oauthHelper.IsAuthenticated)
{
ShowAccountDetails();
}
}

private void ShowAccountDetails()
{
lblAccountName.Text = oauthHelper.GetAccountName();
btnAuthenticate.Text = "&Sign Out";
btnAuthenticate.Tag = "sign_out";
}

private void btnAuthenticate_Click(object sender, EventArgs e)
{
string tag = (string)btnAuthenticate.Tag;
switch (tag)
{
case "sign_out":
oauthHelper.SignOut();
ShowAccountDetails();
break;
case "auth":
oauthHelper.OpenAuthorizationPage();
ShowPinCodePrompt();
break;
}
}

private void ShowPinCodePrompt()
{
using (var pinCodeForm = new PinCodeForm(oauthHelper))
{
if (pinCodeForm.ShowDialog() == DialogResult.OK)
{
ShowAccountDetails();
}
}
}
}

public class OAuthHelper
{
private readonly Settings settings;
private const string clientId = "d9c6c0bfd99b470";
private const string clientSecret = "";

public bool IsAuthenticated
{
get { return false; }
}

public string OAuthUrl { get; private set; }

public OAuthHelper(Settings settings)
{
this.settings = settings;
OAuthUrl = string.Format("https://api.imgur.com/oauth2/authorize?client_id={0}&response_type=pin&state=", clientId);
}


public string GetAccountName()
{
throw new NotImplementedException();
}

public void Authenticate(string pin)
{

}

public void SignOut()
{
throw new NotImplementedException();
}

public void OpenAuthorizationPage()
{
Process.Start(OAuthUrl);
}
}
}

0 comments on commit 0857c83

Please sign in to comment.