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(picPreview, picDisplay);

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

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

        /// <summary>
        /// フォームロード
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e) {
            if (!_lucam.Connect()) {
                MessageBox.Show("カメラが見つかりません.\r\n終了します.", APP_NAME,
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Close();
            }
            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();
        }
    }
}