Compare commits

...

8 Commits

15 changed files with 5554 additions and 29 deletions

View File

@ -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>
@ -186,6 +210,9 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\ApplicationLogo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\CantConnectCamera.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -196,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>

View File

@ -28,16 +28,19 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AIParkingApplicationForm));
this.SuspendLayout();
//
// AIParkingApplicationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1358, 737);
this.MinimumSize = new System.Drawing.Size(1374, 776);
this.ClientSize = new System.Drawing.Size(1366, 737);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(1382, 776);
this.Name = "AIParkingApplicationForm";
this.Text = "AIParking Application";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AIParking - Phần mềm quản lý bãi đỗ xe";
this.ResumeLayout(false);
}

View File

@ -42,6 +42,13 @@ namespace AIParkingApplication
StartLanes();
}
~AIParkingApplicationForm()
{
laneIn.Stop();
laneOut.Stop();
Application.Exit();
}
private void StartLanes()
{
laneIn.Start();

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -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
View 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;
}
}

View File

@ -0,0 +1,56 @@
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);
this.AcceptButton = btnLogin;
}
private async void Login()
{
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 btnLogin_Click(object sender, System.EventArgs e)
{
Login();
}
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();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ namespace AIParkingApplication
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new AIParkingApplicationForm());
Application.Run(new LoginForm());
}
else
{

View File

@ -9,7 +9,7 @@ namespace AIParkingApplication
{
private Statistic statistic;
public Sidebar(ApiController apiController, string logoImagePath = @"C:\Users\B.I\Desktop\photo_2020-06-25_21-22-56.jpg")
public Sidebar(ApiController apiController, string logoImagePath = @".\Images\ApplicationLogo.ico")
{
InitializeComponent();
if (File.Exists(logoImagePath))
@ -17,7 +17,6 @@ namespace AIParkingApplication
PictureBox pictureBoxImageLogo;
pictureBoxImageLogo = new PictureBox();
pictureBoxImageLogo.Location = new Point(1, 1);
pictureBoxImageLogo.BorderStyle = BorderStyle.FixedSingle;
pictureBoxImageLogo.Size = new Size(185, 185);
pictureBoxImageLogo.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBoxImageLogo.Image = new Bitmap(logoImagePath);

View File

@ -32,7 +32,7 @@ namespace AIParkingApplication
private async void GetDataUpdate()
{
ParkInfo parkInfo = await apiController.GetStatisticInfo();
if (parkInfo != null)
if (parkInfo != null && IsHandleCreated)
{
lblSoLuongXeMay.UpdateLabel(parkInfo.NumberOfMoto.ToString());
lblSoLuongOto.UpdateLabel(parkInfo.NumberOfCar.ToString());

View File

@ -52,7 +52,7 @@
//
this.lblDateTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblDateTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDateTime.Location = new System.Drawing.Point(1210, 0);
this.lblDateTime.Location = new System.Drawing.Point(1226, 0);
this.lblDateTime.Name = "lblDateTime";
this.lblDateTime.Size = new System.Drawing.Size(140, 24);
this.lblDateTime.TabIndex = 2;
@ -132,9 +132,10 @@
this.Controls.Add(this.lblConnectionStatus);
this.Controls.Add(this.lblPingTimeServer);
this.Margin = new System.Windows.Forms.Padding(0);
this.MaximumSize = new System.Drawing.Size(1350, 24);
this.MaximumSize = new System.Drawing.Size(1366, 24);
this.MinimumSize = new System.Drawing.Size(1366, 24);
this.Name = "StatusBar";
this.Size = new System.Drawing.Size(1350, 24);
this.Size = new System.Drawing.Size(1366, 24);
this.ResumeLayout(false);
}

View File

@ -41,9 +41,9 @@ namespace AIParkingApplication
if (Process.GetProcessesByName("tmux").Length == 0)
{
if (File.Exists(engineFilePath))
string engineBatFilePath = Application.StartupPath + engineFilePath;
if (File.Exists(engineBatFilePath))
{
string engineBatFilePath = Application.StartupPath + engineFilePath;
Util.ExecuteCommand(engineBatFilePath);
lblEngineStatus.UpdateLabel("DỪNG HOẠT ĐỘNG", Color.Red);
}

View File

@ -80,6 +80,11 @@ namespace AIParkingApplication
public static void UpdateImage(this PictureBox pictureBox, Bitmap image)
{
if (pictureBox.IsDisposed)
{
return;
}
pictureBox.Invoke(new Action(() =>
{
pictureBox.Image?.Dispose();
@ -89,6 +94,11 @@ namespace AIParkingApplication
public static void UpdateLabel(this Label label, string text, Color backColor, Color foreColor)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;
@ -99,6 +109,11 @@ namespace AIParkingApplication
public static void UpdateLabel(this Label label, string text, Color backColor)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;
@ -108,6 +123,11 @@ namespace AIParkingApplication
public static void UpdateLabel(this Label label, string text)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;