-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm3.cs
84 lines (76 loc) · 2.93 KB
/
Form3.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace plato_saga
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
btn_abort.Enabled = true;
}
private void btn_abort_Click(object sender, EventArgs e)
{
btn_abort.Enabled = false;
pic.Enabled = false;
int num = 0;
Process[] localByName = Process.GetProcessesByName("obs64");
num = localByName.Length;
if (num > 0)
{
foreach (Process p in localByName)
{
try
{
Task t = Task.Run(() =>
{
WindowHelper.BringProcessToFront(p);
p.CloseMainWindow();
p.WaitForExit();
});
if (!t.Wait(3000))
{
p.Kill();
}
}
catch
{
Form1 frm1 = new Form1();
if (frm1.language == "es") MessageBox.Show("Error al cerrar OBS Studio. Debe cerrarlo para continuar: " + p.Id, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (frm1.language == "en") MessageBox.Show("An error occurred while closing OBS Studio. You need to close it to continue: " + p.Id, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Enabled = true;
return;
}
}
}
}
private void Form3_Load(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(plato_saga.Properties.Settings.Default.app_lang);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form3));
RefreshResources(this, resources);
timer1.Start();
}
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, Thread.CurrentThread.CurrentUICulture);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res); // recursion
ctrl.ResumeLayout(false);
}
}
}