ABaseControl.cs 3.1 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AOI;
using System.Drawing.Drawing2D;
using Acc.ImageBox;

namespace AccAOI.control
{
    public partial class ABaseControl : Form
    {
        public ABaseControl()
        {
            InitializeComponent();
        }
        public string TitleName
        {
            get { return panControl.Text; }
            set { panControl.Text = value; }
        }
        protected object UpdateLock = "";
        public Image GetImg()
        {
          return   FrmAoiSetting.BaseImg;
        }
        internal bool IsShowOk = false;
        /// <summary>
        /// 区域类型,1=矩形,2=圆形 
        /// </summary>
        public int AreaType = 1;

        /// <summary>
        /// 显示的图片类型,1=原图,2=效果图
        /// </summary>
        public int ShowImageType = 2;
        /// <summary>
        /// 区域信息
        /// </summary>
        protected GraphicsPath currPath = null;
      
        public AccImageBox BImageBox; 
        public AoiMethod AoiInfo;
        /// <summary>
        /// 未处理的小图
        /// </summary>
        protected Image CutImage = null;

        public void SetCurrPath(GraphicsPath path, bool isUpdate = true)
        {
            this.currPath = path;
            if (isUpdate)
            {
                UpdateImage();
            }

        }
        public virtual void UpdateImage()
        {

        }
        public virtual void ShowAoiInfo()
        {
            IsShowOk = true;
        }
        public virtual AoiMethod GetAoiInfo()
        {
            return AoiInfo;
        }

        private void btnSetArea_Click(object sender, EventArgs e)
        {
            if (AreaType.Equals(1))
            {
                AreaType = 2;
                panAreaSet.Text = "区域设置 - 椭圆";
                btnSetArea.Text = "矩形";
                BImageBox.SelectionMode = ImageBoxSelectionMode.Eclipse;
            }
            else
            {
                AreaType = 1;
                panAreaSet.Text = "区域设置 - 矩形";
                btnSetArea.Text = "椭圆";
                BImageBox.SelectionMode = ImageBoxSelectionMode.Rectangle;
            }
        }
         

        private void btnClearArea_Click(object sender, EventArgs e)
        {
         //   this.BImageBox.CleearArea();
            this.aoiImage.Image = null;
            BImageBox.SelectNone();
        }

        private void btnImgType_Click(object sender, EventArgs e)
        {
            if (btnImgType.Text.Equals("原图")) {
                ShowImageType = 1;
                btnImgType.Text = "效果图";
                panAreaImage.Text = "区域图 - 原图";
            }
            else
            {
                ShowImageType = 2;
                btnImgType.Text = "原图";
                panAreaImage.Text = "区域图像 - 效果图";
            }
            UpdateImage();
        }
    }

}