SettingControl.cs 5.8 KB
using CodeLibrary;
using ConfigHelper;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineStore.XLRStore
{
    public partial class SettingControl : UserControl
    {
        public SettingControl()
        {
            InitializeComponent();
            //RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
            ////chbAutoRun.Enabled = false;
            //chbAutoRun.Checked = Convert.ToBoolean(ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun));
            //this.chbAutoRun.CheckedChanged += new System.EventHandler(this.chbAutoRun_CheckedChanged);
            ////chbAutoRun.Enabled = true;
        }

        private void RobotManage_LoadFinishEvent(bool state, string msg)
        {
            //if (!state)
            //    return;
            //cb_printerselect.Items.Clear();
            //cb_labelselect.Items.Clear();
            //foreach (string sPrint in System.Drawing.Printing.PrinterSettings.InstalledPrinters)//获取所有打印机名称
            //{
            //    cb_printerselect.Items.Add(sPrint);
            //}
            //if (RobotManage.PrintBean != null)
            //{
            //    foreach (string labelname in RobotManage.PrintBean.GetLabelName())
            //    {
            //        cb_labelselect.Items.Add(labelname);
            //    }
            //}
            //string PrintName = ConfigHelper.Config.Get(Setting_Init.PrinterName);
            //string labelName = ConfigHelper.Config.Get(Setting_Init.LabelName);
            //cb_printerselect.Text = PrintName;
            //cb_labelselect.Text = labelName;

           
        }


        private void SettingControl_Load(object sender, EventArgs e)
        {

        }

        private void cb_printerselect_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Config.Set(Setting_Init.PrinterName, (sender as ComboBox).Text);
            //RobotManage.LoadPrintSetting();
        }

        private void cb_labelselect_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Config.Set(Setting_Init.LabelName, (sender as ComboBox).Text);
            //RobotManage.LoadPrintSetting();
        }

        private void btn_labeledit_Click(object sender, EventArgs e)
        {
            //RobotManage.PrintBean.EditLabel();
            //RobotManage_LoadFinishEvent(true, "");
            //RobotManage.LoadPrintSetting();
        }

        public static void AutoRun(string strName, bool value)
        {
            try
            {
                //创建启动对象 
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                //设置运行文件
                startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
                //设置启动参数 
                startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
                //设置启动动作,确保以管理员身份运行
                startInfo.Verb = "runas";
                //如果不是管理员,则启动UAC 
                System.Diagnostics.Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void chbAutoRun_CheckedChanged(object sender, EventArgs e)
        {
            if (chbAutoRun.Checked)
            {
                ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
                AutoRun(Application.ExecutablePath, true);
            }
            else
            {
                ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
                AutoRun(Application.ExecutablePath, false);
            }
        }

        private void btn_labelDebug_Click(object sender, EventArgs e)
        {
            ////Bitmap bitmap = new Bitmap("16-51-26-94.bmp");
            ////List<CodeInfo> tlci = EyemDecode2.Decoder(ref bitmap);
            ////bitmap.Dispose();
            //List<CodeInfo> tlci = new List<CodeInfo>();
            //tlci.Add(new CodeInfo("", 413, 1809));
            //LabelParam labelParam = new LabelParam();
            //labelParam.codeInfos = tlci;
            //labelParam.bitmapfilename = @"D:\logs\827\15-02-40-402.bmp";

            //LabelParam aaa = labelParam.clone();
            //Point p = LabelManager.CalcLabelPoint(labelParam, RobotManage.Config.Label_R_Offset, RobotManage.Config.Label_R_Angle_Diff, out int labelAngle);

            ////计算贴标角度的脉冲值
            //int labelAxisPos = RobotManage.Config.Label_R_360 / 360 * labelAngle;

            ////计算像素点位与中心点的差
            //Point p1 = new Point(p.X - Right_Batch_Point.X, p.Y - Right_Batch_Point.Y);
            ////计算像素*脉冲像素比得到脉冲值+中心点基准脉冲
            //p1.X = (int)(p1.X * RobotManage.Config.Cam_Pixel_X_Ratio) + RobotManage.Config.Label_X_Base;
            //p1.Y = (int)(p1.Y * RobotManage.Config.Cam_Pixel_Y_Ratio) + RobotManage.Config.Label_Y_Base;

        }

        private void listEdit_pn_DataRefresh(object sender, EventArgs e)
        {
            LabelManager.LoadMatchList();
        }

        private void btn_codetest_Click(object sender, EventArgs e)
        {
            LabelContent labelParam = new LabelContent();
            labelParam.codeInfos = new List<CodeLibrary.CodeInfo>();
            labelParam.codeInfos.Add(new CodeLibrary.CodeInfo(txt_code.Text, 0, 0));
            LabelManager.CodeProcess(labelParam, out string debugstring);
            label_matchdebugstring.Text = debugstring;
        }
    }
}