Skip to content

Commit fca00fe

Browse files
committed
removed hardcoded "remove all" button event
refactoring
1 parent 325e5d7 commit fca00fe

File tree

6 files changed

+19
-77
lines changed

6 files changed

+19
-77
lines changed

TreeViewPanelExtension/AboutForm.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Data;
5-
using System.Drawing;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Windows.Forms;
92
using System.Reflection;
3+
using System.Windows.Forms;
104

115
namespace TreeViewPanelExtension
126
{

TreeViewPanelExtension/Constants.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System.Collections.Generic;
52

63

74
namespace TreeViewPanelExtension

TreeViewPanelExtension/CustomTreeView.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Windows.Forms;
1+
using System.Windows.Forms;
62

73
namespace TreeViewPanelExtension
84
{

TreeViewPanelExtension/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following
@@ -34,4 +33,4 @@
3433
// [assembly: AssemblyVersion("1.0.*")]
3534
[assembly: AssemblyVersion("0.7.5.0")]
3635
[assembly: AssemblyFileVersion("0.7.5.0")]
37-
[assembly: Fiddler.RequiredVersion("2.4.4.5")]
36+
[assembly: Fiddler.RequiredVersion("2.4.4.5")]

TreeViewPanelExtension/TreePanel.cs

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using System.Windows.Forms;
3-
using Fiddler;
1+
using Fiddler;
42
using Microsoft.Win32;
3+
using System;
54
using System.Drawing;
5+
using System.Windows.Forms;
66

77
namespace TreeViewPanelExtension
88
{
@@ -28,17 +28,17 @@ public class TreePanel : IFiddlerExtension
2828
/// <summary>
2929
/// New menu item
3030
/// </summary>
31-
private System.Windows.Forms.MenuItem mnuShowPanel;
31+
private MenuItem mnuShowPanel;
3232

3333
/// <summary>
3434
/// New menu item to show/hide the panel
3535
/// </summary>
36-
private System.Windows.Forms.MenuItem miShowPanelEnabled;
36+
private MenuItem miShowPanelEnabled;
3737

3838
/// <summary>
3939
/// New item to show about information
4040
/// </summary>
41-
private System.Windows.Forms.MenuItem miAbout;
41+
private MenuItem miAbout;
4242

4343
/// <summary>
4444
/// To keep images to be used in the TreeView
@@ -64,7 +64,7 @@ public class TreePanel : IFiddlerExtension
6464
public TreePanel()
6565
{
6666
this.ShowPanel = false; // Default
67-
67+
6868
// Try to get registry configuration
6969
RegistryKey oReg = Registry.CurrentUser.OpenSubKey(String.Format(@"{0}\{1}\", CONFIG.GetRegPath("Root"), Constants.RegistryExtensionKeyName));
7070
if (null != oReg)
@@ -75,10 +75,10 @@ public TreePanel()
7575
}
7676

7777
// Initialize menu options
78-
this.mnuShowPanel = new System.Windows.Forms.MenuItem();
79-
this.miShowPanelEnabled = new System.Windows.Forms.MenuItem();
80-
this.miAbout = new System.Windows.Forms.MenuItem();
81-
this.mnuShowPanel.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.miShowPanelEnabled, this.miAbout });
78+
this.mnuShowPanel = new MenuItem();
79+
this.miShowPanelEnabled = new MenuItem();
80+
this.miAbout = new MenuItem();
81+
this.mnuShowPanel.MenuItems.AddRange(new MenuItem[] { this.miShowPanelEnabled, this.miAbout });
8282

8383
this.mnuShowPanel.Text = "TreeView&Panel";
8484
this.miShowPanelEnabled.Index = 0;
@@ -287,30 +287,6 @@ private void tv_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
287287
}
288288
}
289289

290-
/// <summary>
291-
/// Delete sessions from the TreeView
292-
/// </summary>
293-
/// <param name="sender">Sender</param>
294-
/// <param name="e">ToolStripItemClickedEventArgs</param>
295-
private void btnRemove_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
296-
{
297-
switch (e.ClickedItem.Text.ToLower())
298-
{
299-
case "remove all":
300-
tv.Nodes.Clear();
301-
break;
302-
case "images":
303-
break;
304-
case "connects":
305-
break;
306-
case "non-200s":
307-
break;
308-
default:
309-
// Other possible things to do here
310-
break;
311-
}
312-
}
313-
314290
#endregion "Methods"
315291

316292
#region "IFiddlerExtension Members"
@@ -348,26 +324,6 @@ public void OnLoad()
348324

349325
// Show or hide depending on the registry value
350326
this.ShowHidePanel();
351-
352-
// TODO: Avoid hardcoded reference to the actual button
353-
// TODO: Research possible error executing the following (code after this would not execute)
354-
foreach (Control c in FiddlerApplication.UI.Controls)
355-
{
356-
if (c is ToolStrip)
357-
{
358-
ToolStrip menuBar = c as ToolStrip;
359-
foreach (ToolStripItem btn in menuBar.Items)
360-
{
361-
//if (btn.Text.Equals(Constants.RemoveButtonText, StringComparison.CurrentCultureIgnoreCase))
362-
//if (btn.ToolTipText.Equals(Constants.RemoveButtonToolTipText, StringComparison.CurrentCultureIgnoreCase))
363-
if (btn.ImageKey.Equals(Constants.RemoveButtonImageKey, StringComparison.CurrentCultureIgnoreCase))
364-
{
365-
ToolStripDropDownButton btnRemove = btn as ToolStripDropDownButton;
366-
btnRemove.DropDownItemClicked += new ToolStripItemClickedEventHandler(btnRemove_DropDownItemClicked);
367-
}
368-
}
369-
}
370-
}
371327
}
372328

373329
private void LvSessions_Invalidated(object sender, InvalidateEventArgs e)
@@ -392,7 +348,7 @@ public void OnBeforeUnload()
392348
oReg.SetValue(Constants.RegistryShowPanel, value, RegistryValueKind.DWord);
393349
oReg.Close();
394350
}
395-
351+
396352
#endregion "IFiddlerExtension Members"
397353
}
398354
}

TreeViewPanelExtension/TreeViewGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using Fiddler;
2+
using System;
23
using System.Linq;
34
using System.Windows.Forms;
4-
using Fiddler;
55

66
namespace TreeViewPanelExtension
77
{
@@ -196,7 +196,7 @@ public void AutoTamperRequestBefore(Session oSession) { }
196196
public void AutoTamperRequestAfter(Session oSession) { }
197197
public void AutoTamperResponseBefore(Session oSession) { }
198198
public void OnBeforeReturningError(Session oSession) { }
199-
199+
200200
#endregion "IAutoTamper"
201201
}
202202
}

0 commit comments

Comments
 (0)