diff --git a/Imposter.Fiddler.Installer/App.xaml b/Imposter.Fiddler.Installer/App.xaml new file mode 100644 index 0000000..c09dd94 --- /dev/null +++ b/Imposter.Fiddler.Installer/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Imposter.Fiddler.Installer/App.xaml.cs b/Imposter.Fiddler.Installer/App.xaml.cs new file mode 100644 index 0000000..ea36004 --- /dev/null +++ b/Imposter.Fiddler.Installer/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Imposter.Fiddler.Installer +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Imposter.Fiddler.Installer/Content/success.png b/Imposter.Fiddler.Installer/Content/success.png new file mode 100644 index 0000000..98c365b Binary files /dev/null and b/Imposter.Fiddler.Installer/Content/success.png differ diff --git a/Imposter.Fiddler.Installer/Imposter.Fiddler.Installer.csproj b/Imposter.Fiddler.Installer/Imposter.Fiddler.Installer.csproj new file mode 100644 index 0000000..19b05b5 --- /dev/null +++ b/Imposter.Fiddler.Installer/Imposter.Fiddler.Installer.csproj @@ -0,0 +1,182 @@ + + + + + Debug + AnyCPU + {9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F} + WinExe + Properties + Imposter.Fiddler.Installer + Install + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + ..\ + true + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + Imposter.ico + + + + app.manifest + + + true + + + Imposter.snk + + + + ..\packages\MahApps.Metro.1.1.2.0\lib\net40\MahApps.Metro.dll + True + + + + + ..\packages\MahApps.Metro.1.1.2.0\lib\net40\System.Windows.Interactivity.dll + True + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + Designer + + + + + + + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 4.5 + true + + + + + + + + Scripts\Imposter.Fiddler.dll + Always + + + Scripts\imposter.js + Always + + + Scripts\MahApps.Metro.dll + Always + + + + + Scripts\System.Windows.Interactivity.dll + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/Imposter.Fiddler.Installer/Imposter.ico b/Imposter.Fiddler.Installer/Imposter.ico new file mode 100644 index 0000000..73e73cc Binary files /dev/null and b/Imposter.Fiddler.Installer/Imposter.ico differ diff --git a/Imposter.Fiddler.Installer/Imposter.snk b/Imposter.Fiddler.Installer/Imposter.snk new file mode 100644 index 0000000..eebb1eb Binary files /dev/null and b/Imposter.Fiddler.Installer/Imposter.snk differ diff --git a/Imposter.Fiddler.Installer/MainWindow.xaml b/Imposter.Fiddler.Installer/MainWindow.xaml new file mode 100644 index 0000000..2cdeced --- /dev/null +++ b/Imposter.Fiddler.Installer/MainWindow.xaml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + You're about to embark on a journey you'll ne'er forget. + + + + + + + + + + + + + + diff --git a/Imposter.Fiddler.Installer/MainWindow.xaml.cs b/Imposter.Fiddler.Installer/MainWindow.xaml.cs new file mode 100644 index 0000000..5210ff0 --- /dev/null +++ b/Imposter.Fiddler.Installer/MainWindow.xaml.cs @@ -0,0 +1,83 @@ +using MahApps.Metro.Controls; +using Microsoft.Win32; +using System; +using System.IO; +using System.Windows; +using System.Windows.Controls; + +namespace Imposter.Fiddler.Installer +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : MetroWindow + { + public MainWindow() + { + InitializeComponent(); + } + + private void Install_Click(object sender, RoutedEventArgs e) + { + Install.IsEnabled = false; + Progress.IsActive = true; + + var installLocation = GetFiddlerLocation(); + + if (installLocation == null || !Directory.Exists(installLocation)) + { + MessageBox.Show("Failed to locate Fiddler2 Installation Location. Please check Fiddler is installed"); + Install.IsEnabled = true; + Progress.IsActive = false; + return; + } + + File.Copy("Scripts\\Imposter.Fiddler.dll", installLocation + "Imposter.Fiddler.dll", true); + File.Copy("Scripts\\imposter.js", installLocation + "imposter.js", true); + File.Copy("Scripts\\MahApps.Metro.dll", installLocation + "MahApps.Metro.dll", true); + + Tabs.SelectedIndex = _tabIndex = 1; + } + + private string GetFiddlerLocation() + { + try + { + using (var key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Fiddler2")) + { + if (key != null) + { + Object o = key.GetValue("LMScriptPath"); + if (o != null) + { + var path = o as string; + path = path.Substring(1, path.Length - 2); + return path; + } + } + } + } + catch (Exception ex) + { + // do something with this + } + + return null; + } + + private int _tabIndex = 0; + + private void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.OriginalSource != Tabs) + { + return; + } + + if (Tabs.SelectedIndex != _tabIndex) + { + Tabs.SelectedIndex = _tabIndex; + } + } + } +} diff --git a/Imposter.Fiddler.Installer/Properties/AssemblyInfo.cs b/Imposter.Fiddler.Installer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7915941 --- /dev/null +++ b/Imposter.Fiddler.Installer/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Imposter.Fiddler.Installer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Imposter.Fiddler.Installer")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Imposter.Fiddler.Installer/app.manifest b/Imposter.Fiddler.Installer/app.manifest new file mode 100644 index 0000000..84901bd --- /dev/null +++ b/Imposter.Fiddler.Installer/app.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Imposter.Fiddler.Installer/packages.config b/Imposter.Fiddler.Installer/packages.config new file mode 100644 index 0000000..b9ca3d3 --- /dev/null +++ b/Imposter.Fiddler.Installer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Imposter.Fiddler.sln b/Imposter.Fiddler.sln index aea34f7..fab0baf 100644 --- a/Imposter.Fiddler.sln +++ b/Imposter.Fiddler.sln @@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{DD8A49 .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imposter.Fiddler.Installer", "Imposter.Fiddler.Installer\Imposter.Fiddler.Installer.csproj", "{9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -20,6 +22,10 @@ Global {6C7AB355-6758-4484-8560-CD6B22B1120B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C7AB355-6758-4484-8560-CD6B22B1120B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C7AB355-6758-4484-8560-CD6B22B1120B}.Release|Any CPU.Build.0 = Release|Any CPU + {9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9593C0A3-BB7F-4BE4-9FB5-C9A51CF73D4F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Imposter.Fiddler/Imposter.Fiddler.csproj b/Imposter.Fiddler/Imposter.Fiddler.csproj index 312d49c..489e1ef 100644 --- a/Imposter.Fiddler/Imposter.Fiddler.csproj +++ b/Imposter.Fiddler/Imposter.Fiddler.csproj @@ -43,8 +43,8 @@ ..\..\..\..\Program Files (x86)\Fiddler2\Fiddler.exe False - - ..\packages\MahApps.Metro.0.10.1.1\lib\net40\MahApps.Metro.dll + + ..\packages\MahApps.Metro.1.1.2.0\lib\net40\MahApps.Metro.dll True @@ -55,7 +55,7 @@ - ..\packages\MahApps.Metro.0.10.1.1\lib\net40\System.Windows.Interactivity.dll + ..\packages\MahApps.Metro.1.1.2.0\lib\net40\System.Windows.Interactivity.dll True @@ -81,9 +81,6 @@ ProfileEditor.xaml - - - MSBuild:Compile @@ -99,6 +96,7 @@ Always + @@ -109,7 +107,7 @@ - copy "$(TargetPath)" "%25programfiles(x86)%25\Fiddler2\Scripts\$(TargetFilename)" + copy "$(TargetDir)" "%25programfiles(x86)%25\Fiddler2\Scripts\" diff --git a/Imposter.Fiddler/Imposter.cs b/Imposter.Fiddler/Imposter.cs index e249dd5..72e336a 100644 --- a/Imposter.Fiddler/Imposter.cs +++ b/Imposter.Fiddler/Imposter.cs @@ -20,6 +20,7 @@ public class Imposter : IAutoTamper private ImposterSettings _settings = null; // TODO: switch to List, need to set watcher on the profile maybe? then switch poll for changes to have a parameter private Profile _currentProfile = null; + private ToolStripMenuItem _currentMenuItem = null; private FileSystemWatcher _watcher = null; private bool _hasChanges = false; @@ -185,14 +186,39 @@ private void ProfileEnable_Click(object sender, EventArgs e) var parent = item.OwnerItem as ToolStripMenuItem; parent.Checked = !parent.Checked; - _currentProfile = _settings.Profiles.Where(p => p.Name == parent.Text).First(); - - if (!IsEnabled) + if (item.Checked) { + IsEnabled = true; + _isEnabled.Checked = true; _isEnabled.Enabled = true; _autoReload.Enabled = true; - _isEnabled.PerformClick(); + _currentProfile = _settings.Profiles.Where(p => p.Name == parent.Text).First(); + + if (_currentMenuItem != null && _currentMenuItem != item) + { + // Uncheck previously enabled profile + _currentMenuItem.Checked = false; + parent = _currentMenuItem.OwnerItem as ToolStripMenuItem; + parent.Checked = false; + } + + // Track currently enabled profile for unchecking later + _currentMenuItem = item; + + Start(); + } + else + { + IsEnabled = false; + _isEnabled.Checked = false; + _isEnabled.Enabled = false; + _autoReload.Enabled = false; + + _currentProfile = null; + _currentMenuItem = null; + + Stop(); } } diff --git a/Imposter.Fiddler/Views/ProfileEditor.xaml b/Imposter.Fiddler/Views/ProfileEditor.xaml index f55c0b4..6f3881b 100644 --- a/Imposter.Fiddler/Views/ProfileEditor.xaml +++ b/Imposter.Fiddler/Views/ProfileEditor.xaml @@ -3,12 +3,13 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" Title="Edit Profile" Height="500" Width="500" WindowStyle="ToolWindow" + WindowTransitionsEnabled="False" Background="#FFF"> - + @@ -96,7 +97,7 @@ AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" - Height="100" + Height="140" BorderBrush="#41B1E1" BorderThickness="1"> diff --git a/Imposter.Fiddler/packages.config b/Imposter.Fiddler/packages.config index 0d76b7a..b9ca3d3 100644 --- a/Imposter.Fiddler/packages.config +++ b/Imposter.Fiddler/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file