From 7f61711e61f880f9debe990b3b8ebb886446f6a8 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Wed, 8 Jul 2020 13:54:01 +0700 Subject: [PATCH] AIParkingApplicationForm - Add menustrip for laneswitch. --- .../AIParkingApplicationForm.Designer.cs | 66 +++++++++++++++++++ .../AIParkingApplicationForm.cs | 41 +++++++++--- .../AIParkingApplicationForm.resx | 3 + 3 files changed, 100 insertions(+), 10 deletions(-) diff --git a/AIParkingApplication/AIParkingApplicationForm.Designer.cs b/AIParkingApplication/AIParkingApplicationForm.Designer.cs index 322da1b..72cabd2 100644 --- a/AIParkingApplication/AIParkingApplicationForm.Designer.cs +++ b/AIParkingApplication/AIParkingApplicationForm.Designer.cs @@ -29,23 +29,89 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AIParkingApplicationForm)); + this.menuStrip = new System.Windows.Forms.MenuStrip(); + this.toolStripMenuItemSwitchLane = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSwitchLaneInIn = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSwitchLaneInOut = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSwitchLaneOutOut = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSwitchLaneOutIn = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip.SuspendLayout(); this.SuspendLayout(); // + // menuStrip + // + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSwitchLane}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(1366, 24); + this.menuStrip.TabIndex = 0; + this.menuStrip.Text = "menuStrip1"; + // + // toolStripMenuItemSwitchLane + // + this.toolStripMenuItemSwitchLane.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSwitchLaneInIn, + this.toolStripMenuItemSwitchLaneInOut, + this.toolStripMenuItemSwitchLaneOutOut, + this.toolStripMenuItemSwitchLaneOutIn}); + this.toolStripMenuItemSwitchLane.Name = "toolStripMenuItemSwitchLane"; + this.toolStripMenuItemSwitchLane.Size = new System.Drawing.Size(59, 20); + this.toolStripMenuItemSwitchLane.Text = "Đảo làn"; + // + // toolStripMenuItemSwitchLaneInIn + // + this.toolStripMenuItemSwitchLaneInIn.Name = "toolStripMenuItemSwitchLaneInIn"; + this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSwitchLaneInIn.Text = "Vào - Vào"; + this.toolStripMenuItemSwitchLaneInIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneInIn_Click); + // + // toolStripMenuItemSwitchLaneInOut + // + this.toolStripMenuItemSwitchLaneInOut.Name = "toolStripMenuItemSwitchLaneInOut"; + this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSwitchLaneInOut.Text = "Vào - Ra"; + // + // toolStripMenuItemSwitchLaneOutOut + // + this.toolStripMenuItemSwitchLaneOutOut.Name = "toolStripMenuItemSwitchLaneOutOut"; + this.toolStripMenuItemSwitchLaneOutOut.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSwitchLaneOutOut.Text = "Ra - Ra"; + // + // toolStripMenuItemSwitchLaneOutIn + // + this.toolStripMenuItemSwitchLaneOutIn.Name = "toolStripMenuItemSwitchLaneOutIn"; + this.toolStripMenuItemSwitchLaneOutIn.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSwitchLaneOutIn.Text = "Ra - Vào"; + // // AIParkingApplicationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1366, 737); + this.Controls.Add(this.menuStrip); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip; this.MinimumSize = new System.Drawing.Size(1382, 776); this.Name = "AIParkingApplicationForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "AIParking - Phần mềm quản lý bãi đỗ xe"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AIParkingApplicationForm_FormClosing); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion + + private System.Windows.Forms.MenuStrip menuStrip; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLane; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneInIn; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneInOut; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutOut; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutIn; } } diff --git a/AIParkingApplication/AIParkingApplicationForm.cs b/AIParkingApplication/AIParkingApplicationForm.cs index e8cf826..df87a30 100644 --- a/AIParkingApplication/AIParkingApplicationForm.cs +++ b/AIParkingApplication/AIParkingApplicationForm.cs @@ -13,6 +13,7 @@ namespace AIParkingApplication private StatusBar statusBar; private Sidebar sidebar; private Config configOnWeb; + private EngineApiController engineApiController; public AIParkingApplicationForm(ApiController apiController, Config configOnWeb) { @@ -25,7 +26,6 @@ namespace AIParkingApplication Controls.Add(sidebar); c3Device = new C3DeviceController("192.168.1.200"); - EngineApiController engineApiController = null; try { @@ -38,12 +38,12 @@ namespace AIParkingApplication } laneIn = new LaneIn(1, this.configOnWeb.CameraData1.StreamUrl, this.configOnWeb.CameraData2.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); laneIn.BorderStyle = BorderStyle.FixedSingle; - laneIn.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, 0); + laneIn.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); Controls.Add(laneIn); laneOut = new LaneOut(2, this.configOnWeb.CameraData3.StreamUrl, this.configOnWeb.CameraData4.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); laneOut.BorderStyle = BorderStyle.FixedSingle; - laneOut.Location = new System.Drawing.Point(laneIn.Location.X + laneIn.Width + 20, 0); + laneOut.Location = new System.Drawing.Point(laneIn.Location.X + laneIn.Width + 20, menuStrip.Height); Controls.Add(laneOut); statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1)); @@ -54,17 +54,38 @@ namespace AIParkingApplication StartLanes(); } - ~AIParkingApplicationForm() - { - laneIn.Stop(); - laneOut.Stop(); - Application.Exit(); - } - private void StartLanes() { laneIn.Start(); laneOut.Start(); } + + private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e) + { + laneIn.Stop(); + laneOut.Stop(); + laneIn.Hide(); + laneOut.Hide(); + LaneIn laneIn1, laneIn2; + laneIn1 = new LaneIn(1, this.configOnWeb.CameraData1.StreamUrl, this.configOnWeb.CameraData2.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); + laneIn1.BorderStyle = BorderStyle.FixedSingle; + laneIn1.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); + Controls.Add(laneIn1); + + laneIn2 = new LaneIn(2, this.configOnWeb.CameraData1.StreamUrl, this.configOnWeb.CameraData2.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); + laneIn2.BorderStyle = BorderStyle.FixedSingle; + laneIn2.Location = new System.Drawing.Point(laneIn1.Location.X + laneIn1.Width + 20, menuStrip.Height); + Controls.Add(laneIn2); + + laneIn1.Start(); + laneIn2.Start(); + this.MinimumSize = new System.Drawing.Size(500, 768); + this.Width = 500; + } + + private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e) + { + Application.Exit(); + } } } diff --git a/AIParkingApplication/AIParkingApplicationForm.resx b/AIParkingApplication/AIParkingApplicationForm.resx index ee2261a..d6cc1f9 100644 --- a/AIParkingApplication/AIParkingApplicationForm.resx +++ b/AIParkingApplication/AIParkingApplicationForm.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 +