ShareX/UploadersLib/GUI/OAuth2Control.cs
2014-01-12 09:25:51 +02:00

137 lines
3.7 KiB
C#

#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (C) 2008-2014 ShareX Developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace UploadersLib.GUI
{
public partial class OAuth2Control : UserControl
{
public delegate void OpenButtonClickedEventHandler();
public event OpenButtonClickedEventHandler OpenButtonClicked;
public delegate void CompleteButtonClickedEventHandler(string code);
public event CompleteButtonClickedEventHandler CompleteButtonClicked;
public delegate void RefreshButtonClickedEventHandler();
public event RefreshButtonClickedEventHandler RefreshButtonClicked;
public string Status
{
get
{
return lblLoginStatus.Text;
}
set
{
lblLoginStatus.Text = value;
}
}
private bool loginStatus;
public bool LoginStatus
{
get
{
return loginStatus;
}
set
{
loginStatus = value;
btnRefreshAuthorization.Enabled = loginStatus;
}
}
private bool isRefreshable;
[DefaultValue(true)]
public bool IsRefreshable
{
get
{
return isRefreshable;
}
set
{
isRefreshable = value;
if (isRefreshable)
{
gbUserAccount.Size = new Size(320, 200);
}
else
{
gbUserAccount.Size = new Size(320, 165);
}
btnRefreshAuthorization.Visible = isRefreshable;
}
}
public OAuth2Control()
{
InitializeComponent();
IsRefreshable = true;
}
private void btnOpenAuthorizePage_Click(object sender, EventArgs e)
{
if (OpenButtonClicked != null)
{
OpenButtonClicked();
}
}
private void txtVerificationCode_TextChanged(object sender, EventArgs e)
{
btnCompleteAuthorization.Enabled = !string.IsNullOrEmpty(txtVerificationCode.Text);
}
private void btnCompleteAuthorization_Click(object sender, EventArgs e)
{
string code = txtVerificationCode.Text;
if (CompleteButtonClicked != null && !string.IsNullOrEmpty(code))
{
CompleteButtonClicked(code);
}
}
private void btnRefreshAuthorization_Click(object sender, EventArgs e)
{
if (RefreshButtonClicked != null)
{
RefreshButtonClicked();
}
}
}
}