1 Star 0 Fork 0

Yongbo/winauth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
Authenticator
Net3.5
Net4.5
Third Party
WinAuth.YubiKey
WinAuth
Properties
Resources
AboutForm.Designer.cs
AboutForm.cs
AboutForm.resources
AboutForm.resx
AddAuthenticator.cs
AddAuthenticator.designer.cs
AddAuthenticator.resx
AddBattleNetAuthenticator.Designer.cs
AddBattleNetAuthenticator.cs
AddBattleNetAuthenticator.resx
AddGoogleAuthenticator.Designer.cs
AddGoogleAuthenticator.cs
AddGoogleAuthenticator.resx
AddGuildWarsAuthenticator.Designer.cs
AddGuildWarsAuthenticator.cs
AddGuildWarsAuthenticator.resx
AddMicrosoftAuthenticator.Designer.cs
AddMicrosoftAuthenticator.cs
AddMicrosoftAuthenticator.resx
AddOktaVerifyAuthenticator.Designer.cs
AddOktaVerifyAuthenticator.cs
AddOktaVerifyAuthenticator.resx
AddSteamAuthenticator.cs
AddSteamAuthenticator.designer.cs
AddSteamAuthenticator.resx
AddTrionAuthenticator.Designer.cs
AddTrionAuthenticator.cs
AddTrionAuthenticator.resx
AuthenticatorListBox.cs
BetaForm.Designer.cs
BetaForm.cs
BetaForm.resources
BetaForm.resx
ChangePasswordForm.Designer.cs
ChangePasswordForm.cs
ChangePasswordForm.resx
DiagnosticForm.cs
DiagnosticForm.designer.cs
DiagnosticForm.resx
ExceptionForm.cs
ExceptionForm.designer.cs
ExceptionForm.resx
ExportForm.Designer.cs
ExportForm.cs
ExportForm.resx
GetPGPKeyForm.cs
GetPGPKeyForm.designer.cs
GetPGPKeyForm.resx
GetPasswordForm.cs
GetPasswordForm.designer.cs
GetPasswordForm.resx
GroupRadioButton.cs
HotKey.cs
HotKeySequence.cs
ILMerge.exe
ISecretTextBox.cs
ImportException.cs
Keyboard.cs
Notification.Designer.cs
Notification.cs
Notification.resx
PasswordForm.resources
RegisteredAuthenticator.cs
ResourceForm.cs
SecretTextBox.cs
SetPasswordForm.Designer.cs
SetPasswordForm.cs
SetPasswordForm.resx
SetShortcutKeyForm.Designer.cs
SetShortcutKeyForm.cs
SetShortcutKeyForm.resx
ShowRestoreCodeForm.Designer.cs
ShowRestoreCodeForm.cs
ShowRestoreCodeForm.resources
ShowRestoreCodeForm.resx
ShowSecretKeyForm.Designer.cs
ShowSecretKeyForm.cs
ShowSecretKeyForm.resources
ShowSecretKeyForm.resx
ShowSteamSecretForm.cs
ShowSteamSecretForm.designer.cs
ShowSteamSecretForm.resx
ShowSteamTradesForm.cs
ShowSteamTradesForm.designer.cs
ShowSteamTradesForm.resx
ShowTrionSecretForm.Designer.cs
ShowTrionSecretForm.cs
ShowTrionSecretForm.resources
ShowTrionSecretForm.resx
SingleGlobalInstance.cs
Tuple.cs
UnprotectPasswordForm.cs
UnprotectPasswordForm.designer.cs
UnprotectPasswordForm.resx
UpdateCheckForm.Designer.cs
UpdateCheckForm.cs
UpdateCheckForm.resx
WinAPI.cs
WinAuth-Net3.5.csproj
WinAuth.csproj
WinAuthAuthenticator.cs
WinAuthConfig.cs
WinAuthForm.Designer.cs
WinAuthForm.cs
WinAuthForm.resx
WinAuthHelper.cs
WinAuthMain.cs
WinAuthUpdater.cs
app.config
ilmerge.bat
packages.WinAuth-Net3.5.config
packages.WinAuth.config
winauth.ico
winauth.png
docs
.gitignore
.nojekyll
CNAME
COMPILING.md
LICENSE
README.md
winauth3-preview.png
克隆/下载
ResourceForm.cs 4.21 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Copyright (C) 2013 Colin Mackie.
* This software is distributed under the terms of the GNU General Public License.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.ComponentModel;
using System.Security;
using System.Windows.Forms;
using MetroFramework.Components;
using MetroFramework.Drawing;
using MetroFramework.Interfaces;
using System.Resources;
namespace WinAuth
{
/// <summary>
/// Subclass of the MetroForm that replaces Text properties of any matching controls from the resource file
/// </summary>
[Designer("MetroFramework.Design.Controls.MetroLabelDesigner, " + MetroFramework.AssemblyRef.MetroFrameworkDesignSN)]
[ToolboxBitmap(typeof(Form))]
public class ResourceForm : MetroFramework.Forms.MetroForm
{
/// <summary>
/// Comparer that checks two types and returns trues if they are the same or one is based on the other
/// </summary>
class BasedOnComparer : IEqualityComparer<Type>
{
/// <summary>
/// Check if two types are equal or subclassed
/// </summary>
/// <param name="t1"></param>
/// <param name="t2"></param>
/// <returns>true if equal or subclassed</returns>
public bool Equals(Type t1, Type t2)
{
return (t1 == t2 || t2.IsSubclassOf(t1));
}
/// <summary>
/// Get the hash code for a Type
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public int GetHashCode(Type t)
{
return t.GetHashCode();
}
}
/// <summary>
/// Create the new form
/// </summary>
public ResourceForm()
: base()
{
}
/// <summary>
/// Search the resources for any _FORMNAME_CONTROLNAME_ strings and replace the text
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
{
// go through all controls and set any text from resources (including this form)
//var controls = GetControls(this, new Type[] { typeof(MetroFramework.Controls.MetroLabel), typeof(MetroFramework.Controls.MetroCheckBox) });
var controls = GetControls(this);
string formname = "_" + this.Name + "_";
string text = WinAuthMain.StringResources.GetString(formname, System.Threading.Thread.CurrentThread.CurrentCulture);
if (text != null)
{
this.Text = text;
}
foreach (Control c in controls)
{
string controlname = formname + c.Name + "_";
text = WinAuthMain.StringResources.GetString(controlname, System.Threading.Thread.CurrentThread.CurrentCulture);
if (text != null)
{
if (c is MetroFramework.Controls.MetroTextBox)
{
((MetroFramework.Controls.MetroTextBox)c).PromptText = text;
}
else
{
c.Text = text;
}
}
}
base.OnLoad(e);
}
/// <summary>
/// Get a recursive list of all controls that match the array of types
/// </summary>
/// <param name="control">parent control</param>
/// <param name="controlTypes">array of types to match</param>
/// <param name="controls">existing list of Controls to add to</param>
/// <returns>list of Control objects</returns>
private List<Control> GetControls(Control control, Type[] controlTypes = null, List<Control> controls = null)
{
if (controls == null)
{
controls = new List<Control>();
}
BasedOnComparer baseComparer = new BasedOnComparer();
foreach (Control c in control.Controls)
{
if (controlTypes == null || controlTypes.Contains(c.GetType(), baseComparer) == true)
{
controls.Add(c);
}
if (c.Controls != null && c.Controls.Count != 0)
{
GetControls(c, controlTypes, controls);
}
}
return controls;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/YongboZhu/winauth.git
git@gitee.com:YongboZhu/winauth.git
YongboZhu
winauth
winauth
master

搜索帮助