|
|
1.1 root 1: using CleanFlashCommon;
2: using System;
3: using System.Diagnostics;
4: using System.Threading.Tasks;
5: using System.Windows.Forms;
6:
7: namespace CleanFlashUninstaller {
8: public partial class UninstallForm : Form, IProgressForm {
9: private static int UNINSTALL_TICKS = 9;
10:
11: public UninstallForm() {
12: InitializeComponent();
13: }
14:
15: private void HideAllPanels() {
16: beforeInstallPanel.Visible = false;
17: installPanel.Visible = false;
18: completePanel.Visible = false;
19: failurePanel.Visible = false;
20: }
21:
22: private void OpenBeforeInstall() {
23: HideAllPanels();
24: beforeInstallPanel.Visible = true;
25: prevButton.Enabled = true;
26: nextButton.Text = "UNINSTALL";
27: }
28:
29: private void OpenInstall() {
30: HideAllPanels();
31: installPanel.Visible = true;
32: prevButton.Enabled = false;
33: nextButton.Visible = false;
34: BeginInstall();
35: }
36:
37: private void OpenComplete() {
38: HideAllPanels();
39: completePanel.Visible = true;
40: prevButton.Enabled = true;
41:
42: completeLabel.Links.Clear();
43: completeLabel.Links.Add(new LinkLabel.Link(110, 28));
44: }
45:
46: private void OpenFailure(Exception e) {
47: HideAllPanels();
48: failurePanel.Visible = true;
49: prevButton.Enabled = true;
50: nextButton.Text = "RETRY";
51: nextButton.Visible = true;
52: failureBox.Text = e.ToString();
53: }
54:
55: private void BeginInstall() {
56: progressBar.Value = 0;
57: progressBar.Maximum = UNINSTALL_TICKS;
58:
59: new Task(new Action(() => {
60: IntPtr redirection = RedirectionManager.DisableRedirection();
61:
62: try {
63: Uninstaller.Uninstall(this);
64: Complete();
65: } catch (Exception e) {
66: Failure(e);
67: } finally {
68: RedirectionManager.EnableRedirection(redirection);
69: }
70: })).Start();
71: }
72:
73: private void UninstallForm_Load(object sender, EventArgs e) {
74: string version = UpdateChecker.GetFlashVersion();
75:
76: subtitleLabel.Text = string.Format("built from version {0} (China)", version);
77: Text = string.Format("Clean Flash Player {0} Uninstaller", version);
78:
79: OpenBeforeInstall();
80: }
81:
82: private void prevButton_Click(object sender, EventArgs e) {
83: Application.Exit();
84: }
85:
86: private void nextButton_Click(object sender, EventArgs e) {
87: if (beforeInstallPanel.Visible || failurePanel.Visible) {
88: OpenInstall();
89: }
90: }
91:
92: public void UpdateProgressLabel(string text, bool tick) {
93: Invoke(new Action(() => {
94: progressLabel.Text = text;
95:
96: if (tick) {
97: progressBar.Value++;
98: }
99: }));
100: }
101:
102: public void TickProgress() {
103: Invoke(new Action(() => {
104: progressBar.Value++;
105: }));
106: }
107:
108: public void Complete() {
109: Invoke(new Action(OpenComplete));
110: }
111:
112: public void Failure(Exception e) {
113: Invoke(new Action(() => OpenFailure(e)));
114: }
115:
116: private void completeLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
117: if (e.Link.Start == 212) {
118: Process.Start("https://waterfox.net");
119: } else {
120: Process.Start("https://cleanflash.github.io");
121: }
122: }
123:
124: private void copyErrorButton_Click(object sender, EventArgs e) {
125: Clipboard.SetText(failureBox.Text);
126: MessageBox.Show("Copied error message to clipboard!", "Clean Flash Installer", MessageBoxButtons.OK, MessageBoxIcon.Information);
127: }
128: }
129: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.