From 788304276860fae57bfa246adcfc75a168f46ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Taljaard?= Date: Thu, 9 Oct 2014 10:04:09 +0200 Subject: [PATCH] Some changes. Still borked! --- .../Kill It With Fire!.vbproj | 4 + .../My Project/AssemblyInfo.vb | 6 +- .../Kill It With Fire!/Prompt.Designer.vb | 115 +++++++++++------- .../Kill It With Fire!/Prompt.vb | 23 ++++ Kill It With Fire!/Kill It With Fire!/kill.vb | 18 ++- 5 files changed, 116 insertions(+), 50 deletions(-) diff --git a/Kill It With Fire!/Kill It With Fire!/Kill It With Fire!.vbproj b/Kill It With Fire!/Kill It With Fire!/Kill It With Fire!.vbproj index 6dcf762..73b3107 100644 --- a/Kill It With Fire!/Kill It With Fire!/Kill It With Fire!.vbproj +++ b/Kill It With Fire!/Kill It With Fire!/Kill It With Fire!.vbproj @@ -68,6 +68,9 @@ ManagedMinimumRules.ruleset true + + My Project\app.manifest + @@ -138,6 +141,7 @@ + MyApplicationCodeGenerator Application.Designer.vb diff --git a/Kill It With Fire!/Kill It With Fire!/My Project/AssemblyInfo.vb b/Kill It With Fire!/Kill It With Fire!/My Project/AssemblyInfo.vb index c370548..8bc7a34 100644 --- a/Kill It With Fire!/Kill It With Fire!/My Project/AssemblyInfo.vb +++ b/Kill It With Fire!/Kill It With Fire!/My Project/AssemblyInfo.vb @@ -9,7 +9,7 @@ Imports System.Runtime.InteropServices ' Review the values of the assembly attributes - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/Kill It With Fire!/Kill It With Fire!/Prompt.Designer.vb b/Kill It With Fire!/Kill It With Fire!/Prompt.Designer.vb index 92f8c04..84dfb6f 100644 --- a/Kill It With Fire!/Kill It With Fire!/Prompt.Designer.vb +++ b/Kill It With Fire!/Kill It With Fire!/Prompt.Designer.vb @@ -22,72 +22,103 @@ Partial Class Prompt 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.Button1 = New System.Windows.Forms.Button() - Me.Button2 = New System.Windows.Forms.Button() - Me.CheckBox1 = New System.Windows.Forms.CheckBox() - Me.Label1 = New System.Windows.Forms.Label() + Me.btn_yes = New System.Windows.Forms.Button() + Me.btn_no = New System.Windows.Forms.Button() + Me.chk_all = New System.Windows.Forms.CheckBox() + Me.label_procCurrent = New System.Windows.Forms.Label() + Me.label_procDetails = New System.Windows.Forms.Label() + Me.panel_buttons = New System.Windows.Forms.Panel() + Me.panel_buttons.SuspendLayout() Me.SuspendLayout() ' - 'Button1 + 'btn_yes ' - Me.Button1.Location = New System.Drawing.Point(41, 52) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 0 - Me.Button1.Text = "Yes" - Me.Button1.UseVisualStyleBackColor = True + Me.btn_yes.Location = New System.Drawing.Point(3, 4) + Me.btn_yes.Name = "btn_yes" + Me.btn_yes.Size = New System.Drawing.Size(75, 23) + Me.btn_yes.TabIndex = 0 + Me.btn_yes.Text = "Yes" + Me.btn_yes.UseVisualStyleBackColor = True ' - 'Button2 + 'btn_no ' - Me.Button2.Location = New System.Drawing.Point(164, 52) - Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(75, 23) - Me.Button2.TabIndex = 1 - Me.Button2.Text = "No" - Me.Button2.UseVisualStyleBackColor = True + Me.btn_no.Location = New System.Drawing.Point(120, 3) + Me.btn_no.Name = "btn_no" + Me.btn_no.Size = New System.Drawing.Size(75, 23) + Me.btn_no.TabIndex = 1 + Me.btn_no.Text = "No" + Me.btn_no.UseVisualStyleBackColor = True ' - 'CheckBox1 + 'chk_all ' - Me.CheckBox1.AutoSize = True - Me.CheckBox1.Location = New System.Drawing.Point(115, 81) - Me.CheckBox1.Name = "CheckBox1" - Me.CheckBox1.Size = New System.Drawing.Size(52, 17) - Me.CheckBox1.TabIndex = 2 - Me.CheckBox1.Text = "To all" - Me.CheckBox1.UseVisualStyleBackColor = True + Me.chk_all.AutoSize = True + Me.chk_all.Location = New System.Drawing.Point(74, 33) + Me.chk_all.Name = "chk_all" + Me.chk_all.Size = New System.Drawing.Size(52, 17) + Me.chk_all.TabIndex = 2 + Me.chk_all.Text = "To all" + Me.chk_all.UseVisualStyleBackColor = True ' - 'Label1 + 'label_procCurrent ' - Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(38, 19) - Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(39, 13) - Me.Label1.TabIndex = 3 - Me.Label1.Text = "Label1" + Me.label_procCurrent.AutoSize = True + Me.label_procCurrent.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.label_procCurrent.Location = New System.Drawing.Point(18, 15) + Me.label_procCurrent.Name = "label_procCurrent" + Me.label_procCurrent.Size = New System.Drawing.Size(49, 16) + Me.label_procCurrent.TabIndex = 3 + Me.label_procCurrent.Text = "Label1" + ' + 'label_procDetails + ' + Me.label_procDetails.AutoSize = True + Me.label_procDetails.Location = New System.Drawing.Point(18, 40) + Me.label_procDetails.Name = "label_procDetails" + Me.label_procDetails.Size = New System.Drawing.Size(39, 13) + Me.label_procDetails.TabIndex = 4 + Me.label_procDetails.Text = "Label1" + ' + 'panel_buttons + ' + Me.panel_buttons.AutoSize = True + Me.panel_buttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.panel_buttons.Controls.Add(Me.btn_yes) + Me.panel_buttons.Controls.Add(Me.btn_no) + Me.panel_buttons.Controls.Add(Me.chk_all) + Me.panel_buttons.Location = New System.Drawing.Point(40, 66) + Me.panel_buttons.Name = "panel_buttons" + Me.panel_buttons.Size = New System.Drawing.Size(198, 53) + Me.panel_buttons.TabIndex = 5 ' 'Prompt ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(280, 113) + Me.AutoSize = True + Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ClientSize = New System.Drawing.Size(280, 159) Me.ControlBox = False - Me.Controls.Add(Me.Label1) - Me.Controls.Add(Me.CheckBox1) - Me.Controls.Add(Me.Button2) - Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.panel_buttons) + Me.Controls.Add(Me.label_procDetails) + Me.Controls.Add(Me.label_procCurrent) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "Prompt" + Me.Padding = New System.Windows.Forms.Padding(15) Me.ShowInTaskbar = False Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide Me.Text = "Confirmation" Me.TopMost = True + Me.panel_buttons.ResumeLayout(False) + Me.panel_buttons.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub - Friend WithEvents Button1 As System.Windows.Forms.Button - Friend WithEvents Button2 As System.Windows.Forms.Button - Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox - Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents btn_yes As System.Windows.Forms.Button + Friend WithEvents btn_no As System.Windows.Forms.Button + Friend WithEvents chk_all As System.Windows.Forms.CheckBox + Friend WithEvents label_procCurrent As System.Windows.Forms.Label + Friend WithEvents label_procDetails As System.Windows.Forms.Label + Friend WithEvents panel_buttons As System.Windows.Forms.Panel End Class diff --git a/Kill It With Fire!/Kill It With Fire!/Prompt.vb b/Kill It With Fire!/Kill It With Fire!/Prompt.vb index ec1e7ae..13e2567 100644 --- a/Kill It With Fire!/Kill It With Fire!/Prompt.vb +++ b/Kill It With Fire!/Kill It With Fire!/Prompt.vb @@ -1,3 +1,26 @@ Public Class Prompt + Private Sub btn_yes_Click(sender As Object, e As EventArgs) Handles btn_yes.Click + If chk_all.Checked = True Then + promptResult = "YesAll" + Else + promptResult = "Yes" + End If + + Me.Close() + End Sub + + Private Sub btn_no_Click(sender As Object, e As EventArgs) Handles btn_no.Click + If chk_all.Checked = True Then + promptResult = "NoAll" + Else + promptResult = "No" + End If + + Me.Close() + End Sub + + Private Sub Prompt_Load(sender As Object, e As EventArgs) Handles MyBase.Load + panel_buttons.Location = New Point((Me.Width - panel_buttons.Width) / 2, panel_buttons.Location.Y) + End Sub End Class \ No newline at end of file diff --git a/Kill It With Fire!/Kill It With Fire!/kill.vb b/Kill It With Fire!/Kill It With Fire!/kill.vb index 34db5d2..653f7c4 100644 --- a/Kill It With Fire!/Kill It With Fire!/kill.vb +++ b/Kill It With Fire!/Kill It With Fire!/kill.vb @@ -1,4 +1,6 @@ Module kill + Public promptResult As String + Public Sub kill() Dim listProcesses(,) As String = _ { _ @@ -24,15 +26,21 @@ For i = 0 To listProcesses.Length / 2 - 1 If Strings.StrComp(currentProcess, listProcesses(i, 0)) = 0 Then - Dim r As MsgBoxResult - r = MsgBox("Are you sure you want to Kill the following process? " & vbNewLine & currentProcess, MsgBoxStyle.YesNoCancel Or MsgBoxStyle.ApplicationModal Or MsgBoxStyle.MsgBoxSetForeground) + Dim str As String = "Are you sure you want to kill " & p.ProcessName & "? " + + If promptResult <> "YesAll" Or promptResult <> "NoAll" Then + Prompt.label_procCurrent.Text = str + Prompt.label_procDetails.Text = "(" & currentProcess & ")" + Prompt.ShowDialog() + End If - If r = MsgBoxResult.Cancel Then + If promptResult = "No" Then Exit For - ElseIf r = MsgBoxResult.Yes Then + ElseIf promptResult = "NoAll" Then + Exit Sub + Else '"Yes" or "YesAll" p.Kill() p.WaitForExit() ' // possibly with a timeout - MsgBox("Done") End If End If Next