Add LoginForm. Make start LoginForm default.
This commit is contained in:
parent
d60b020ad2
commit
0ff210091a
|
@ -16,6 +16,21 @@
|
|||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -117,6 +132,12 @@
|
|||
<Compile Include="LaneOut.Designer.cs">
|
||||
<DependentUpon>LaneOut.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoginForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LoginForm.Designer.cs">
|
||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PlateDetector.cs" />
|
||||
<Compile Include="PlateProcessor.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
|
@ -149,6 +170,9 @@
|
|||
<EmbeddedResource Include="LaneOut.resx">
|
||||
<DependentUpon>LaneOut.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="LoginForm.resx">
|
||||
<DependentUpon>LoginForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
@ -199,7 +223,18 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -42,6 +42,13 @@ namespace AIParkingApplication
|
|||
StartLanes();
|
||||
}
|
||||
|
||||
~AIParkingApplicationForm()
|
||||
{
|
||||
laneIn.Stop();
|
||||
laneOut.Stop();
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void StartLanes()
|
||||
{
|
||||
laneIn.Start();
|
||||
|
|
|
@ -178,26 +178,12 @@ namespace AIParkingApplication
|
|||
|
||||
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)
|
||||
{
|
||||
try
|
||||
{
|
||||
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
|
||||
}
|
||||
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
|
||||
private void PlateCameraOnVideoFrameReceived(Mat videoFrame)
|
||||
{
|
||||
try
|
||||
{
|
||||
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
|
||||
}
|
||||
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
|
||||
}
|
||||
|
||||
private void ConnectToDoorAccessControl()
|
||||
|
|
177
AIParkingApplication/LoginForm.Designer.cs
generated
Normal file
177
AIParkingApplication/LoginForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,177 @@
|
|||
namespace AIParkingApplication
|
||||
{
|
||||
partial class LoginForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginForm));
|
||||
this.pictureBoxImageLogo = new System.Windows.Forms.PictureBox();
|
||||
this.txtUsername = new System.Windows.Forms.TextBox();
|
||||
this.lblUsername = new System.Windows.Forms.Label();
|
||||
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||
this.lblPassword = new System.Windows.Forms.Label();
|
||||
this.lblServerAddress = new System.Windows.Forms.TextBox();
|
||||
this.lblServerIP = new System.Windows.Forms.Label();
|
||||
this.btnLogin = new System.Windows.Forms.Button();
|
||||
this.btnExit = new System.Windows.Forms.Button();
|
||||
this.lblLoginStatus = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxImageLogo
|
||||
//
|
||||
this.pictureBoxImageLogo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBoxImageLogo.Location = new System.Drawing.Point(12, 14);
|
||||
this.pictureBoxImageLogo.Name = "pictureBoxImageLogo";
|
||||
this.pictureBoxImageLogo.Size = new System.Drawing.Size(185, 185);
|
||||
this.pictureBoxImageLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBoxImageLogo.TabIndex = 0;
|
||||
this.pictureBoxImageLogo.TabStop = false;
|
||||
//
|
||||
// txtUsername
|
||||
//
|
||||
this.txtUsername.Location = new System.Drawing.Point(294, 14);
|
||||
this.txtUsername.Name = "txtUsername";
|
||||
this.txtUsername.Size = new System.Drawing.Size(227, 20);
|
||||
this.txtUsername.TabIndex = 1;
|
||||
this.txtUsername.Text = "cong1vao";
|
||||
//
|
||||
// lblUsername
|
||||
//
|
||||
this.lblUsername.AutoSize = true;
|
||||
this.lblUsername.Location = new System.Drawing.Point(214, 17);
|
||||
this.lblUsername.Name = "lblUsername";
|
||||
this.lblUsername.Size = new System.Drawing.Size(55, 13);
|
||||
this.lblUsername.TabIndex = 2;
|
||||
this.lblUsername.Text = "Tài khoản";
|
||||
//
|
||||
// txtPassword
|
||||
//
|
||||
this.txtPassword.Location = new System.Drawing.Point(294, 52);
|
||||
this.txtPassword.Name = "txtPassword";
|
||||
this.txtPassword.PasswordChar = '*';
|
||||
this.txtPassword.Size = new System.Drawing.Size(227, 20);
|
||||
this.txtPassword.TabIndex = 1;
|
||||
this.txtPassword.Text = "123456a@";
|
||||
//
|
||||
// lblPassword
|
||||
//
|
||||
this.lblPassword.AutoSize = true;
|
||||
this.lblPassword.Location = new System.Drawing.Point(214, 55);
|
||||
this.lblPassword.Name = "lblPassword";
|
||||
this.lblPassword.Size = new System.Drawing.Size(52, 13);
|
||||
this.lblPassword.TabIndex = 2;
|
||||
this.lblPassword.Text = "Mật khẩu";
|
||||
//
|
||||
// lblServerAddress
|
||||
//
|
||||
this.lblServerAddress.Location = new System.Drawing.Point(294, 90);
|
||||
this.lblServerAddress.Name = "lblServerAddress";
|
||||
this.lblServerAddress.Size = new System.Drawing.Size(227, 20);
|
||||
this.lblServerAddress.TabIndex = 1;
|
||||
this.lblServerAddress.Text = "localhost";
|
||||
//
|
||||
// lblServerIP
|
||||
//
|
||||
this.lblServerIP.AutoSize = true;
|
||||
this.lblServerIP.Location = new System.Drawing.Point(214, 93);
|
||||
this.lblServerIP.Name = "lblServerIP";
|
||||
this.lblServerIP.Size = new System.Drawing.Size(48, 13);
|
||||
this.lblServerIP.TabIndex = 2;
|
||||
this.lblServerIP.Text = "Máy chủ";
|
||||
//
|
||||
// btnLogin
|
||||
//
|
||||
this.btnLogin.Location = new System.Drawing.Point(294, 162);
|
||||
this.btnLogin.Name = "btnLogin";
|
||||
this.btnLogin.Size = new System.Drawing.Size(101, 37);
|
||||
this.btnLogin.TabIndex = 3;
|
||||
this.btnLogin.Text = "Đăng nhập";
|
||||
this.btnLogin.UseVisualStyleBackColor = true;
|
||||
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
|
||||
//
|
||||
// btnExit
|
||||
//
|
||||
this.btnExit.Location = new System.Drawing.Point(421, 162);
|
||||
this.btnExit.Name = "btnExit";
|
||||
this.btnExit.Size = new System.Drawing.Size(101, 37);
|
||||
this.btnExit.TabIndex = 3;
|
||||
this.btnExit.Text = "Thoát";
|
||||
this.btnExit.UseVisualStyleBackColor = true;
|
||||
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
|
||||
//
|
||||
// lblLoginStatus
|
||||
//
|
||||
this.lblLoginStatus.AutoSize = true;
|
||||
this.lblLoginStatus.Location = new System.Drawing.Point(294, 117);
|
||||
this.lblLoginStatus.Name = "lblLoginStatus";
|
||||
this.lblLoginStatus.Size = new System.Drawing.Size(66, 13);
|
||||
this.lblLoginStatus.TabIndex = 4;
|
||||
this.lblLoginStatus.Text = "Login Status";
|
||||
//
|
||||
// LoginForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(534, 211);
|
||||
this.Controls.Add(this.lblLoginStatus);
|
||||
this.Controls.Add(this.btnExit);
|
||||
this.Controls.Add(this.btnLogin);
|
||||
this.Controls.Add(this.lblServerIP);
|
||||
this.Controls.Add(this.lblPassword);
|
||||
this.Controls.Add(this.lblUsername);
|
||||
this.Controls.Add(this.lblServerAddress);
|
||||
this.Controls.Add(this.txtPassword);
|
||||
this.Controls.Add(this.txtUsername);
|
||||
this.Controls.Add(this.pictureBoxImageLogo);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximumSize = new System.Drawing.Size(550, 250);
|
||||
this.Name = "LoginForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "AIParking - Hệ thống quản lý bãi đỗ xe - Đăng nhập hệ thống";
|
||||
this.TopMost = true;
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBoxImageLogo;
|
||||
private System.Windows.Forms.TextBox txtUsername;
|
||||
private System.Windows.Forms.Label lblUsername;
|
||||
private System.Windows.Forms.TextBox txtPassword;
|
||||
private System.Windows.Forms.Label lblPassword;
|
||||
private System.Windows.Forms.TextBox lblServerAddress;
|
||||
private System.Windows.Forms.Label lblServerIP;
|
||||
private System.Windows.Forms.Button btnLogin;
|
||||
private System.Windows.Forms.Button btnExit;
|
||||
private System.Windows.Forms.Label lblLoginStatus;
|
||||
}
|
||||
}
|
50
AIParkingApplication/LoginForm.cs
Normal file
50
AIParkingApplication/LoginForm.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
public partial class LoginForm : Form
|
||||
{
|
||||
private const string serverBaseAddress = "http://localhost:80/";
|
||||
private ApiController apiController;
|
||||
|
||||
public LoginForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
pictureBoxImageLogo.Image = new Bitmap(@".\Images\ApplicationLogo.ico");
|
||||
lblLoginStatus.Text = string.Empty;
|
||||
|
||||
apiController = new ApiController(serverBaseAddress);
|
||||
}
|
||||
|
||||
private async void btnLogin_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
lblLoginStatus.Text = string.Empty;
|
||||
string username = txtUsername.Text;
|
||||
string password = txtPassword.Text;
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không được để trống!";
|
||||
return;
|
||||
}
|
||||
var loginResult = await apiController.Login(new LoginModel { Username = username, Password = password });
|
||||
if (loginResult.IsLoginSuccess)
|
||||
{
|
||||
new AIParkingApplicationForm().Show();
|
||||
Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không đúng!";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnExit_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (DialogResult.OK == MessageBox.Show("AIParking - Bạn muốn thoát ứng dụng?", "Cảnh báo!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2679
AIParkingApplication/LoginForm.resx
Normal file
2679
AIParkingApplication/LoginForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -16,7 +16,7 @@ namespace AIParkingApplication
|
|||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new AIParkingApplicationForm());
|
||||
Application.Run(new LoginForm());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user