-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
89 lines (78 loc) · 2.8 KB
/
MainWindow.xaml.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
85
86
87
88
89
using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Windows_Explorer_Toggle
{
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
static class Globals
{
public static TextBlock toggleBTNtext = new TextBlock();
}
public MainWindow()
{
InitializeComponent();
Grid mainGrid = new Grid();
this.Content = mainGrid;
Button toggleBTN = new Button();
toggleBTN.Width = 175;
toggleBTN.Height = 23;
toggleBTN.Margin = new Thickness(0, -30, 0, 0);
toggleBTN.Click += toggleBTNclick;
WrapPanel toggleBTNwrap = new WrapPanel();
Globals.toggleBTNtext.Text = "Disable Windows Explorer";
toggleBTNwrap.Children.Add(Globals.toggleBTNtext);
toggleBTN.Content = toggleBTNwrap;
Button openBTN = new Button();
openBTN.Width = 175;
openBTN.Height = 23;
openBTN.Margin = new Thickness(0, 20, 0, 0);
openBTN.Click += openBTNclick;
WrapPanel openBTNwrap = new WrapPanel();
TextBlock openBTNtext = new TextBlock();
openBTNtext.Text = "Open Folder";
openBTNwrap.Children.Add(openBTNtext);
openBTN.Content = openBTNwrap;
mainGrid.Children.Add(toggleBTN);
mainGrid.Children.Add(openBTN);
}
private void openBTNclick(object sender, RoutedEventArgs e)
{
Process.Start(Directory.GetCurrentDirectory());
}
private void toggleBTNclick(object sender, RoutedEventArgs e)
{
if (Globals.toggleBTNtext.Text == "Disable Windows Explorer")
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c TASKKILL /F /IM explorer.exe";
process.StartInfo = startInfo;
process.Start();
Globals.toggleBTNtext.Text = "Enable Windows Explorer";
}
else{
Process.Start(@"C:\Windows\explorer.exe");
Globals.toggleBTNtext.Text = "Disable Windows Explorer";
}
}
}
}