using Rs.Motion.GugaoEcat; using Rs.Motion; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Rs.Controls; using Rs.MotionPlat.Flow; using Rs.Framework; using Rs.Camera; using System.Threading; using Rs.MotionPlat.Commom; using static System.Runtime.CompilerServices.RuntimeHelpers; using Rs.Motion.GugaoPulse; using Rs.MotionPlat.SysConfig; namespace Rs.MotionPlat { public partial class Home : BaseFormHeader { public Home() { this.StartPosition = FormStartPosition.Manual; InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; } void CloseSubWindow() { foreach(Control f in panel_main.Controls) { if(f is Form && ((Form)f).Name!= "FormMain") { ((Form)f).Close(); } } panel_main.Controls.Clear(); } protected void Menu_Clicked(object sender, EventArgs e) { ButtonEx button = (ButtonEx)sender; if (button == btnSystem) { ClearSelectBtn(); button.Selected = true; CloseSubWindow(); BaseForm from = new SubMenuForm("SysConfig"); from.TopLevel = false; from.Dock = DockStyle.Fill; panel_main.Controls.Add(from); from.Visible = true; } else if (button == btnMain) { ClearSelectBtn(); button.Selected = true; CloseSubWindow(); BaseForm form = ActiveForms.Get("FormMain"); if(form!=null) { panel_main.Controls.Add(form); form.TopLevel = false; form.Dock = DockStyle.Fill; form.Visible = true; } else { form = new FormMain(); form.Name = "FormMain"; form.TopLevel = false; form.Dock = DockStyle.Fill; panel_main.Controls.Add(form); form.Visible = true; ActiveForms.Add(form); } } else if (button == btnQuit) { button.Selected = false; DialogResult dr = MessageBox.Show("确定要退出吗?", "提示", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) { Ops.Quit(); System.Environment.Exit(-1); } } else if (button == btnRecipe) { ClearSelectBtn(); button.Selected = true; CloseSubWindow(); BaseForm from = new SubMenuForm("Recipe"); from.TopLevel = false; from.Dock = DockStyle.Fill; panel_main.Controls.Add(from); from.Visible = true; } else if (button == btnAbout) { btnAbout.Enabled = false; BaseFormHeader form; form = new DebugMove(ShowBtn); //form = DebugMove.Instance; form.HeaderBackgroundColor = Color.Gray; form.TopMost = true; form.ShowMax = false; form.ShowMin = false; form.ShowInTaskbar = false; //form.StartPosition = FormStartPosition.CenterScreen; //MessageBox.Show(form.Width.ToString()); //MessageBox.Show(form.Height.ToString()); //form.Location= new Point(this.Width-form.Width, this.Height-form.Height); //form.mov = new Point(0,0); form.Show(this); } else if (button == btnPermission) { BaseFormHeader form; form = new UserForm(); form.StartPosition = FormStartPosition.CenterScreen; form.Opacity = 1; form.TopMost = true; form.ShowDialog(this); } else if (button == btnLanguage) { ClearSelectBtn(); button.Selected = true; CloseSubWindow(); BaseForm from = new SubMenuForm("Calib"); from.TopLevel = false; from.Dock = DockStyle.Fill; panel_main.Controls.Add(from); from.Visible = true; // btnLanguage.Enabled = false; //VarConfig vc = new VarConfig(ShowBtn); // vc.StartPosition = FormStartPosition.CenterScreen; // vc.Show(); } } private void ShowBtn(string btnname) { if(btnname== "DebugMove") { btnAbout.Enabled = true; } else if(btnname== "VarConfig") { btnLanguage.Enabled = true ; } } private void ClearSelectBtn() { btnMain.Selected = false; btnData.Selected = false; btnRecipe.Selected = false; btnSystem.Selected = false; btnAbout.Selected = false; btnPermission.Selected = false; btnLanguage.Selected = false; btnQuit.Selected = false; } private void Home2_Load(object sender, EventArgs e) { Ops.Init(); //SetFormStyle(); panel_main.Controls.Clear(); BaseForm form = ActiveForms.Get("FormMain"); if (form != null) { panel_main.Controls.Add(form); form.TopLevel = false; form.Dock = DockStyle.Fill; form.Visible = true; } else { form = new FormMain(); form.Name = "FormMain"; form.TopLevel = false; form.Dock = DockStyle.Fill; panel_main.Controls.Add(form); form.Visible = true; ActiveForms.Add(form); btnMain.Selected = true; } timer1.Enabled = true; } private void SetFormStyle() { this.StartPosition = FormStartPosition.Manual; this.FormBorderStyle = FormBorderStyle.None;//设置无边框 this.WindowState = FormWindowState.Maximized;//设置窗体最大化显示 this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;//设置窗体在无边框和最大化时不遮挡任务栏 } private void timer1_Tick(object sender, EventArgs e) { if(MachineManage.Instance.MachineStatus.ToString()!=lblMachineState.Text) lblMachineState.Text=MachineManage.Instance.MachineStatus.ToString(); } public override bool WindowsClose() { DialogResult dr = MessageBox.Show("确定要退出吗?", "提示", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) { Ops.Quit(); return true; } else { return false; } } } }