Exemple #1
0
        private static void RetrieveKoi(ConfuserContext ctx)
        {
            if (settings.NoUI)
            {
                ctx.Logger.Debug("Retrieving Koi...");

                var sys  = new KoiSystem();
                var hnd  = new ManualResetEvent(false);
                var okay = false;
                sys.Progress += _ => { };
                sys.Finish   += f =>
                {
                    okay = f;
                    hnd.Set();
                };
                sys.Login(settings.KoiID);
                hnd.WaitOne();
                if (!okay)
                {
                    throw new InvalidOperationException("Authentication failed.");
                }
            }
            else
            {
                Application.EnableVisualStyles();
                if (new LoginPrompt {
                    TopLevel = true
                }.ShowDialog() != DialogResult.OK)
                {
                    throw new InvalidOperationException("Authentication failed.");
                }
            }
        }
Exemple #2
0
        static void CheckUpdate(ConfuserContext ctx)
        {
            var ver = new KoiSystem().GetVersion(settings.KoiID);

            if (ver == settings.Version)
            {
                return;
            }

            ctx.Logger.DebugFormat("New version of KoiVM: {0}", ver);
            ctx.Logger.DebugFormat("Current version of KoiVM: {0}", settings.Version);

            if (settings.NoUI)
            {
                ctx.Logger.DebugFormat("Updating...");
                var  sys  = new KoiSystem();
                var  hnd  = new ManualResetEvent(false);
                bool okay = false;
                sys.Progress += _ => { };
                sys.Finish   += f => {
                    okay = f;
                    hnd.Set();
                };
                sys.Login(settings.KoiID);
                hnd.WaitOne();
                if (!okay)
                {
                    throw new InvalidOperationException("Authentication failed.");
                }
                else
                {
                    settings.Version = ver;
                    settings.Save();
                }
            }
            else
            {
                Application.EnableVisualStyles();
                if (new UpdatePrompt(ver)
                {
                    TopLevel = true
                }.ShowDialog() != DialogResult.OK)
                {
                    throw new InvalidOperationException("Authentication failed.");
                }
            }
        }
Exemple #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.btnLogin.Enabled  = false;
            this.txtId.Enabled     = false;
            KoiInfo.settings.KoiID = this.txtId.Text;
            KoiInfo.settings.Save();

            var    sys = new KoiSystem();
            string ver = sys.GetVersion(KoiInfo.settings.KoiID);

            sys.Progress += value => this.BeginInvoke(new Action(() =>
            {
                if (value != 0)
                {
                    this.progress.Style = ProgressBarStyle.Continuous;
                    this.progress.Value = (int)(value * 1000);
                }
                else
                {
                    this.progress.Value = 0;
                    this.progress.Style = ProgressBarStyle.Marquee;
                }
            }));
            sys.Finish += success =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    this.btnLogin.Enabled = true;
                    this.txtId.Enabled    = true;
                    if (!success)
                    {
                        KoiInfo.settings.Version = "";
                        KoiInfo.settings.Save();
                        MessageBox.Show("Login failed.", "Koi System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        KoiInfo.settings.Version = ver;
                        KoiInfo.settings.Save();
                        this.DialogResult = DialogResult.OK;
                    }
                }));
            };
            sys.Login(this.txtId.Text);
        }
Exemple #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            btnUpdate.Enabled = false;

            var sys = new KoiSystem();

            sys.Progress += value => BeginInvoke(new Action(() =>
            {
                if (value == 0)
                {
                    progress.Value = 0;
                    progress.Style = ProgressBarStyle.Marquee;
                }
                else
                {
                    progress.Style = ProgressBarStyle.Continuous;
                    progress.Value = (int)(value * 1000);
                }
            }));
            sys.Finish += success =>
            {
                BeginInvoke(new Action(() =>
                {
                    btnUpdate.Enabled = true;

                    if (success)
                    {
                        KoiInfo.settings.Version = newVersion;
                        KoiInfo.settings.Save();
                        DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        failed = true;
                        KoiInfo.settings.Version = "";
                        KoiInfo.settings.Save();
                        MessageBox.Show("Login failed.", "Koi System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));
            };
            sys.Login(KoiInfo.settings.KoiID);
        }
        private void btnDl_Click(object sender, EventArgs e)
        {
            this.txtId.Enabled = this.btnRefr.Enabled = this.btnDl.Enabled = false;

            var    sys = new KoiSystem();
            string ver = sys.GetVersion(KoiInfo.settings.KoiID);

            sys.Progress += value => this.BeginInvoke(new Action(() =>
            {
                if (value != 0)
                {
                    this.progress.Style = ProgressBarStyle.Continuous;
                    this.progress.Value = (int)(value * 1000);
                }
                else
                {
                    this.progress.Value = 0;
                    this.progress.Style = ProgressBarStyle.Marquee;
                }
            }));
            sys.Finish += success =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    this.txtId.Enabled = this.btnRefr.Enabled = this.btnDl.Enabled = true;
                    if (success)
                    {
                        this.verCurrent.Text = KoiInfo.settings.Version = ver;
                        MessageBox.Show("Download finished.", "Koi System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        this.verCurrent.Text     = "<< None >>";
                        KoiInfo.settings.Version = "";
                        MessageBox.Show("Login failed.", "Koi System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));
            };
            sys.Login(this.txtId.Text);
        }