C# - How to add click event using source code

-3

1.How can i click the login button from the source code?

3.Someone recommend me to use OnLogintClick(null, null); but where and how to use it?

  1. Thank you guys for your future helps,

  2. This is the decompiled source in dnspy;

using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using Honeygain.Presenters;
using Honeygain.Properties;
using Honeygain.Utilities;
using Honeygain.Views.Controls;
using Honeygain.Views.Events;

namespace Honeygain.Views.Forms
{
    // Token: 0x0200000D RID: 13
    internal class LoginForm : BaseForm
    {
        // Token: 0x14000013 RID: 19
        // (add) Token: 0x06000073 RID: 115 RVA: 0x000034D0 File Offset: 0x000016D0
        // (remove) Token: 0x06000074 RID: 116 RVA: 0x00003508 File Offset: 0x00001708
        public event EventHandler<FormFailedEventArgs> LoginFailed;

        // Token: 0x14000014 RID: 20
        // (add) Token: 0x06000075 RID: 117 RVA: 0x00003540 File Offset: 0x00001740
        // (remove) Token: 0x06000076 RID: 118 RVA: 0x00003578 File Offset: 0x00001778
        public event EventHandler LoginFinished;

        // Token: 0x14000015 RID: 21
        // (add) Token: 0x06000077 RID: 119 RVA: 0x000035B0 File Offset: 0x000017B0
        // (remove) Token: 0x06000078 RID: 120 RVA: 0x000035E8 File Offset: 0x000017E8
        public event EventHandler LoginStarted;

        // Token: 0x14000016 RID: 22
        // (add) Token: 0x06000079 RID: 121 RVA: 0x00003620 File Offset: 0x00001820
        // (remove) Token: 0x0600007A RID: 122 RVA: 0x00003658 File Offset: 0x00001858
        public event EventHandler<FormRequestedEventArgs> SignupRequested;

        // Token: 0x0600007B RID: 123 RVA: 0x0000368D File Offset: 0x0000188D
        public LoginForm(IMainPresenter presenter)
        {
            this.InitializeComponent();
            this._presenter = presenter;
        }

        // Token: 0x0600007C RID: 124 RVA: 0x000036A2 File Offset: 0x000018A2
        private void OnFormVisibleChanged(object sender, EventArgs e)
        {
            this.authentication.Clear();
        }

        // Token: 0x0600007D RID: 125 RVA: 0x000036AF File Offset: 0x000018AF
        private void OnForgotPasswordClick(object sender, EventArgs e)
        {
            Websites.OpenForgotPassword();
        }

        // Token: 0x0600007E RID: 126 RVA: 0x000036B6 File Offset: 0x000018B6
        private void OnSignupClick(object sender, EventArgs e)
        {
            base.Hide();
            EventHandler<FormRequestedEventArgs> signupRequested = this.SignupRequested;
            if (signupRequested == null)
            {
                return;
            }
            signupRequested(this, new FormRequestedEventArgs
            {
                Location = base.Location
            });
        }

        // Token: 0x0600007F RID: 127 RVA: 0x000036E0 File Offset: 0x000018E0
        private void OnLoginClick(object sender, EventArgs e)
        {
            LoginForm.<OnLoginClick>d__17 <OnLoginClick>d__;
            <OnLoginClick>d__.<>4__this = this;
            <OnLoginClick>d__.<>t__builder = AsyncVoidMethodBuilder.Create();
            <OnLoginClick>d__.<>1__state = -1;
            <OnLoginClick>d__.<>t__builder.Start<LoginForm.<OnLoginClick>d__17>(ref <OnLoginClick>d__);
        }

        // Token: 0x06000080 RID: 128 RVA: 0x00003717 File Offset: 0x00001917
        private void PrepareLogin()
        {
            EventHandler loginStarted = this.LoginStarted;
            if (loginStarted != null)
            {
                loginStarted(this, EventArgs.Empty);
            }
            base.Enabled = false;
        }

        // Token: 0x06000081 RID: 129 RVA: 0x00003738 File Offset: 0x00001938
        private Task LoginAsync()
        {
            LoginForm.<LoginAsync>d__19 <LoginAsync>d__;
            <LoginAsync>d__.<>4__this = this;
            <LoginAsync>d__.<>t__builder = AsyncTaskMethodBuilder.Create();
            <LoginAsync>d__.<>1__state = -1;
            <LoginAsync>d__.<>t__builder.Start<LoginForm.<LoginAsync>d__19>(ref <LoginAsync>d__);
            return <LoginAsync>d__.<>t__builder.Task;
        }

        // Token: 0x06000082 RID: 130 RVA: 0x0000377B File Offset: 0x0000197B
        private void FailLogin(Exception exception)
        {
            base.Hide();
            EventHandler<FormFailedEventArgs> loginFailed = this.LoginFailed;
            if (loginFailed == null)
            {
                return;
            }
            loginFailed(this, new FormFailedEventArgs
            {
                Error = exception
            });
        }

