login!
This commit is contained in:
@@ -5,6 +5,7 @@ namespace OwnChar.App.Desktop.Api
|
||||
{
|
||||
public interface IMainWindowApi
|
||||
{
|
||||
Form Window { get; }
|
||||
OwnCharManager? Manager { get; }
|
||||
void OpenTab(Control content, string title);
|
||||
void CloseTab(Control content);
|
||||
|
||||
18
OwnChar.App.Desktop/Api/LoginProvider.cs
Normal file
18
OwnChar.App.Desktop/Api/LoginProvider.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using OwnChar.Data;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
namespace OwnChar.App.Desktop.Api;
|
||||
|
||||
public abstract class LoginProvider : PluginFeature
|
||||
{
|
||||
public abstract IDataManager GetDefault(IMainWindowApi api);
|
||||
public abstract void Configure(IMainWindowApi api, ref IDataManager? manager);
|
||||
|
||||
protected LoginProvider(string featureType, string identifier) : base(featureType, identifier)
|
||||
{
|
||||
}
|
||||
|
||||
protected LoginProvider(string featureType, string featureIdentifier, string? featureName) : base(featureType, featureIdentifier, featureName)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,11 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using Pilz.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.App.Desktop
|
||||
namespace OwnChar.App.Desktop;
|
||||
|
||||
public sealed class AppApi : IOwnCharApi
|
||||
{
|
||||
public sealed class AppApi : IOwnCharApi
|
||||
{
|
||||
public static AppApi Instance { get; } = new();
|
||||
public IMainWindowApi? MainWindow { get; internal set; }
|
||||
public ISettings? Settings { get; internal set; }
|
||||
}
|
||||
public static AppApi Instance { get; } = new();
|
||||
public IMainWindowApi? MainWindow { get; internal set; }
|
||||
public ISettings Settings { get; internal set; } = null!;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
{
|
||||
public const string MainTab = "ownchar.app.desktop.main.tab";
|
||||
public const string QuickAction = "ownchar.app.desktop.main.quickaction";
|
||||
public const string LoginProvider = "ownchar.app.desktop.main.login.provider";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.Settings;
|
||||
using OwnChar.Data;
|
||||
using OwnChar.Data.Managers;
|
||||
using OwnChar.Data.Providers.JsonFile;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.Features.LoginProviders;
|
||||
|
||||
internal class JsonFileLoginProvider() : LoginProvider(FeatureCodes.LoginProvider, "ownchar.jsonfile"), IPluginFeatureProvider<JsonFileLoginProvider>
|
||||
{
|
||||
private const string defaultJsonFileName = "ownchar.db.json";
|
||||
|
||||
public static JsonFileLoginProvider Instance { get; } = new();
|
||||
|
||||
public override IDataManager GetDefault(IMainWindowApi api)
|
||||
{
|
||||
var settings = AppApi.Instance.Settings.Get<JsonFileLoginProviderSettings>();
|
||||
return new DefaultDataManager(new JsonFileDataProvider(settings?.RecentFilePath ?? defaultJsonFileName));
|
||||
}
|
||||
|
||||
public override void Configure(IMainWindowApi api, ref IDataManager? manager)
|
||||
{
|
||||
var settings = AppApi.Instance.Settings.Get<JsonFileLoginProviderSettings>();
|
||||
using var ofd = new RadOpenFileDialog
|
||||
{
|
||||
Filter = "OwnChar Json database (*.json)|*.json"
|
||||
};
|
||||
|
||||
if (manager is DefaultDataManager defaultManager && defaultManager.DataProvider is JsonFileDataProvider jsonFileDataProvider)
|
||||
ofd.FileName = jsonFileDataProvider.JsonFilePath;
|
||||
else
|
||||
ofd.FileName = settings.RecentFilePath;
|
||||
|
||||
if (ofd.ShowDialog(api.Window) != System.Windows.Forms.DialogResult.OK)
|
||||
return;
|
||||
|
||||
settings.RecentFilePath = ofd.FileName;
|
||||
|
||||
manager = new DefaultDataManager(new JsonFileDataProvider(ofd.FileName ?? defaultJsonFileName));
|
||||
}
|
||||
}
|
||||
@@ -22,14 +22,14 @@ namespace OwnChar.App.Desktop.LangRes {
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class LangResCharListControl {
|
||||
internal class CharListControlLangRes {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal LangResCharListControl() {
|
||||
internal CharListControlLangRes() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,7 +39,7 @@ namespace OwnChar.App.Desktop.LangRes {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OwnChar.App.Desktop.LangRes.LangResCharListControl", typeof(LangResCharListControl).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OwnChar.App.Desktop.LangRes.CharListControlLangRes", typeof(CharListControlLangRes).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -22,14 +22,14 @@ namespace OwnChar.App.Desktop.LangRes {
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class HomePageLangRes {
|
||||
internal class LoginPageLangRes {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal HomePageLangRes() {
|
||||
internal LoginPageLangRes() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,7 +39,7 @@ namespace OwnChar.App.Desktop.LangRes {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OwnChar.App.Desktop.LangRes.HomePageLangRes", typeof(HomePageLangRes).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OwnChar.App.Desktop.LangRes.LoginPageLangRes", typeof(LoginPageLangRes).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -61,7 +61,25 @@ namespace OwnChar.App.Desktop.LangRes {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Home ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Login failed. Please ensure username and password are correct and choose and configure a provider. If nothing helps try restart the app. ähnelt.
|
||||
/// </summary>
|
||||
internal static string MsgBox_LoginFailed {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgBox_LoginFailed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Login failed ähnelt.
|
||||
/// </summary>
|
||||
internal static string MsgBox_LoginFailed_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgBox_LoginFailed_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Login ähnelt.
|
||||
/// </summary>
|
||||
internal static string Title {
|
||||
get {
|
||||
@@ -117,7 +117,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="MsgBox_LoginFailed" xml:space="preserve">
|
||||
<value>Login failed. Please ensure username and password are correct and choose and configure a provider. If nothing helps try restart the app.</value>
|
||||
</data>
|
||||
<data name="MsgBox_LoginFailed_Title" xml:space="preserve">
|
||||
<value>Login failed</value>
|
||||
</data>
|
||||
<data name="Title" xml:space="preserve">
|
||||
<value>Home</value>
|
||||
<value>Login</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -31,10 +31,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="LangRes\HomePageLangRes.Designer.cs">
|
||||
<Compile Update="LangRes\LoginPageLangRes.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>HomePageLangRes.resx</DependentUpon>
|
||||
<DependentUpon>LoginPageLangRes.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LangRes\SettingsPageLangRes.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -44,9 +44,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="LangRes\HomePageLangRes.resx">
|
||||
<EmbeddedResource Update="LangRes\LoginPageLangRes.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>HomePageLangRes.Designer.cs</LastGenOutput>
|
||||
<LastGenOutput>LoginPageLangRes.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="LangRes\SettingsPageLangRes.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
@@ -55,17 +55,17 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="LangRes\LangResCharListControl.Designer.cs">
|
||||
<Compile Update="LangRes\CharListControlLangRes.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>LangResCharListControl.resx</DependentUpon>
|
||||
<DependentUpon>CharListControlLangRes.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="LangRes\LangResCharListControl.resx">
|
||||
<EmbeddedResource Update="LangRes\CharListControlLangRes.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>LangResCharListControl.Designer.cs</LastGenOutput>
|
||||
<LastGenOutput>CharListControlLangRes.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Pilz.Configuration;
|
||||
|
||||
namespace OwnChar.App.Desktop.Settings;
|
||||
|
||||
internal class JsonFileLoginProviderSettings : IChildSettings, ISettingsIdentifier
|
||||
{
|
||||
public static string Identifier => "ownchar.login.providers.jsonfile";
|
||||
|
||||
public string? RecentFilePath { get; set; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
RecentFilePath = null;
|
||||
}
|
||||
}
|
||||
184
OwnChar.App.Desktop/UI/MainTabs/TabLoginView.Designer.cs
generated
184
OwnChar.App.Desktop/UI/MainTabs/TabLoginView.Designer.cs
generated
@@ -29,18 +29,26 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
radButton1 = new Telerik.WinControls.UI.RadButton();
|
||||
radLabel1 = new Telerik.WinControls.UI.RadLabel();
|
||||
radTextBoxControl1 = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radTextBoxControl2 = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radTextBoxControl_Password = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radLabel2 = new Telerik.WinControls.UI.RadLabel();
|
||||
radTextBoxControl_Username = new Telerik.WinControls.UI.RadTextBoxControl();
|
||||
radButton_Login = new Telerik.WinControls.UI.RadButton();
|
||||
radLabel1 = new Telerik.WinControls.UI.RadLabel();
|
||||
radLabel3 = new Telerik.WinControls.UI.RadLabel();
|
||||
tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||
radDropDownList_LoginProvider = new Telerik.WinControls.UI.RadDropDownList();
|
||||
radButton_ConfigureProvider = new Telerik.WinControls.UI.RadButton();
|
||||
tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radButton1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Password).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Username).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Login).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel3).BeginInit();
|
||||
tableLayoutPanel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radDropDownList_LoginProvider).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_ConfigureProvider).BeginInit();
|
||||
tableLayoutPanel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -51,64 +59,116 @@
|
||||
tableLayoutPanel1.ColumnCount = 2;
|
||||
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
|
||||
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F));
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl2, 1, 1);
|
||||
tableLayoutPanel1.Controls.Add(radLabel2, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl1, 1, 0);
|
||||
tableLayoutPanel1.Controls.Add(radButton1, 1, 2);
|
||||
tableLayoutPanel1.Controls.Add(radLabel1, 0, 0);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(129, 81);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl_Password, 1, 2);
|
||||
tableLayoutPanel1.Controls.Add(radLabel2, 0, 2);
|
||||
tableLayoutPanel1.Controls.Add(radTextBoxControl_Username, 1, 1);
|
||||
tableLayoutPanel1.Controls.Add(radButton_Login, 1, 3);
|
||||
tableLayoutPanel1.Controls.Add(radLabel1, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(radLabel3, 0, 0);
|
||||
tableLayoutPanel1.Controls.Add(tableLayoutPanel3, 1, 0);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(129, 74);
|
||||
tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
tableLayoutPanel1.RowCount = 3;
|
||||
tableLayoutPanel1.RowCount = 4;
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.Size = new System.Drawing.Size(259, 86);
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
tableLayoutPanel1.Size = new System.Drawing.Size(259, 114);
|
||||
tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// radButton1
|
||||
// radTextBoxControl_Password
|
||||
//
|
||||
radButton1.Location = new System.Drawing.Point(106, 59);
|
||||
radButton1.Name = "radButton1";
|
||||
radButton1.Size = new System.Drawing.Size(110, 24);
|
||||
radButton1.TabIndex = 1;
|
||||
radButton1.Text = "radButton1";
|
||||
//
|
||||
// radLabel1
|
||||
//
|
||||
radLabel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel1.AutoSize = false;
|
||||
radLabel1.Location = new System.Drawing.Point(3, 3);
|
||||
radLabel1.Name = "radLabel1";
|
||||
radLabel1.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel1.TabIndex = 1;
|
||||
radLabel1.Text = "radLabel1";
|
||||
//
|
||||
// radTextBoxControl1
|
||||
//
|
||||
radTextBoxControl1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl1.Location = new System.Drawing.Point(106, 3);
|
||||
radTextBoxControl1.Name = "radTextBoxControl1";
|
||||
radTextBoxControl1.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl1.TabIndex = 2;
|
||||
//
|
||||
// radTextBoxControl2
|
||||
//
|
||||
radTextBoxControl2.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl2.Location = new System.Drawing.Point(106, 31);
|
||||
radTextBoxControl2.Name = "radTextBoxControl2";
|
||||
radTextBoxControl2.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl2.TabIndex = 1;
|
||||
radTextBoxControl_Password.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl_Password.Location = new System.Drawing.Point(106, 59);
|
||||
radTextBoxControl_Password.Name = "radTextBoxControl_Password";
|
||||
radTextBoxControl_Password.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl_Password.TabIndex = 1;
|
||||
//
|
||||
// radLabel2
|
||||
//
|
||||
radLabel2.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel2.AutoSize = false;
|
||||
radLabel2.Location = new System.Drawing.Point(3, 31);
|
||||
radLabel2.Location = new System.Drawing.Point(3, 59);
|
||||
radLabel2.Name = "radLabel2";
|
||||
radLabel2.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel2.TabIndex = 0;
|
||||
radLabel2.Text = "radLabel2";
|
||||
radLabel2.Text = "Password";
|
||||
//
|
||||
// radTextBoxControl_Username
|
||||
//
|
||||
radTextBoxControl_Username.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radTextBoxControl_Username.Location = new System.Drawing.Point(106, 31);
|
||||
radTextBoxControl_Username.Name = "radTextBoxControl_Username";
|
||||
radTextBoxControl_Username.Size = new System.Drawing.Size(150, 22);
|
||||
radTextBoxControl_Username.TabIndex = 2;
|
||||
//
|
||||
// radButton_Login
|
||||
//
|
||||
radButton_Login.Location = new System.Drawing.Point(106, 87);
|
||||
radButton_Login.Name = "radButton_Login";
|
||||
radButton_Login.Size = new System.Drawing.Size(110, 24);
|
||||
radButton_Login.TabIndex = 1;
|
||||
radButton_Login.Text = "Login";
|
||||
radButton_Login.Click += RadButton_Login_Click;
|
||||
//
|
||||
// radLabel1
|
||||
//
|
||||
radLabel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel1.AutoSize = false;
|
||||
radLabel1.Location = new System.Drawing.Point(3, 31);
|
||||
radLabel1.Name = "radLabel1";
|
||||
radLabel1.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel1.TabIndex = 1;
|
||||
radLabel1.Text = "Username";
|
||||
//
|
||||
// radLabel3
|
||||
//
|
||||
radLabel3.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radLabel3.AutoSize = false;
|
||||
radLabel3.Location = new System.Drawing.Point(3, 3);
|
||||
radLabel3.Name = "radLabel3";
|
||||
radLabel3.Size = new System.Drawing.Size(97, 22);
|
||||
radLabel3.TabIndex = 3;
|
||||
radLabel3.Text = "Provider";
|
||||
//
|
||||
// tableLayoutPanel3
|
||||
//
|
||||
tableLayoutPanel3.AutoSize = true;
|
||||
tableLayoutPanel3.ColumnCount = 2;
|
||||
tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
tableLayoutPanel3.Controls.Add(radDropDownList_LoginProvider, 0, 0);
|
||||
tableLayoutPanel3.Controls.Add(radButton_ConfigureProvider, 1, 0);
|
||||
tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
tableLayoutPanel3.Location = new System.Drawing.Point(103, 0);
|
||||
tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
|
||||
tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
tableLayoutPanel3.RowCount = 1;
|
||||
tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.Size = new System.Drawing.Size(156, 28);
|
||||
tableLayoutPanel3.TabIndex = 4;
|
||||
//
|
||||
// radDropDownList_LoginProvider
|
||||
//
|
||||
radDropDownList_LoginProvider.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
radDropDownList_LoginProvider.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
|
||||
radDropDownList_LoginProvider.Location = new System.Drawing.Point(3, 3);
|
||||
radDropDownList_LoginProvider.Name = "radDropDownList_LoginProvider";
|
||||
radDropDownList_LoginProvider.Size = new System.Drawing.Size(122, 22);
|
||||
radDropDownList_LoginProvider.TabIndex = 0;
|
||||
radDropDownList_LoginProvider.SelectedValueChanged += RadDropDownList_LoginProvider_SelectedValueChanged;
|
||||
//
|
||||
// radButton_ConfigureProvider
|
||||
//
|
||||
radButton_ConfigureProvider.DisplayStyle = Telerik.WinControls.DisplayStyle.Image;
|
||||
radButton_ConfigureProvider.ImageAlignment = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
radButton_ConfigureProvider.Location = new System.Drawing.Point(131, 3);
|
||||
radButton_ConfigureProvider.Name = "radButton_ConfigureProvider";
|
||||
radButton_ConfigureProvider.Size = new System.Drawing.Size(22, 22);
|
||||
radButton_ConfigureProvider.TabIndex = 1;
|
||||
radButton_ConfigureProvider.Text = "Configure";
|
||||
radButton_ConfigureProvider.Click += RadButton_ConfigureProvider_Click;
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
@@ -135,11 +195,17 @@
|
||||
Name = "TabLoginView";
|
||||
Size = new System.Drawing.Size(519, 412);
|
||||
tableLayoutPanel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)radButton1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl2).EndInit();
|
||||
tableLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Password).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel2).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTextBoxControl_Username).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Login).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radLabel3).EndInit();
|
||||
tableLayoutPanel3.ResumeLayout(false);
|
||||
tableLayoutPanel3.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radDropDownList_LoginProvider).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_ConfigureProvider).EndInit();
|
||||
tableLayoutPanel2.ResumeLayout(false);
|
||||
tableLayoutPanel2.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@@ -148,11 +214,15 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl2;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_Password;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel2;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl1;
|
||||
private Telerik.WinControls.UI.RadButton radButton1;
|
||||
private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_Username;
|
||||
private Telerik.WinControls.UI.RadButton radButton_Login;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel1;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||
private Telerik.WinControls.UI.RadLabel radLabel3;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
||||
private Telerik.WinControls.UI.RadDropDownList radDropDownList_LoginProvider;
|
||||
private Telerik.WinControls.UI.RadButton radButton_ConfigureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.Data;
|
||||
using Pilz.Cryptography;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabLoginView : UserControl, ILoadContent
|
||||
{
|
||||
public partial class TabLoginView : UserControl
|
||||
private readonly IMainWindowApi mainApi;
|
||||
private IDataManager? dataManager;
|
||||
|
||||
public TabLoginView(IMainWindowApi mainApi)
|
||||
{
|
||||
public TabLoginView()
|
||||
this.mainApi = mainApi;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
LoadProvidersList();
|
||||
}
|
||||
|
||||
private void LoadProvidersList()
|
||||
{
|
||||
radDropDownList_LoginProvider.BeginUpdate();
|
||||
|
||||
foreach (var feat in PluginFeatureController.Instance.Features.Get(FeatureCodes.LoginProvider))
|
||||
{
|
||||
InitializeComponent();
|
||||
if (feat is LoginProvider provider)
|
||||
{
|
||||
var item = new RadListDataItem(feat.Name, provider)
|
||||
{
|
||||
SvgImage = feat.Icon as RadSvgImage,
|
||||
Image = feat.Icon as Image,
|
||||
};
|
||||
radDropDownList_LoginProvider.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
radDropDownList_LoginProvider.EndUpdate();
|
||||
|
||||
if (radDropDownList_LoginProvider.Items.Count > 0)
|
||||
radDropDownList_LoginProvider.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void RadDropDownList_LoginProvider_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (radDropDownList_LoginProvider.SelectedValue is LoginProvider provider)
|
||||
dataManager = provider.GetDefault(mainApi);
|
||||
}
|
||||
|
||||
private void RadButton_Login_Click(object sender, EventArgs e)
|
||||
{
|
||||
var username = radTextBoxControl_Username.Text.Trim();
|
||||
var password = (SecureString)radTextBoxControl_Password.Text;
|
||||
|
||||
if (mainApi.Manager?.Login(dataManager, username, password) is not bool success || !success)
|
||||
{
|
||||
RadMessageBox.Show(LoginPageLangRes.MsgBox_LoginFailed, LoginPageLangRes.MsgBox_LoginFailed_Title, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
mainApi.OpenTab(new TabUserView(mainApi, mainApi.Manager.CurrentUser), mainApi.Manager.CurrentUser!.Username!);
|
||||
mainApi.CloseTab(this);
|
||||
}
|
||||
|
||||
private void RadButton_ConfigureProvider_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radDropDownList_LoginProvider.SelectedValue is LoginProvider provider)
|
||||
provider.Configure(mainApi, ref dataManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
Name = "MainWindow";
|
||||
ShowIcon = false;
|
||||
Text = "RadForm1";
|
||||
Load += MainWindow_Load;
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl2).EndInit();
|
||||
radTabbedFormControl2.ResumeLayout(false);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.Api.Parameters;
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.App.Desktop.UI.MainTabs;
|
||||
using OwnChar.Data;
|
||||
using OwnChar.Data.Managers;
|
||||
using OwnChar.Data.Providers.JsonFile;
|
||||
@@ -92,5 +94,10 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
if (sender is RadMenuItem item && item.Tag is PluginFunction function)
|
||||
function.Execute(GetMainWindowParams());
|
||||
}
|
||||
|
||||
private void MainWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
Api.OpenTab(new TabLoginView(Api), LoginPageLangRes.Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user