Newer
Older
TIASShot / TIASshot / Form1.cs
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 TIASshot {
    public partial class Form1 : Form {

        const string APP_NAME = "TIAS Shot";
        Lucam _lucam;

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Form1() {
            InitializeComponent();

            _lucam = new Lucam(this, picPreview, picDisplay);

            var version = Assembly.GetExecutingAssembly().GetName().Version;
            Text = $"{APP_NAME} ver.{version.Major}.{version.Minor}";
#if DEBUG
            Text += " [DEBUG]";
#endif
        }

        /// <summary>
        /// フォームロード
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e) {
            if (!_lucam.Connect()) {
                MessageBox.Show(_lucam.ErrorMsg, APP_NAME,
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Close();
                return;
            }
            txtDeviceName.Text = _lucam.DeviceName;
            txtSerialNo.Text = _lucam.SerialNumber;
            _lucam.StartStopPreview();
        }

        /// <summary>
        /// フォームクローズ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
            _lucam.Disconnect();
        }

        /// <summary>
        /// 画像撮影1枚
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnShot1_Click(object sender, EventArgs e) {
            _lucam.ShotOne();
        }

        /// <summary>
        /// 複数画像撮影
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnShotMulti_Click(object sender, EventArgs e) {
            _lucam.ShotMulti();
        }

        /// <summary>
        /// 校正
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalib_Click(object sender, EventArgs e) {
            _lucam.Calibration();
        }

        /// <summary>
        /// 動作チェックボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheck_Click(object sender, EventArgs e) {
            _lucam.Check();
        }
    }
}