// Decompiled with JetBrains decompiler
// Type: HPG_68D.ComForm
// Assembly: HPG-68D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 530C99A8-8EEF-42C8-8A74-66FDE7B322C3
// Assembly location: C:\Program Files (x86)\HONGKAIDE\HPG-68D\HPG-68D.exe

using HPG_68D.My;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace HPG_68D
{
    [DesignerGenerated]
    public class ComForm : Form
    {
        private static ArrayList __ENCList = new ArrayList();
        private IContainer components;
        [AccessedThroughProperty("Button2")]
        private Button _Button2;
        [AccessedThroughProperty("Button1")]
        private Button _Button1;
        [AccessedThroughProperty("ComboBox1")]
        private ComboBox _ComboBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;

        [DebuggerNonUserCode]
        static ComForm()
        {
        }

        [DebuggerNonUserCode]
        public ComForm()
        {
            Load += ComForm_Load;
            __ENCList.Add(new WeakReference(this));
            InitializeComponent();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && components != null)
                components.Dispose();
            base.Dispose(disposing);
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            var componentResourceManager = new ComponentResourceManager(typeof(ComForm));
            Button2 = new Button();
            Button1 = new Button();
            ComboBox1 = new ComboBox();
            Label1 = new Label();
            SuspendLayout();
            Button2.AccessibleDescription = null;
            Button2.AccessibleName = null;
            componentResourceManager.ApplyResources(Button2, "Button2");
            Button2.BackgroundImage = null;
            Button2.Font = null;
            Button2.Name = "Button2";
            Button2.UseVisualStyleBackColor = true;
            Button1.AccessibleDescription = null;
            Button1.AccessibleName = null;
            componentResourceManager.ApplyResources(Button1, "Button1");
            Button1.BackgroundImage = null;
            Button1.Font = null;
            Button1.Name = "Button1";
            Button1.UseVisualStyleBackColor = true;
            ComboBox1.AccessibleDescription = null;
            ComboBox1.AccessibleName = null;
            componentResourceManager.ApplyResources(ComboBox1, "ComboBox1");
            ComboBox1.BackgroundImage = null;
            ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            ComboBox1.Font = null;
            ComboBox1.FormattingEnabled = true;
            ComboBox1.Name = "ComboBox1";
            Label1.AccessibleDescription = null;
            Label1.AccessibleName = null;
            componentResourceManager.ApplyResources(Label1, "Label1");
            Label1.Font = null;
            Label1.Name = "Label1";
            AccessibleDescription = null;
            AccessibleName = null;
            componentResourceManager.ApplyResources(this, "$this");
            AutoScaleMode = AutoScaleMode.Font;
            BackgroundImage = null;
            Controls.Add(Button2);
            Controls.Add(Button1);
            Controls.Add(ComboBox1);
            Controls.Add(Label1);
            Font = null;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox = false;
            MinimizeBox = false;
            Name = nameof(ComForm);
            ResumeLayout(false);
            PerformLayout();
        }

        internal virtual Button Button2
        {
            [DebuggerNonUserCode]
            get => _Button2;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (_Button2 != null)
                    _Button2.Click -= Button2_Click;
                _Button2 = value;
                if (_Button2 == null)
                    return;
                _Button2.Click += Button2_Click;
            }
        }

        internal virtual Button Button1
        {
            [DebuggerNonUserCode]
            get => _Button1;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (_Button1 != null)
                    _Button1.Click -= Button1_Click;
                _Button1 = value;
                if (_Button1 == null)
                    return;
                _Button1.Click += Button1_Click;
            }
        }

        internal virtual ComboBox ComboBox1
        {
            [DebuggerNonUserCode]
            get => _ComboBox1;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (_ComboBox1 != null)
                    _ComboBox1.MouseClick -= ComboBox1_MouseClick;
                _ComboBox1 = value;
                if (_ComboBox1 == null)
                    return;
                _ComboBox1.MouseClick += ComboBox1_MouseClick;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get => _Label1;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set => _Label1 = value;
        }

        private void ComForm_Load(object sender, EventArgs e)
        {
            ComboBox1.SelectedIndex = checked((int) publicva.COM_SelectIndex);
            Label1.Text = "Port";
        }

        private void ComboBox1_MouseClick(object sender, MouseEventArgs e)
        {
            var selectedIndex = ComboBox1.SelectedIndex;
            ComboBox1.Items.Clear();
            GetSerialPortNames();
            if (-1 == ComboBox1.FindString(ComboBox1.Text))
                ComboBox1.SelectedIndex = 0;
            else
                ComboBox1.SelectedIndex = selectedIndex;
        }

        private void Button1_Click(object sender, EventArgs e) => Close();

        public void GetSerialPortNames()
        {
            try
            {
                foreach (object serialPortName in MyProject.Computer.Ports.SerialPortNames)
                    ComboBox1.Items.Add(serialPortName);
            }
            finally
            {
            }

            if (ComboBox1.Items.Count >= 1)
                return;
            ComboBox1.Items.Add("COM1");
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            publicva.COM_SelectIndex = checked((uint) ComboBox1.SelectedIndex);
            MyProject.Forms.MDIParent1.SerialPort1.PortName = ComboBox1.Text;
            Close();
        }
    }
}