-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchwindow.cs
94 lines (73 loc) · 3.03 KB
/
searchwindow.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
90
91
92
93
94
using System;
using Gtk;
using System.Collections.Generic;
using UI = Gtk.Builder.ObjectAttribute;
using Appbatroz;
namespace Appbatroz
{
class searchwindow : Window
{
[UI] private Entry entry1 = null;
[UI] private TextView textview1 = null;
private int _counter;
string[] listexe;
public searchwindow() : this(new Builder("searchwindow.glade")) { }
private searchwindow(Builder builder) : base(builder.GetRawOwnedObject("searchwindow"))
{
string a = "";
builder.Autoconnect(this);
entry1.KeyReleaseEvent += OnEntry1KeyReleaseEvent;
foreach (string ln in ExecuteCommand())
{
a += ln+"\n";
}
textview1.Buffer.Text = a;
listexe= ExecuteCommand();
// DeleteEvent += Window_DeleteEvent;
// _button1.Clicked += Button1_Clicked;
}
public static string[] ExecuteCommand()
{
string[] ss ;
string command = "where *.exe &&cd c:\\Program Files && dir /s /b *.exe | findstr /v .exe. && cd c:\\Program Files (x86) && dir /s /b *.exe | findstr /v .exe.";
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C " + command;
process.StartInfo = startInfo;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
List<string> list = new List<string>();
//awk '/^Exec=/ {sub("^Exec=", ""); gsub(" ?%[cDdFfikmNnUuv]", ""); exit system($0)}' /usr/share/applications/libreoffice-calc.desktop
//(grep '^Exec' filename.desktop | tail -1 | sed 's/^Exec=//' \| sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g')
while (!process.StandardOutput.EndOfStream)
{
list.Add(process.StandardOutput.ReadLine());
}
process.Close();
ss = list.ToArray();
return ss;
}
protected void OnTextview1Shown(object sender, EventArgs e)
{
}
protected void OnEntry1KeyReleaseEvent(object o, KeyReleaseEventArgs args)
{
string a = "";
List<string> list = new List<string>();
foreach (string ms in listexe)
{
if (ms.ToLower().Contains(entry1.Text.ToLower()))
{
list.Add(ms);
}
}
foreach (string ln in list.ToArray())
{
a += ln + "\n";
}
textview1.Buffer.Text = a;
}
}
}