// Decompiled with JetBrains decompiler
// Type: HPG_68D.PasswordForm
// 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;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;

namespace HPG_68D
{
    [DesignerGenerated]
    public class PasswordForm : Form
    {
        private static ArrayList __ENCList = new ArrayList();
        private IContainer components;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("TextBoxPassword")]
        private TextBox _TextBoxPassword;
        [AccessedThroughProperty("ButtonOK")]
        private Button _ButtonOK;
        [AccessedThroughProperty("ButtonCannel")]
        private Button _ButtonCannel;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("TextBox_NewPassword_R")]
        private TextBox _TextBox_NewPassword_R;
        [AccessedThroughProperty("CheckBox_WritePassword")]
        private CheckBox _CheckBox_WritePassword;
        [AccessedThroughProperty("CheckBox_ReadPassword")]
        private CheckBox _CheckBox_ReadPassword;
        [AccessedThroughProperty("GroupBox_ReadPassword")]
        private GroupBox _GroupBox_ReadPassword;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("TextBox_EnterPassword_R")]
        private TextBox _TextBox_EnterPassword_R;
        [AccessedThroughProperty("GroupBox_WritePassword")]
        private GroupBox _GroupBox_WritePassword;
        [AccessedThroughProperty("TextBox_OldPassword_W")]
        private TextBox _TextBox_OldPassword_W;
        [AccessedThroughProperty("Label4")]
        private Label _Label4;
        [AccessedThroughProperty("Label5")]
        private Label _Label5;
        [AccessedThroughProperty("Label6")]
        private Label _Label6;
        [AccessedThroughProperty("TextBox_EnterPassword_W")]
        private TextBox _TextBox_EnterPassword_W;
        [AccessedThroughProperty("TextBox_NewPassword_W")]
        private TextBox _TextBox_NewPassword_W;

        [DebuggerNonUserCode]
        static PasswordForm()
        {
        }

        [DebuggerNonUserCode]
        public PasswordForm()
        {
            Load += PasswordForm_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(PasswordForm));
            Label1 = new Label();
            TextBoxPassword = new TextBox();
            ButtonOK = new Button();
            ButtonCannel = new Button();
            Label2 = new Label();
            TextBox_NewPassword_R = new TextBox();
            CheckBox_WritePassword = new CheckBox();
            CheckBox_ReadPassword = new CheckBox();
            GroupBox_ReadPassword = new GroupBox();
            Label3 = new Label();
            TextBox_EnterPassword_R = new TextBox();
            GroupBox_WritePassword = new GroupBox();
            TextBox_OldPassword_W = new TextBox();
            Label4 = new Label();
            Label5 = new Label();
            Label6 = new Label();
            TextBox_EnterPassword_W = new TextBox();
            TextBox_NewPassword_W = new TextBox();
            GroupBox_ReadPassword.SuspendLayout();
            GroupBox_WritePassword.SuspendLayout();
            SuspendLayout();
            Label1.AccessibleDescription = null;
            Label1.AccessibleName = null;
            componentResourceManager.ApplyResources(Label1, "Label1");
            Label1.Font = null;
            Label1.Name = "Label1";
            TextBoxPassword.AccessibleDescription = null;
            TextBoxPassword.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBoxPassword, "TextBoxPassword");
            TextBoxPassword.BackgroundImage = null;
            TextBoxPassword.Font = null;
            TextBoxPassword.Name = "TextBoxPassword";
            ButtonOK.AccessibleDescription = null;
            ButtonOK.AccessibleName = null;
            componentResourceManager.ApplyResources(ButtonOK, "ButtonOK");
            ButtonOK.BackgroundImage = null;
            ButtonOK.Font = null;
            ButtonOK.Name = "ButtonOK";
            ButtonOK.UseVisualStyleBackColor = true;
            ButtonCannel.AccessibleDescription = null;
            ButtonCannel.AccessibleName = null;
            componentResourceManager.ApplyResources(ButtonCannel, "ButtonCannel");
            ButtonCannel.BackgroundImage = null;
            ButtonCannel.Font = null;
            ButtonCannel.Name = "ButtonCannel";
            ButtonCannel.UseVisualStyleBackColor = true;
            Label2.AccessibleDescription = null;
            Label2.AccessibleName = null;
            componentResourceManager.ApplyResources(Label2, "Label2");
            Label2.Font = null;
            Label2.Name = "Label2";
            TextBox_NewPassword_R.AccessibleDescription = null;
            TextBox_NewPassword_R.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBox_NewPassword_R, "TextBox_NewPassword_R");
            TextBox_NewPassword_R.BackgroundImage = null;
            TextBox_NewPassword_R.Font = null;
            TextBox_NewPassword_R.Name = "TextBox_NewPassword_R";
            CheckBox_WritePassword.AccessibleDescription = null;
            CheckBox_WritePassword.AccessibleName = null;
            componentResourceManager.ApplyResources(CheckBox_WritePassword, "CheckBox_WritePassword");
            CheckBox_WritePassword.BackgroundImage = null;
            CheckBox_WritePassword.Font = null;
            CheckBox_WritePassword.Name = "CheckBox_WritePassword";
            CheckBox_WritePassword.UseVisualStyleBackColor = true;
            CheckBox_ReadPassword.AccessibleDescription = null;
            CheckBox_ReadPassword.AccessibleName = null;
            componentResourceManager.ApplyResources(CheckBox_ReadPassword, "CheckBox_ReadPassword");
            CheckBox_ReadPassword.BackgroundImage = null;
            CheckBox_ReadPassword.Font = null;
            CheckBox_ReadPassword.Name = "CheckBox_ReadPassword";
            CheckBox_ReadPassword.UseVisualStyleBackColor = true;
            GroupBox_ReadPassword.AccessibleDescription = null;
            GroupBox_ReadPassword.AccessibleName = null;
            componentResourceManager.ApplyResources(GroupBox_ReadPassword, "GroupBox_ReadPassword");
            GroupBox_ReadPassword.BackgroundImage = null;
            GroupBox_ReadPassword.Controls.Add(TextBoxPassword);
            GroupBox_ReadPassword.Controls.Add(Label1);
            GroupBox_ReadPassword.Controls.Add(Label3);
            GroupBox_ReadPassword.Controls.Add(Label2);
            GroupBox_ReadPassword.Controls.Add(TextBox_EnterPassword_R);
            GroupBox_ReadPassword.Controls.Add(TextBox_NewPassword_R);
            GroupBox_ReadPassword.Font = null;
            GroupBox_ReadPassword.Name = "GroupBox_ReadPassword";
            GroupBox_ReadPassword.TabStop = false;
            Label3.AccessibleDescription = null;
            Label3.AccessibleName = null;
            componentResourceManager.ApplyResources(Label3, "Label3");
            Label3.Font = null;
            Label3.Name = "Label3";
            TextBox_EnterPassword_R.AccessibleDescription = null;
            TextBox_EnterPassword_R.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBox_EnterPassword_R, "TextBox_EnterPassword_R");
            TextBox_EnterPassword_R.BackgroundImage = null;
            TextBox_EnterPassword_R.Font = null;
            TextBox_EnterPassword_R.Name = "TextBox_EnterPassword_R";
            GroupBox_WritePassword.AccessibleDescription = null;
            GroupBox_WritePassword.AccessibleName = null;
            componentResourceManager.ApplyResources(GroupBox_WritePassword, "GroupBox_WritePassword");
            GroupBox_WritePassword.BackgroundImage = null;
            GroupBox_WritePassword.Controls.Add(TextBox_OldPassword_W);
            GroupBox_WritePassword.Controls.Add(Label4);
            GroupBox_WritePassword.Controls.Add(Label5);
            GroupBox_WritePassword.Controls.Add(Label6);
            GroupBox_WritePassword.Controls.Add(TextBox_EnterPassword_W);
            GroupBox_WritePassword.Controls.Add(TextBox_NewPassword_W);
            GroupBox_WritePassword.Font = null;
            GroupBox_WritePassword.Name = "GroupBox_WritePassword";
            GroupBox_WritePassword.TabStop = false;
            TextBox_OldPassword_W.AccessibleDescription = null;
            TextBox_OldPassword_W.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBox_OldPassword_W, "TextBox_OldPassword_W");
            TextBox_OldPassword_W.BackgroundImage = null;
            TextBox_OldPassword_W.Font = null;
            TextBox_OldPassword_W.Name = "TextBox_OldPassword_W";
            Label4.AccessibleDescription = null;
            Label4.AccessibleName = null;
            componentResourceManager.ApplyResources(Label4, "Label4");
            Label4.Font = null;
            Label4.Name = "Label4";
            Label5.AccessibleDescription = null;
            Label5.AccessibleName = null;
            componentResourceManager.ApplyResources(Label5, "Label5");
            Label5.Font = null;
            Label5.Name = "Label5";
            Label6.AccessibleDescription = null;
            Label6.AccessibleName = null;
            componentResourceManager.ApplyResources(Label6, "Label6");
            Label6.Font = null;
            Label6.Name = "Label6";
            TextBox_EnterPassword_W.AccessibleDescription = null;
            TextBox_EnterPassword_W.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBox_EnterPassword_W, "TextBox_EnterPassword_W");
            TextBox_EnterPassword_W.BackgroundImage = null;
            TextBox_EnterPassword_W.Font = null;
            TextBox_EnterPassword_W.Name = "TextBox_EnterPassword_W";
            TextBox_NewPassword_W.AccessibleDescription = null;
            TextBox_NewPassword_W.AccessibleName = null;
            componentResourceManager.ApplyResources(TextBox_NewPassword_W, "TextBox_NewPassword_W");
            TextBox_NewPassword_W.BackgroundImage = null;
            TextBox_NewPassword_W.Font = null;
            TextBox_NewPassword_W.Name = "TextBox_NewPassword_W";
            AccessibleDescription = null;
            AccessibleName = null;
            componentResourceManager.ApplyResources(this, "$this");
            AutoScaleMode = AutoScaleMode.Font;
            BackgroundImage = null;
            Controls.Add(GroupBox_WritePassword);
            Controls.Add(GroupBox_ReadPassword);
            Controls.Add(CheckBox_ReadPassword);
            Controls.Add(CheckBox_WritePassword);
            Controls.Add(ButtonCannel);
            Controls.Add(ButtonOK);
            Font = null;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox = false;
            MinimizeBox = false;
            Name = nameof(PasswordForm);
            GroupBox_ReadPassword.ResumeLayout(false);
            GroupBox_ReadPassword.PerformLayout();
            GroupBox_WritePassword.ResumeLayout(false);
            GroupBox_WritePassword.PerformLayout();
            ResumeLayout(false);
            PerformLayout();
        }

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

        internal virtual TextBox TextBoxPassword
        {
            [DebuggerNonUserCode]
            get => _TextBoxPassword;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBoxPassword = value; }
        }

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

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

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

        internal virtual TextBox TextBox_NewPassword_R
        {
            [DebuggerNonUserCode]
            get => _TextBox_NewPassword_R;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBox_NewPassword_R = value; }
        }

        internal virtual CheckBox CheckBox_WritePassword
        {
            [DebuggerNonUserCode]
            get => _CheckBox_WritePassword;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (_CheckBox_WritePassword != null)
                    _CheckBox_WritePassword.CheckedChanged -= CheckBox_WritePassword_CheckedChanged;
                _CheckBox_WritePassword = value;
                if (_CheckBox_WritePassword == null)
                    return;
                _CheckBox_WritePassword.CheckedChanged += CheckBox_WritePassword_CheckedChanged;
            }
        }

        internal virtual CheckBox CheckBox_ReadPassword
        {
            [DebuggerNonUserCode]
            get => _CheckBox_ReadPassword;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (_CheckBox_ReadPassword != null)
                    _CheckBox_ReadPassword.CheckedChanged -= CheckBox_ReadPassword_CheckedChanged;
                _CheckBox_ReadPassword = value;
                if (_CheckBox_ReadPassword == null)
                    return;
                _CheckBox_ReadPassword.CheckedChanged += CheckBox_ReadPassword_CheckedChanged;
            }
        }

        internal virtual GroupBox GroupBox_ReadPassword
        {
            [DebuggerNonUserCode]
            get => _GroupBox_ReadPassword;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _GroupBox_ReadPassword = value; }
        }

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

        internal virtual TextBox TextBox_EnterPassword_R
        {
            [DebuggerNonUserCode]
            get => _TextBox_EnterPassword_R;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBox_EnterPassword_R = value; }
        }

        internal virtual GroupBox GroupBox_WritePassword
        {
            [DebuggerNonUserCode]
            get => _GroupBox_WritePassword;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _GroupBox_WritePassword = value; }
        }

        internal virtual TextBox TextBox_OldPassword_W
        {
            [DebuggerNonUserCode]
            get => _TextBox_OldPassword_W;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBox_OldPassword_W = value; }
        }

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

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

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

        internal virtual TextBox TextBox_EnterPassword_W
        {
            [DebuggerNonUserCode]
            get => _TextBox_EnterPassword_W;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBox_EnterPassword_W = value; }
        }

        internal virtual TextBox TextBox_NewPassword_W
        {
            [DebuggerNonUserCode]
            get => _TextBox_NewPassword_W;
            [DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)]
            set { _TextBox_NewPassword_W = value; }
        }

        private void PasswordForm_Load(object sender, EventArgs e)
        {
            var num = 0;
            MyProject.Forms.MDIParent1.SetControl_U8_Data(CheckBox_ReadPassword, checked(num + 11), publicva.Bit5, 0);
            MyProject.Forms.MDIParent1.SetControl_U8_Data(CheckBox_WritePassword, checked(num + 11), publicva.Bit6, 0);
            CheckBox_ReadPassword_CheckedChanged(RuntimeHelpers.GetObjectValue(sender), e);
            CheckBox_WritePassword_CheckedChanged(RuntimeHelpers.GetObjectValue(sender), e);
        }

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

        private void ButtonOK_Click(object sender, EventArgs e)
        {
            var num1 = 60;
            var Right1 = Strings.RTrim(Encoding.ASCII.GetString(publicva.EEPROM_Byte, checked(num1 + 0), 16));
            var num2 = 70;
            var Right2 = Strings.RTrim(Encoding.ASCII.GetString(publicva.EEPROM_Byte, checked(num2 + 0), 16));
            var num3 = 0;
            if ((publicva.EEPROM_Byte[checked(num3 + 11)] & (uint) publicva.Bit5) > 0U)
            {
                if (Operators.CompareString(TextBoxPassword.Text, Right1, false) == 0)
                {
                    if (Operators.CompareString(TextBox_NewPassword_R.Text, TextBox_EnterPassword_R.Text, false) == 0)
                    {
                        Encoding.ASCII.GetBytes(TextBox_NewPassword_R.Text.PadRight(16), 0, 16, publicva.EEPROM_Byte, 60);
                    }
                    else
                    {
                        MyProject.Forms.ChannelMsg.Msgbox_Msg("Enter a password different!");
                        TextBox_NewPassword_R.Text = "";
                        TextBox_EnterPassword_R.Text = "";
                        return;
                    }
                }
                else
                {
                    MyProject.Forms.ChannelMsg.Msgbox_Msg("The old password is wrong!");
                    TextBoxPassword.Text = "";
                    TextBox_NewPassword_R.Text = "";
                    TextBox_EnterPassword_R.Text = "";
                    return;
                }
            }
            else if (Operators.CompareString(TextBox_NewPassword_R.Text, TextBox_EnterPassword_R.Text, false) == 0)
            {
                Encoding.ASCII.GetBytes(TextBox_NewPassword_R.Text.PadRight(16), 0, 16, publicva.EEPROM_Byte, 60);
            }
            else
            {
                MyProject.Forms.ChannelMsg.Msgbox_Msg("Enter a password different!");
                TextBox_NewPassword_R.Text = "";
                TextBox_EnterPassword_R.Text = "";
                return;
            }

            if ((publicva.EEPROM_Byte[checked(num3 + 11)] & (uint) publicva.Bit6) > 0U)
            {
                if (Operators.CompareString(TextBox_OldPassword_W.Text, Right2, false) == 0)
                {
                    if (Operators.CompareString(TextBox_NewPassword_W.Text, TextBox_EnterPassword_W.Text, false) == 0)
                    {
                        Encoding.ASCII.GetBytes(TextBox_NewPassword_W.Text.PadRight(16), 0, 16, publicva.EEPROM_Byte, 70);
                    }
                    else
                    {
                        MyProject.Forms.ChannelMsg.Msgbox_Msg("Enter a password different!");
                        TextBox_NewPassword_W.Text = "";
                        TextBox_EnterPassword_W.Text = "";
                        return;
                    }
                }
                else
                {
                    MyProject.Forms.ChannelMsg.Msgbox_Msg("The old password is wrong!");
                    TextBox_OldPassword_W.Text = "";
                    TextBox_NewPassword_W.Text = "";
                    TextBox_EnterPassword_W.Text = "";
                    return;
                }
            }
            else if (Operators.CompareString(TextBox_NewPassword_W.Text, TextBox_EnterPassword_W.Text, false) == 0)
            {
                Encoding.ASCII.GetBytes(TextBox_NewPassword_W.Text.PadRight(16), 0, 16, publicva.EEPROM_Byte, 70);
            }
            else
            {
                MyProject.Forms.ChannelMsg.Msgbox_Msg("Enter a password different!");
                TextBox_NewPassword_W.Text = "";
                TextBox_EnterPassword_W.Text = "";
                return;
            }

            publicva.EEPROM_Byte[checked(num3 + 11)] = Operators.CompareString(TextBox_NewPassword_R.Text, "", false) != 0
                ? (byte) (publicva.EEPROM_Byte[checked(num3 + 11)] | publicva.Bit5)
                : (byte) (publicva.EEPROM_Byte[checked(num3 + 11)] & ~publicva.Bit5);
            publicva.EEPROM_Byte[checked(num3 + 11)] = Operators.CompareString(TextBox_NewPassword_W.Text, "", false) != 0
                ? (byte) (publicva.EEPROM_Byte[checked(num3 + 11)] | publicva.Bit6)
                : (byte) (publicva.EEPROM_Byte[checked(num3 + 11)] & ~publicva.Bit6);
            if (!MyProject.Forms.MDIParent1.MSCcomm_StartInit("Write_Password", publicva.WPassword_EEPROM_Add_Lendgth_List))
                ;
            Close();
        }

        private void CheckBox_ReadPassword_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBox_ReadPassword.Checked)
            {
                GroupBox_ReadPassword.Enabled = true;
            }
            else
            {
                GroupBox_ReadPassword.Enabled = false;
                TextBoxPassword.Text = "";
                TextBox_NewPassword_R.Text = "";
                TextBox_EnterPassword_R.Text = "";
            }
        }

        private void CheckBox_WritePassword_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBox_WritePassword.Checked)
            {
                GroupBox_WritePassword.Enabled = true;
            }
            else
            {
                GroupBox_WritePassword.Enabled = false;
                TextBox_OldPassword_W.Text = "";
                TextBox_NewPassword_W.Text = "";
                TextBox_EnterPassword_W.Text = "";
            }
        }
    }
}