FrmMenu.cs 3.9 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text; 
using System.Windows.Forms;  
using System.Diagnostics;
using System.IO;
using URSoldering.Common;
using URSoldering.DeviceLibrary;

namespace URSoldering.Client
{
    public partial class FrmMenu : FrmBase
    {
        /// <summary>
        /// 是否已经按了按钮,没有按时才会自动进入机器人焊接界面
        /// </summary>
        private bool isClick = false;
        public FrmMenu()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent(); 
            this.MaximizeBox = false;
            this.MinimizeBox = false;
             
        }
         
        private void btnWelding_Click(object sender, EventArgs e)
        {
            if (BoardManager.CurrBoard == null)
            {
                if (BoardManager.boardList.Count > 0)
                {
                    BoardManager.UpdateCurrBoard(BoardManager.boardList[0].boardId);
                }
                else
                {
                    MessageBox.Show("请先配置程序");
                    return;
                }
            }
            isClick = true;
            FrmWork fw = new FrmWork();
            this.Visible = false; ;
            fw.ShowDialog();
            this.Visible = true;
        }
      
        private void btnProduct_Click(object sender, EventArgs e)
        {
            isClick = true;
            FrmBoardList board = new FrmBoardList();
            this.Visible = false; ;
            board.ShowDialog();
            this.Visible = true;
        }
       
        private void btnDebug_Click(object sender, EventArgs e)
        {
            isClick = true;
            //FrmDebugMenu main = new FrmDebugMenu();
            FrmOrgConfig frmOrgConfig = new FrmOrgConfig();
            this.Visible = false;
            frmOrgConfig.ShowDialog();
            this.Visible = true;
        }
        private System.Timers.Timer timer = new System.Timers.Timer();
        private void FrmMenu_Load(object sender, EventArgs e)
        {
            //加载板卡
            WorkCountManager.LoadData();
            //SProgramManager.LoadData();
            BoardManager.LoadBoard(); 
            //ComponentManager.LoadData();
            RobotManager.InitRobotConfig(); 
            //RobotBean.ConnectionIO();
            this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
       
        } 
        
        private void FrmMenu_FormClosing(object sender, FormClosingEventArgs e)
        {
            isClick = true; 
         
            URRobotControl.StopRobot();
            KNDManager.CloseAllDO();
            KNDManager.CloseAllConnection();
            SolderingManager.Release();
            SendWireManager.Release();
            Application.Exit();
        }  
        private void FrmMenu_SizeChanged(object sender, EventArgs e)
        {
            return;
        }
         

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnProgram_Click(object sender, EventArgs e)
        { 
        }

        private void btnAutoEdit_Click(object sender, EventArgs e)
        {
            //isClick = true; 
            //FrmAutoAddBoard info = new FrmAutoAddBoard(null);
            //this.Visible = false;
            //info.ShowDialog();
            //this.Visible = true; 
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            URRobotControl.StartRobot();
            //URRobotManager.StartListen();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            URRobotControl.StopRobot();
            //URRobotManager.StopListen();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            URRobotControl.GetRobotMode();
        }
    }
}