        // Token: 0x06000083 RID: 131 RVA: 0x000037A0 File Offset: 0x000019A0
        private void FinalizeLogin()
        {
            base.Enabled = true;
            EventHandler loginFinished = this.LoginFinished;
            if (loginFinished == null)
            {
                return;
            }
            loginFinished(this, EventArgs.Empty);
        }

        // Token: 0x06000084 RID: 132 RVA: 0x000037BF File Offset: 0x000019BF
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        // Token: 0x06000085 RID: 133 RVA: 0x000037E0 File Offset: 0x000019E0
        private void InitializeComponent()
        {
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(LoginForm));
            this.panel = new TableLayoutPanel();
            this.message = new TableLayoutPanel();
            this.description = new Label();
            this.link = new Label();
            this.authentication = new AuthenticationControl();
            this.reset = new Label();
            this.login = new Button();
            this.banner = new PictureBox();
            this.title = new Label();
            this.panel.SuspendLayout();
            this.message.SuspendLayout();
            ((ISupportInitialize)this.banner).BeginInit();
            base.SuspendLayout();
            componentResourceManager.ApplyResources(this.panel, "panel");
            this.panel.Controls.Add(this.message, 0, 6);
            this.panel.Controls.Add(this.authentication, 0, 2);
            this.panel.Controls.Add(this.reset, 0, 3);
            this.panel.Controls.Add(this.login, 0, 5);
            this.panel.Controls.Add(this.banner, 0, 0);
            this.panel.Controls.Add(this.title, 0, 1);
            this.panel.Name = "panel";
            componentResourceManager.ApplyResources(this.message, "message");
            this.message.Controls.Add(this.description, 0, 0);
            this.message.Controls.Add(this.link, 1, 0);
            this.message.Name = "message";
            componentResourceManager.ApplyResources(this.description, "description");
            this.description.ForeColor = Color.FromArgb(14, 65, 88);
            this.description.Name = "description";
            componentResourceManager.ApplyResources(this.link, "link");
            this.link.Cursor = Cursors.Hand;
            this.link.ForeColor = Color.FromArgb(11, 152, 222);
            this.link.Name = "link";
            this.link.Click += this.OnSignupClick;
            componentResourceManager.ApplyResources(this.authentication, "authentication");
            this.authentication.Name = "authentication";
            this.authentication.EmailEntered += this.OnLoginClick;
            this.authentication.PasswordEntered += this.OnLoginClick;
            componentResourceManager.ApplyResources(this.reset, "reset");
            this.reset.Cursor = Cursors.Hand;
            this.reset.ForeColor = Color.FromArgb(11, 152, 222);
            this.reset.Name = "reset";
            this.reset.Click += this.OnForgotPasswordClick;
            componentResourceManager.ApplyResources(this.login, "login");
            this.login.BackColor = Color.FromArgb(11, 152, 222);
            this.login.ForeColor = Color.White;
            this.login.Name = "login";
            this.login.UseVisualStyleBackColor = false;
            this.login.Click += this.OnLoginClick;
            componentResourceManager.ApplyResources(this.banner, "banner");
            this.banner.Image = Resources.logo;
            this.banner.Name = "banner";
            this.banner.TabStop = false;
            componentResourceManager.ApplyResources(this.title, "title");
            this.title.ForeColor = Color.FromArgb(14, 65, 88);
            this.title.Name = "title";
            componentResourceManager.ApplyResources(this, "$this");
            base.Controls.Add(this.panel);
            base.Name = "LoginForm";
            base.VisibleChanged += this.OnFormVisibleChanged;
            this.panel.ResumeLayout(false);
            this.panel.PerformLayout();
            this.message.ResumeLayout(false);
            this.message.PerformLayout();
            ((ISupportInitialize)this.banner).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        // Token: 0x04000014 RID: 20
        private readonly IMainPresenter _presenter;

        // Token: 0x04000019 RID: 25
        private IContainer components;

        // Token: 0x0400001A RID: 26
        private TableLayoutPanel panel;

        // Token: 0x0400001B RID: 27
        private TableLayoutPanel message;

        // Token: 0x0400001C RID: 28
        private Label description;

        // Token: 0x0400001D RID: 29
        private Label link;

        // Token: 0x0400001E RID: 30
        private AuthenticationControl authentication;

        // Token: 0x0400001F RID: 31
        private Label reset;

        // Token: 0x04000020 RID: 32
        private Button login;

        // Token: 0x04000021 RID: 33
        private PictureBox banner;

        // Token: 0x04000022 RID: 34
        private Label title;
    }
}

. Thank you guys for your future helps, . Thank you guys for your future helps, 4. Thank you guys for your future helps, 4. Thank you guys for your future helps,

c#
debugging
buttonclick
decompiler
asked on Stack Overflow Sep 29, 2020 by Codforc • edited Sep 29, 2020 by Codforc

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0