// 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.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
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()
    {
      this.Load += new EventHandler(this.ComForm_Load);
      ComForm.__ENCList.Add((object) new WeakReference((object) this));
      this.InitializeComponent();
    }

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

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

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

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

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

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

    private void ComForm_Load(object sender, EventArgs e)
    {
      this.ComboBox1.SelectedIndex = checked ((int) publicva.COM_SelectIndex);
      if (Operators.CompareString(publicva.Language, "zh-CN", false) == 0)
        this.Label1.Text = "通信端口";
      else
        this.Label1.Text = "Port";
    }

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

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

    public void GetSerialPortNames()
    {
      try
      {
        foreach (object serialPortName in MyProject.Computer.Ports.SerialPortNames)
          this.ComboBox1.Items.Add(serialPortName);
      }
      finally
      {
      }
      if (this.ComboBox1.Items.Count >= 1)
        return;
      this.ComboBox1.Items.Add((object) "COM1");
    }

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