Ejemplo n.º 1
0
        private void AddressChanged(object sender, AddressChangedEventArgs e)
        {
            Console.WriteLine(e.Address);
            form.BeginInvoke(new MethodInvoker(delegate()
            {
                try
                {
                    Uri infos = new Uri(e.Address);
                    NameValueCollection vars = HttpUtility.ParseQueryString(infos.Query);

                    if (vars.AllKeys.Count() != 0 && !vars.AllKeys.Contains("refresh"))
                    {
                        web.LoadHtml(htmlReload, Path.GetDirectoryName(Application.ExecutablePath) + @"\HTML\Comments.html");
                    }

                    if (vars.AllKeys.Contains("comment"))
                    {
                        if (!String.IsNullOrWhiteSpace(vars.Get("comment")))
                        {
                            if (Networking.SendComment(form, id, vars.Get("comment"), vars.Get("reply")))
                            {
                                LoadComments(id, form, author);
                            }
                        }
                    }
                    else if (vars.AllKeys.Contains("delete"))
                    {
                        DialogResult result = MetroFramework.MetroMessageBox.Show(form, "Do you really want to delete the comment and all the replys to it?", "Delete Comment", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, 100);
                        if (result == DialogResult.Yes)
                        {
                            if (Networking.DeleteComment(form, vars.Get("delete")))
                            {
                                LoadComments(id, form, author);
                            }
                            else
                            {
                                MetroFramework.MetroMessageBox.Show(form, "Could't delete your comment. Please try again later.", "Could not delete comment", MessageBoxButtons.OK, MessageBoxIcon.Error, 100);
                            }
                        }
                    }
                    else if (vars.AllKeys.Contains("refresh"))
                    {
                        LoadComments(id, form, author);
                    }
                    else if (vars.AllKeys.Contains("discord"))
                    {
                        Process.Start("http://discord.gg/KDe7Vyu");
                    }
                }
                catch { web.Load(Path.GetDirectoryName(Application.ExecutablePath) + @"\HTML\CommentError.html"); }
            }));
        }