├── .gitattributes ├── .github └── issue_template.md ├── .gitignore ├── LICENSE.md ├── Libs └── DotNet4 │ ├── FiddlerCore4.XML │ └── FiddlerCore4.dll ├── ProcessProxifier.sln ├── ProcessProxifier ├── App.xaml ├── App.xaml.cs ├── Behaviors │ ├── AutoScrollListBox.cs │ ├── AutoSizeListViewColumns.cs │ ├── GridViewSortBehavior.cs │ └── TextboxHelper.cs ├── Converters │ ├── EnumBooleanConverter.cs │ ├── FileToImageIconConverter.cs │ └── ThicknessToDoubleConverter.cs ├── Core │ ├── ProcessesListManager.cs │ ├── ProxyRouter.cs │ ├── SettingsManager.cs │ └── SettingsSerializer.cs ├── Images │ ├── CopyHS.png │ ├── copy.png │ ├── delete.png │ ├── pp.png │ ├── refresh.png │ ├── run.png │ ├── save.png │ └── stop.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Models │ ├── Process.cs │ ├── ProxifierSettings.cs │ ├── RoutedConnection.cs │ ├── ServerInfo.cs │ └── ServerType.cs ├── ProcessProxifier.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Styles │ └── Common.xaml ├── Themes │ ├── BaseLight.xaml │ ├── Blue.xaml │ ├── Button.xaml │ ├── CheckBox.xaml │ ├── Colors.xaml │ ├── ContextMenu.xaml │ ├── Css.xaml │ ├── GroupBox.xaml │ ├── ICons.xaml │ ├── ListBox.xaml │ ├── ListView.xaml │ ├── RadioButton.xaml │ ├── Scrollbars.xaml │ ├── TabControl.xaml │ ├── TextBox.xaml │ └── ToolTip.xaml ├── Utils │ ├── AsyncObservableCollection.cs │ ├── DelegateCommand.cs │ ├── Designer.cs │ ├── DispatcherHelper.cs │ ├── ExceptionLogger.cs │ ├── Memory.cs │ ├── MinimizeToTray.cs │ ├── ProcessUtils.cs │ ├── RunOnWindowsStartup.cs │ ├── SafeClipboard.cs │ └── SimpleTaskScheduler.cs ├── ViewModels │ └── MainWindowViewModel.cs ├── app.config ├── network.ico └── packages.config └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | # Summary of the issue 2 | 3 | 4 | 5 | ## Environment 6 | 7 | ``` 8 | The in-use version: 9 | Operating system: 10 | IDE: (e.g. Visual Studio 2015) 11 | ``` 12 | 13 | ## Example code/Steps to reproduce: 14 | 15 | ``` 16 | paste your core code 17 | ``` 18 | 19 | ## Output: 20 | 21 | ``` 22 | Exception message: 23 | Full Stack trace: 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /Libs/DotNet4/FiddlerCore4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/Libs/DotNet4/FiddlerCore4.dll -------------------------------------------------------------------------------- /ProcessProxifier.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessProxifier", "ProcessProxifier\ProcessProxifier.csproj", "{0644897E-EB19-44D8-B24F-2CE3C776C623}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1561D61A-8AD2-4F92-80D0-6748F6DFEA71}" 9 | ProjectSection(SolutionItems) = preProject 10 | LICENSE.md = LICENSE.md 11 | README.md = README.md 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {0644897E-EB19-44D8-B24F-2CE3C776C623}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {0644897E-EB19-44D8-B24F-2CE3C776C623}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | GlobalSection(ExtensibilityGlobals) = postSolution 26 | VisualSVNWorkingCopyRoot = . 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /ProcessProxifier/App.xaml: -------------------------------------------------------------------------------- 1 |  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 | -------------------------------------------------------------------------------- /ProcessProxifier/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows; 4 | using System.Windows.Media.Animation; 5 | using System.Windows.Threading; 6 | using ProcessProxifier.Utils; 7 | 8 | namespace ProcessProxifier 9 | { 10 | public partial class App 11 | { 12 | void checkSingleInst() 13 | { 14 | //WPF Single Instance Application 15 | var process = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); 16 | if (process.Length <= 1) return; 17 | MessageBox.Show("ProcessProxifier is already running ...", "ProcessProxifier", MessageBoxButton.OK, MessageBoxImage.Information); 18 | this.Shutdown(); 19 | } 20 | 21 | public App() 22 | { 23 | this.DispatcherUnhandledException += appDispatcherUnhandledException; 24 | AppDomain.CurrentDomain.UnhandledException += currentDomainUnhandledException; 25 | this.Startup += appStartup; 26 | this.Deactivated += appDeactivated; 27 | checkSingleInst(); 28 | } 29 | 30 | static void appDeactivated(object sender, EventArgs e) 31 | { 32 | Memory.ReEvaluatedWorkingSet(); 33 | } 34 | 35 | void appStartup(object sender, StartupEventArgs e) 36 | { 37 | reducingCpuConsumptionForAnimations(); 38 | } 39 | 40 | static void reducingCpuConsumptionForAnimations() 41 | { 42 | Timeline.DesiredFrameRateProperty.OverrideMetadata( 43 | typeof(Timeline), 44 | new FrameworkPropertyMetadata { DefaultValue = 20 } 45 | ); 46 | } 47 | 48 | static void currentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) 49 | { 50 | var ex = (Exception)e.ExceptionObject; 51 | ExceptionLogger.LogExceptionToFile(ex); 52 | } 53 | 54 | private static void appDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) 55 | { 56 | ExceptionLogger.LogExceptionToFile(e.Exception); 57 | e.Handled = true; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /ProcessProxifier/Behaviors/AutoScrollListBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace ProcessProxifier.Behaviors 7 | { 8 | public class AutoScrollListBox : DependencyObject 9 | { 10 | public static readonly DependencyProperty AutoScrollProperty = 11 | DependencyProperty.RegisterAttached( 12 | "AutoScroll", 13 | typeof(bool), 14 | typeof(AutoScrollListBox), 15 | new UIPropertyMetadata(default(bool), OnAutoScrollChanged)); 16 | 17 | 18 | public static bool GetAutoScroll(DependencyObject dp) 19 | { 20 | return (bool)dp.GetValue(AutoScrollProperty); 21 | } 22 | 23 | public static void SetAutoScroll(DependencyObject dp, bool value) 24 | { 25 | dp.SetValue(AutoScrollProperty, value); 26 | } 27 | 28 | public static void OnAutoScrollChanged(DependencyObject s, DependencyPropertyChangedEventArgs e) 29 | { 30 | var val = (bool)e.NewValue; 31 | var lb = s as ListView; 32 | if (lb == null) 33 | throw new InvalidOperationException("This behavior can only be attached to a ListView."); 34 | 35 | var ic = lb.Items; 36 | var data = ic.SourceCollection as INotifyCollectionChanged; 37 | if (data == null) return; 38 | 39 | var autoscroller = new NotifyCollectionChangedEventHandler( 40 | (s1, e1) => 41 | { 42 | var selectedItem = default(object); 43 | switch (e1.Action) 44 | { 45 | case NotifyCollectionChangedAction.Add: 46 | case NotifyCollectionChangedAction.Move: selectedItem = e1.NewItems[e1.NewItems.Count - 1]; break; 47 | case NotifyCollectionChangedAction.Remove: if (ic.Count < e1.OldStartingIndex) { selectedItem = ic[e1.OldStartingIndex - 1]; } else if (ic.Count > 0) selectedItem = ic[0]; break; 48 | case NotifyCollectionChangedAction.Reset: if (ic.Count > 0) selectedItem = ic[0]; break; 49 | } 50 | 51 | if (selectedItem == default(object)) return; 52 | ic.MoveCurrentTo(selectedItem); 53 | lb.ScrollIntoView(selectedItem); 54 | }); 55 | 56 | if (val) data.CollectionChanged += autoscroller; 57 | else data.CollectionChanged -= autoscroller; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /ProcessProxifier/Behaviors/AutoSizeListViewColumns.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace ProcessProxifier.Behaviors 7 | { 8 | public class AutoSizeListViewColumns : DependencyObject 9 | { 10 | public static readonly DependencyProperty EnableProperty = 11 | DependencyProperty.RegisterAttached( 12 | "Enable", 13 | typeof(bool), 14 | typeof(AutoSizeListViewColumns), 15 | new FrameworkPropertyMetadata(OnEnableChanged)); 16 | 17 | public static bool GetEnable(DependencyObject obj) 18 | { 19 | return (bool)obj.GetValue(EnableProperty); 20 | } 21 | 22 | public static void SetEnable(DependencyObject obj, bool value) 23 | { 24 | obj.SetValue(EnableProperty, value); 25 | } 26 | 27 | public static readonly DependencyProperty AutoSizeColumnProperty = 28 | DependencyProperty.RegisterAttached( 29 | "AutoSizeColumn", 30 | typeof(bool), 31 | typeof(AutoSizeListViewColumns), 32 | new UIPropertyMetadata(false) 33 | ); 34 | 35 | public static bool GetAutoSizeColumn(DependencyObject obj) 36 | { 37 | return (bool)obj.GetValue(AutoSizeColumnProperty); 38 | } 39 | 40 | public static void SetAutoSizeColumn(DependencyObject obj, bool value) 41 | { 42 | obj.SetValue(AutoSizeColumnProperty, value); 43 | } 44 | 45 | public static void OnEnableChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) 46 | { 47 | var val = (bool)e.NewValue; 48 | var listView = obj as ListView; 49 | if (listView == null) 50 | throw new InvalidOperationException("This behavior can only be attached to a ListView."); 51 | 52 | if (val) 53 | { 54 | listView.SizeChanged += listViewSizeChanged; 55 | } 56 | else 57 | { 58 | listView.SizeChanged -= listViewSizeChanged; 59 | } 60 | } 61 | 62 | private static void listViewSizeChanged(object sender, SizeChangedEventArgs e) 63 | { 64 | var listView = sender as ListView; 65 | if (listView == null) 66 | throw new InvalidOperationException("This behavior can only be attached to a ListView."); 67 | 68 | // Only relevant to grid views 69 | if (!(listView.View is GridView)) 70 | return; 71 | 72 | var grid = listView.View as GridView; 73 | 74 | // Only relevant for width 75 | if (!e.WidthChanged) 76 | return; 77 | 78 | // Get all AutoSize columns 79 | var columns = new List(); 80 | double specifiedWidth = 0; 81 | foreach (var col in grid.Columns) 82 | { 83 | if ((bool)col.GetValue(AutoSizeColumnProperty)) 84 | columns.Add(col); 85 | else 86 | specifiedWidth += col.ActualWidth; 87 | } 88 | 89 | // Give them a fair share of the remaining space 90 | foreach (var col in columns) 91 | { 92 | var newWidth = (listView.ActualWidth - specifiedWidth) / columns.Count; 93 | if (newWidth >= 0) 94 | { 95 | col.Width = newWidth > 5 ? newWidth - 5 : newWidth; 96 | } 97 | } 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /ProcessProxifier/Behaviors/GridViewSortBehavior.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Documents; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | using System.Windows.Controls.Primitives; 8 | 9 | namespace ProcessProxifier.Behaviors 10 | { 11 | public class GridViewSortBehavior 12 | { 13 | public static readonly DependencyProperty ResetSortProperty = DependencyProperty.RegisterAttached( 14 | "ResetSort", 15 | typeof(bool), 16 | typeof(GridViewSortBehavior), 17 | new FrameworkPropertyMetadata(onResetSortChanged)); 18 | 19 | public static bool GetResetSort(DependencyObject obj) 20 | { 21 | return (bool)obj.GetValue(ResetSortProperty); 22 | } 23 | 24 | public static void SetResetSort(DependencyObject obj, string value) 25 | { 26 | obj.SetValue(ResetSortProperty, value); 27 | } 28 | 29 | private static void onResetSortChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 30 | { 31 | var listView = sender as ListView; 32 | if (listView == null || e.NewValue == null) 33 | return; 34 | 35 | var resetSort = (bool)e.NewValue; 36 | if (resetSort) 37 | { 38 | listView.Items.SortDescriptions.Clear(); 39 | var currentSortedColumnHeader = getSortedColumnHeader(listView); 40 | if (currentSortedColumnHeader != null) 41 | { 42 | removeSortGlyph(currentSortedColumnHeader); 43 | } 44 | } 45 | } 46 | 47 | public static ICommand GetCommand(DependencyObject obj) 48 | { 49 | return (ICommand)obj.GetValue(CommandProperty); 50 | } 51 | 52 | public static void SetCommand(DependencyObject obj, ICommand value) 53 | { 54 | obj.SetValue(CommandProperty, value); 55 | } 56 | 57 | // Using a DependencyProperty as the backing store for Command. This enables animation, styling, binding, etc... 58 | public static readonly DependencyProperty CommandProperty = 59 | DependencyProperty.RegisterAttached( 60 | "Command", 61 | typeof(ICommand), 62 | typeof(GridViewSortBehavior), 63 | new UIPropertyMetadata( 64 | null, 65 | (o, e) => 66 | { 67 | var listView = o as ItemsControl; 68 | if (listView == null) 69 | return; 70 | 71 | if (GetAutoSort(listView)) 72 | return; 73 | 74 | if (e.OldValue != null && e.NewValue == null) 75 | { 76 | listView.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(columnHeaderClick)); 77 | } 78 | if (e.OldValue == null && e.NewValue != null) 79 | { 80 | listView.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(columnHeaderClick)); 81 | } 82 | } 83 | ) 84 | ); 85 | 86 | public static bool GetAutoSort(DependencyObject obj) 87 | { 88 | return (bool)obj.GetValue(AutoSortProperty); 89 | } 90 | 91 | public static void SetAutoSort(DependencyObject obj, bool value) 92 | { 93 | obj.SetValue(AutoSortProperty, value); 94 | } 95 | 96 | // Using a DependencyProperty as the backing store for AutoSort. This enables animation, styling, binding, etc... 97 | public static readonly DependencyProperty AutoSortProperty = 98 | DependencyProperty.RegisterAttached( 99 | "AutoSort", 100 | typeof(bool), 101 | typeof(GridViewSortBehavior), 102 | new UIPropertyMetadata( 103 | false, 104 | (o, e) => 105 | { 106 | var listView = o as ListView; 107 | if (listView == null) 108 | return; 109 | 110 | if (GetCommand(listView) != null) 111 | return; 112 | 113 | var oldValue = (bool)e.OldValue; 114 | var newValue = (bool)e.NewValue; 115 | if (oldValue && !newValue) 116 | { 117 | listView.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(columnHeaderClick)); 118 | } 119 | if (!oldValue && newValue) 120 | { 121 | listView.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(columnHeaderClick)); 122 | } 123 | } 124 | ) 125 | ); 126 | 127 | public static string GetPropertyName(DependencyObject obj) 128 | { 129 | return (string)obj.GetValue(PropertyNameProperty); 130 | } 131 | 132 | public static void SetPropertyName(DependencyObject obj, string value) 133 | { 134 | obj.SetValue(PropertyNameProperty, value); 135 | } 136 | 137 | // Using a DependencyProperty as the backing store for PropertyName. This enables animation, styling, binding, etc... 138 | public static readonly DependencyProperty PropertyNameProperty = 139 | DependencyProperty.RegisterAttached( 140 | "PropertyName", 141 | typeof(string), 142 | typeof(GridViewSortBehavior), 143 | new UIPropertyMetadata(null) 144 | ); 145 | 146 | public static bool GetShowSortGlyph(DependencyObject obj) 147 | { 148 | return (bool)obj.GetValue(ShowSortGlyphProperty); 149 | } 150 | 151 | public static void SetShowSortGlyph(DependencyObject obj, bool value) 152 | { 153 | obj.SetValue(ShowSortGlyphProperty, value); 154 | } 155 | 156 | // Using a DependencyProperty as the backing store for ShowSortGlyph. This enables animation, styling, binding, etc... 157 | public static readonly DependencyProperty ShowSortGlyphProperty = 158 | DependencyProperty.RegisterAttached("ShowSortGlyph", typeof(bool), typeof(GridViewSortBehavior), new UIPropertyMetadata(true)); 159 | 160 | public static ImageSource GetSortGlyphAscending(DependencyObject obj) 161 | { 162 | return (ImageSource)obj.GetValue(SortGlyphAscendingProperty); 163 | } 164 | 165 | public static void SetSortGlyphAscending(DependencyObject obj, ImageSource value) 166 | { 167 | obj.SetValue(SortGlyphAscendingProperty, value); 168 | } 169 | 170 | // Using a DependencyProperty as the backing store for SortGlyphAscending. This enables animation, styling, binding, etc... 171 | public static readonly DependencyProperty SortGlyphAscendingProperty = 172 | DependencyProperty.RegisterAttached("SortGlyphAscending", typeof(ImageSource), typeof(GridViewSortBehavior), new UIPropertyMetadata(null)); 173 | 174 | public static ImageSource GetSortGlyphDescending(DependencyObject obj) 175 | { 176 | return (ImageSource)obj.GetValue(SortGlyphDescendingProperty); 177 | } 178 | 179 | public static void SetSortGlyphDescending(DependencyObject obj, ImageSource value) 180 | { 181 | obj.SetValue(SortGlyphDescendingProperty, value); 182 | } 183 | 184 | // Using a DependencyProperty as the backing store for SortGlyphDescending. This enables animation, styling, binding, etc... 185 | public static readonly DependencyProperty SortGlyphDescendingProperty = 186 | DependencyProperty.RegisterAttached("SortGlyphDescending", typeof(ImageSource), typeof(GridViewSortBehavior), new UIPropertyMetadata(null)); 187 | 188 | 189 | private static GridViewColumnHeader getSortedColumnHeader(DependencyObject obj) 190 | { 191 | return (GridViewColumnHeader)obj.GetValue(SortedColumnHeaderProperty); 192 | } 193 | 194 | private static void setSortedColumnHeader(DependencyObject obj, GridViewColumnHeader value) 195 | { 196 | obj.SetValue(SortedColumnHeaderProperty, value); 197 | } 198 | 199 | // Using a DependencyProperty as the backing store for SortedColumn. This enables animation, styling, binding, etc... 200 | private static readonly DependencyProperty SortedColumnHeaderProperty = 201 | DependencyProperty.RegisterAttached("SortedColumnHeader", typeof(GridViewColumnHeader), typeof(GridViewSortBehavior), new UIPropertyMetadata(null)); 202 | 203 | 204 | private static void columnHeaderClick(object sender, RoutedEventArgs e) 205 | { 206 | var headerClicked = e.OriginalSource as GridViewColumnHeader; 207 | if (headerClicked == null || headerClicked.Column == null) 208 | return; 209 | 210 | var propertyName = GetPropertyName(headerClicked.Column); 211 | if (string.IsNullOrEmpty(propertyName)) 212 | return; 213 | 214 | var listView = GetAncestor(headerClicked); 215 | if (listView == null) 216 | return; 217 | 218 | var command = GetCommand(listView); 219 | if (command != null) 220 | { 221 | if (command.CanExecute(propertyName)) 222 | { 223 | command.Execute(propertyName); 224 | } 225 | } 226 | else if (GetAutoSort(listView)) 227 | { 228 | ApplySort(listView.Items, propertyName, listView, headerClicked); 229 | } 230 | } 231 | 232 | 233 | public static T GetAncestor(DependencyObject reference) where T : DependencyObject 234 | { 235 | var parent = VisualTreeHelper.GetParent(reference); 236 | while (!(parent is T)) 237 | { 238 | parent = VisualTreeHelper.GetParent(parent); 239 | } 240 | return (T)parent; 241 | } 242 | 243 | public static void ApplySort(ICollectionView view, string propertyName, ListView listView, GridViewColumnHeader sortedColumnHeader) 244 | { 245 | var direction = ListSortDirection.Ascending; 246 | if (view.SortDescriptions.Count > 0) 247 | { 248 | var currentSort = view.SortDescriptions[0]; 249 | if (currentSort.PropertyName == propertyName) 250 | { 251 | direction = currentSort.Direction == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; 252 | } 253 | view.SortDescriptions.Clear(); 254 | 255 | var currentSortedColumnHeader = getSortedColumnHeader(listView); 256 | if (currentSortedColumnHeader != null) 257 | { 258 | removeSortGlyph(currentSortedColumnHeader); 259 | } 260 | } 261 | if (!string.IsNullOrEmpty(propertyName)) 262 | { 263 | view.SortDescriptions.Add(new SortDescription(propertyName, direction)); 264 | if (GetShowSortGlyph(listView)) 265 | addSortGlyph( 266 | sortedColumnHeader, 267 | direction, 268 | direction == ListSortDirection.Ascending ? GetSortGlyphAscending(listView) : GetSortGlyphDescending(listView)); 269 | setSortedColumnHeader(listView, sortedColumnHeader); 270 | } 271 | } 272 | 273 | private static void addSortGlyph(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph) 274 | { 275 | var adornerLayer = AdornerLayer.GetAdornerLayer(columnHeader); 276 | adornerLayer.Add( 277 | new SortGlyphAdorner( 278 | columnHeader, 279 | direction, 280 | sortGlyph 281 | )); 282 | } 283 | 284 | private static void removeSortGlyph(UIElement columnHeader) 285 | { 286 | var adornerLayer = AdornerLayer.GetAdornerLayer(columnHeader); 287 | var adorners = adornerLayer.GetAdorners(columnHeader); 288 | if (adorners == null) 289 | return; 290 | 291 | foreach (var adorner in adorners) 292 | { 293 | if (adorner is SortGlyphAdorner) 294 | adornerLayer.Remove(adorner); 295 | } 296 | } 297 | 298 | 299 | private class SortGlyphAdorner : Adorner 300 | { 301 | private readonly GridViewColumnHeader _columnHeader; 302 | private readonly ListSortDirection _direction; 303 | private readonly ImageSource _sortGlyph; 304 | 305 | public SortGlyphAdorner(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph) 306 | : base(columnHeader) 307 | { 308 | _columnHeader = columnHeader; 309 | _direction = direction; 310 | _sortGlyph = sortGlyph; 311 | } 312 | 313 | private Geometry getDefaultGlyph() 314 | { 315 | var x1 = _columnHeader.ActualWidth - 13; 316 | var x2 = x1 + 10; 317 | var x3 = x1 + 5; 318 | var y1 = _columnHeader.ActualHeight / 2 - 3; 319 | var y2 = y1 + 5; 320 | 321 | if (_direction == ListSortDirection.Ascending) 322 | { 323 | var tmp = y1; 324 | y1 = y2; 325 | y2 = tmp; 326 | } 327 | 328 | var pathSegmentCollection = new PathSegmentCollection 329 | { 330 | new LineSegment(new Point(x2, y1), true), 331 | new LineSegment(new Point(x3, y2), true) 332 | }; 333 | 334 | var pathFigure = new PathFigure( 335 | new Point(x1, y1), 336 | pathSegmentCollection, 337 | true); 338 | 339 | var pathFigureCollection = new PathFigureCollection { pathFigure }; 340 | 341 | var pathGeometry = new PathGeometry(pathFigureCollection); 342 | return pathGeometry; 343 | } 344 | 345 | protected override void OnRender(DrawingContext drawingContext) 346 | { 347 | base.OnRender(drawingContext); 348 | 349 | if (_sortGlyph != null) 350 | { 351 | var x = _columnHeader.ActualWidth - 13; 352 | var y = _columnHeader.ActualHeight / 2 - 5; 353 | var rect = new Rect(x, y, 10, 10); 354 | drawingContext.DrawImage(_sortGlyph, rect); 355 | } 356 | else 357 | { 358 | drawingContext.DrawGeometry(new SolidColorBrush(Colors.LightGray) { Opacity = 0.5 }, new Pen(Brushes.Gray, 0.5), getDefaultGlyph()); 359 | } 360 | } 361 | } 362 | } 363 | } -------------------------------------------------------------------------------- /ProcessProxifier/Behaviors/TextboxHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media; 5 | 6 | namespace ProcessProxifier.Behaviors 7 | { 8 | /// 9 | /// Password watermarking code from: http://prabu-guru.blogspot.com/2010/06/how-to-add-watermark-text-to-textbox.html 10 | /// 11 | public class TextboxHelper : DependencyObject 12 | { 13 | public static readonly DependencyProperty IsMonitoringProperty = DependencyProperty.RegisterAttached("IsMonitoring", typeof(bool), typeof(TextboxHelper), new UIPropertyMetadata(false, onIsMonitoringChanged)); 14 | public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached("Watermark", typeof(string), typeof(TextboxHelper), new UIPropertyMetadata(string.Empty)); 15 | public static readonly DependencyProperty TextLengthProperty = DependencyProperty.RegisterAttached("TextLength", typeof(int), typeof(TextboxHelper), new UIPropertyMetadata(0)); 16 | public static readonly DependencyProperty ClearTextButtonProperty = DependencyProperty.RegisterAttached("ClearTextButton", typeof(bool), typeof(TextboxHelper), new FrameworkPropertyMetadata(false, clearTextChanged)); 17 | public static readonly DependencyProperty SelectAllOnFocusProperty = DependencyProperty.RegisterAttached("SelectAllOnFocus", typeof(bool), typeof(TextboxHelper), new FrameworkPropertyMetadata(false)); 18 | 19 | private static readonly DependencyProperty HasTextProperty = DependencyProperty.RegisterAttached("HasText", typeof(bool), typeof(TextboxHelper), new FrameworkPropertyMetadata(false)); 20 | 21 | public static void SetSelectAllOnFocus(DependencyObject obj, bool value) 22 | { 23 | obj.SetValue(SelectAllOnFocusProperty, value); 24 | } 25 | 26 | public static bool GetSelectAllOnFocus(DependencyObject obj) 27 | { 28 | return (bool)obj.GetValue(SelectAllOnFocusProperty); 29 | } 30 | 31 | public static void SetIsMonitoring(DependencyObject obj, bool value) 32 | { 33 | obj.SetValue(IsMonitoringProperty, value); 34 | } 35 | 36 | public static string GetWatermark(DependencyObject obj) 37 | { 38 | return (string)obj.GetValue(WatermarkProperty); 39 | } 40 | 41 | public static void SetWatermark(DependencyObject obj, string value) 42 | { 43 | obj.SetValue(WatermarkProperty, value); 44 | } 45 | 46 | private static void setTextLength(DependencyObject obj, int value) 47 | { 48 | obj.SetValue(TextLengthProperty, value); 49 | obj.SetValue(HasTextProperty, value >= 1); 50 | } 51 | 52 | public bool HasText 53 | { 54 | get { return (bool)GetValue(HasTextProperty); } 55 | } 56 | 57 | static void onIsMonitoringChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 58 | { 59 | if (d is TextBox) 60 | { 61 | var txtBox = d as TextBox; 62 | 63 | if ((bool)e.NewValue) 64 | { 65 | txtBox.TextChanged += textChanged; 66 | txtBox.GotFocus += textBoxGotFocus; 67 | } 68 | else 69 | { 70 | txtBox.TextChanged -= textChanged; 71 | txtBox.GotFocus -= textBoxGotFocus; 72 | } 73 | } 74 | else if (d is PasswordBox) 75 | { 76 | var passBox = d as PasswordBox; 77 | 78 | if ((bool)e.NewValue) 79 | { 80 | passBox.PasswordChanged += passwordChanged; 81 | passBox.GotFocus += passwordGotFocus; 82 | } 83 | else 84 | { 85 | passBox.PasswordChanged -= passwordChanged; 86 | passBox.GotFocus -= passwordGotFocus; 87 | } 88 | } 89 | } 90 | 91 | static void textChanged(object sender, TextChangedEventArgs e) 92 | { 93 | var txtBox = sender as TextBox; 94 | if (txtBox == null) 95 | return; 96 | setTextLength(txtBox, txtBox.Text.Length); 97 | } 98 | 99 | static void passwordChanged(object sender, RoutedEventArgs e) 100 | { 101 | var passBox = sender as PasswordBox; 102 | if (passBox == null) 103 | return; 104 | setTextLength(passBox, passBox.Password.Length); 105 | } 106 | 107 | static void textBoxGotFocus(object sender, RoutedEventArgs e) 108 | { 109 | var txtBox = sender as TextBox; 110 | if (txtBox == null) 111 | return; 112 | if (GetSelectAllOnFocus(txtBox)) 113 | { 114 | txtBox.Dispatcher.BeginInvoke((Action)(txtBox.SelectAll)); 115 | } 116 | } 117 | 118 | static void passwordGotFocus(object sender, RoutedEventArgs e) 119 | { 120 | var passBox = sender as PasswordBox; 121 | if (passBox == null) 122 | return; 123 | if (GetSelectAllOnFocus(passBox)) 124 | { 125 | passBox.Dispatcher.BeginInvoke((Action)(passBox.SelectAll)); 126 | } 127 | } 128 | 129 | public static bool GetClearTextButton(DependencyObject d) 130 | { 131 | return (bool)d.GetValue(ClearTextButtonProperty); 132 | } 133 | 134 | public static void SetClearTextButton(DependencyObject obj, bool value) 135 | { 136 | obj.SetValue(ClearTextButtonProperty, value); 137 | } 138 | 139 | private static void clearTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 140 | { 141 | var textbox = d as TextBox; 142 | if (textbox != null) 143 | { 144 | if ((bool)e.NewValue) 145 | { 146 | textbox.Loaded += textBoxLoaded; 147 | } 148 | else 149 | { 150 | textbox.Loaded -= textBoxLoaded; 151 | } 152 | } 153 | var passbox = d as PasswordBox; 154 | if (passbox != null) 155 | { 156 | if ((bool)e.NewValue) 157 | { 158 | passbox.Loaded += passBoxLoaded; 159 | } 160 | else 161 | { 162 | passbox.Loaded -= passBoxLoaded; 163 | } 164 | } 165 | } 166 | 167 | static void passBoxLoaded(object sender, RoutedEventArgs e) 168 | { 169 | if (!(sender is PasswordBox)) 170 | return; 171 | 172 | var passbox = sender as PasswordBox; 173 | if (passbox.Style == null) 174 | return; 175 | 176 | var template = passbox.Template; 177 | if (template == null) 178 | return; 179 | 180 | var button = template.FindName("PART_ClearText", passbox) as Button; 181 | if (button == null) 182 | return; 183 | 184 | if (GetClearTextButton(passbox)) 185 | { 186 | button.Click += clearPassClicked; 187 | } 188 | else 189 | { 190 | button.Click -= clearPassClicked; 191 | } 192 | } 193 | 194 | 195 | static void textBoxLoaded(object sender, RoutedEventArgs e) 196 | { 197 | if (!(sender is TextBox)) 198 | return; 199 | 200 | var textbox = sender as TextBox; 201 | if (textbox.Style == null) 202 | return; 203 | 204 | var template = textbox.Template; 205 | if (template == null) 206 | return; 207 | 208 | var button = template.FindName("PART_ClearText", textbox) as Button; 209 | if (button == null) 210 | return; 211 | 212 | if (GetClearTextButton(textbox)) 213 | { 214 | button.Click += clearTextClicked; 215 | } 216 | else 217 | { 218 | button.Click -= clearTextClicked; 219 | } 220 | } 221 | 222 | static void clearTextClicked(object sender, RoutedEventArgs e) 223 | { 224 | var button = ((Button)sender); 225 | var parent = VisualTreeHelper.GetParent(button); 226 | while (!(parent is TextBox)) 227 | { 228 | parent = VisualTreeHelper.GetParent(parent); 229 | } 230 | 231 | ((TextBox)parent).Clear(); 232 | } 233 | 234 | static void clearPassClicked(object sender, RoutedEventArgs e) 235 | { 236 | var button = ((Button)sender); 237 | var parent = VisualTreeHelper.GetParent(button); 238 | while (!(parent is PasswordBox)) 239 | { 240 | parent = VisualTreeHelper.GetParent(parent); 241 | } 242 | 243 | ((PasswordBox)parent).Clear(); 244 | } 245 | } 246 | } -------------------------------------------------------------------------------- /ProcessProxifier/Converters/EnumBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace ProcessProxifier.Converters 7 | { 8 | public class EnumBooleanConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var parameterString = parameter as string; 13 | if (parameterString == null) 14 | return DependencyProperty.UnsetValue; 15 | 16 | if (Enum.IsDefined(value.GetType(), value) == false) 17 | return DependencyProperty.UnsetValue; 18 | 19 | var parameterValue = Enum.Parse(value.GetType(), parameterString); 20 | 21 | return parameterValue.Equals(value); 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 25 | { 26 | var parameterString = parameter as string; 27 | return parameterString == null ? DependencyProperty.UnsetValue : Enum.Parse(targetType, parameterString); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /ProcessProxifier/Converters/FileToImageIconConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Interop; 8 | using System.Windows.Media.Imaging; 9 | 10 | namespace ProcessProxifier.Converters 11 | { 12 | public class FileToImageIconConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (value == null) 17 | return DependencyProperty.UnsetValue; 18 | 19 | var path = value.ToString(); 20 | if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) 21 | return DependencyProperty.UnsetValue; 22 | 23 | using (var sysicon = Icon.ExtractAssociatedIcon(path)) 24 | { 25 | return sysicon == null ? 26 | DependencyProperty.UnsetValue : 27 | Imaging.CreateBitmapSourceFromHIcon(sysicon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); 28 | } 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /ProcessProxifier/Converters/ThicknessToDoubleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace ProcessProxifier.Converters 7 | { 8 | public class ThicknessToDoubleConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var thickness = (Thickness)value; 13 | return thickness.Left; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /ProcessProxifier/Core/ProcessesListManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using ProcessProxifier.Models; 4 | using ProcessProxifier.Utils; 5 | 6 | namespace ProcessProxifier.Core 7 | { 8 | public static class ProcessesListManager 9 | { 10 | public static AsyncObservableCollection UpdateProcesses( 11 | ProxifierSettings guiModelData, 12 | ProxifierSettings settings) 13 | { 14 | var systemProcessList = System.Diagnostics.Process.GetProcesses().OrderBy(x => x.ProcessName).ToList(); 15 | var systemProcessIds = systemProcessList.Select(p => p.Id).ToList(); 16 | var finishedProcesses = guiModelData.ProcessesList 17 | .Where(process => !systemProcessIds.Contains(process.Pid)) 18 | .ToList(); 19 | 20 | if (finishedProcesses.Any()) 21 | { 22 | SettingsManager.SaveSettings(guiModelData, settings); 23 | } 24 | 25 | foreach (var process in finishedProcesses) 26 | { 27 | guiModelData.ProcessesList.Remove(process); 28 | } 29 | 30 | var guiProcessIds = guiModelData.ProcessesList.Select(process => process.Pid).ToList(); 31 | var newSystemProcesses = systemProcessList.Where(process => !guiProcessIds.Contains(process.Id)).ToList(); 32 | foreach (var systemProcess in newSystemProcesses) 33 | { 34 | var path = systemProcess.GetPath(); 35 | if(string.IsNullOrWhiteSpace(path)) // TODO: improve 36 | { 37 | continue; 38 | } 39 | 40 | var newProcess = new Process 41 | { 42 | Name = systemProcess.ProcessName, 43 | Pid = systemProcess.Id, 44 | Path = path 45 | }; 46 | 47 | var settingsProcess = settings.ActiveProcessesList 48 | .FirstOrDefault(x => x.Path.Equals(path, StringComparison.InvariantCultureIgnoreCase)); 49 | if (settingsProcess != null) 50 | { 51 | newProcess.IsEnabled = settingsProcess.IsEnabled; 52 | newProcess.ServerInfo = new ServerInfo 53 | { 54 | ServerIP = settingsProcess.ServerInfo.ServerIP, 55 | ServerPort = settingsProcess.ServerInfo.ServerPort, 56 | ServerType = settingsProcess.ServerInfo.ServerType 57 | }; 58 | } 59 | 60 | guiModelData.ProcessesList.Add(newProcess); 61 | } 62 | 63 | return guiModelData.ProcessesList; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /ProcessProxifier/Core/ProxyRouter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net.Security; 4 | using System.Text; 5 | using System.Threading; 6 | using Fiddler; 7 | using ProcessProxifier.Models; 8 | using ProcessProxifier.Utils; 9 | 10 | namespace ProcessProxifier.Core 11 | { 12 | using System.Globalization; 13 | 14 | public class ProxyRouter 15 | { 16 | public ServerInfo DefaultServerInfo { set; get; } 17 | 18 | public int FiddlerPort { set; get; } 19 | 20 | public AsyncObservableCollection ProcessesList { set; get; } 21 | 22 | public AsyncObservableCollection RoutedConnectionsList { set; get; } 23 | 24 | 25 | public void Shutdown() 26 | { 27 | FiddlerApplication.BeforeRequest -= beforeRequest; 28 | FiddlerApplication.OnValidateServerCertificate -= onValidateServerCertificate; 29 | 30 | if (FiddlerApplication.oProxy != null) 31 | FiddlerApplication.oProxy.Detach(); 32 | 33 | FiddlerApplication.Shutdown(); 34 | 35 | Thread.Sleep(1000); 36 | } 37 | 38 | public void Start() 39 | { 40 | FiddlerApplication.BeforeRequest += beforeRequest; 41 | FiddlerApplication.OnValidateServerCertificate += onValidateServerCertificate; 42 | 43 | FiddlerApplication.Startup(FiddlerPort, 44 | FiddlerCoreStartupFlags.RegisterAsSystemProxy | 45 | FiddlerCoreStartupFlags.MonitorAllConnections | 46 | FiddlerCoreStartupFlags.CaptureFTP); 47 | } 48 | 49 | 50 | private static void onValidateServerCertificate(object sender, ValidateServerCertificateEventArgs e) 51 | { 52 | if (SslPolicyErrors.None == e.CertificatePolicyErrors) 53 | return; 54 | 55 | e.ValidityState = CertificateValidity.ForceValid; 56 | } 57 | 58 | private static void setBasicAuthenticationHeaders(Session oSession, string userCredentials) 59 | { 60 | var base64UserCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(userCredentials)); 61 | oSession.RequestHeaders["Proxy-Authorization"] = $"Basic {base64UserCredentials}"; 62 | } 63 | 64 | private void beforeRequest(Session oSession) 65 | { 66 | var process = ProcessesList.FirstOrDefault(p => p.Pid == oSession.LocalProcessID && p.IsEnabled); 67 | if (process == null) 68 | { 69 | return; 70 | } 71 | 72 | var processServerInfo = process.ServerInfo; 73 | var useDefaultServerInfo = string.IsNullOrWhiteSpace(processServerInfo.ServerIP); 74 | if (useDefaultServerInfo) 75 | { 76 | var serverType = DefaultServerInfo.ServerType == ServerType.Socks ? "socks=" : ""; 77 | oSession["X-OverrideGateway"] = $"{serverType}{DefaultServerInfo.ServerIP}:{DefaultServerInfo.ServerPort}"; 78 | 79 | if (!string.IsNullOrWhiteSpace(DefaultServerInfo.Username) && 80 | !string.IsNullOrWhiteSpace(DefaultServerInfo.Password)) 81 | { 82 | var userCredentials = $"{DefaultServerInfo.Username}:{DefaultServerInfo.Password}"; 83 | setBasicAuthenticationHeaders(oSession, userCredentials); 84 | } 85 | } 86 | else 87 | { 88 | var serverType = processServerInfo.ServerType == ServerType.Socks ? "socks=" : ""; 89 | oSession["X-OverrideGateway"] = $"{serverType}{processServerInfo.ServerIP}:{processServerInfo.ServerPort}"; 90 | 91 | if (!string.IsNullOrWhiteSpace(processServerInfo.Username) && 92 | !string.IsNullOrWhiteSpace(processServerInfo.Password)) 93 | { 94 | var userCredentials = $"{processServerInfo.Username}:{processServerInfo.Password}"; 95 | setBasicAuthenticationHeaders(oSession, userCredentials); 96 | } 97 | } 98 | 99 | RoutedConnectionsList.Add(new RoutedConnection 100 | { 101 | ProcessPid = oSession.LocalProcessID, 102 | Url = oSession.fullUrl, 103 | ProcessName = getProcessName(oSession), 104 | ProcessPath = process.Path 105 | }); 106 | } 107 | 108 | private string getProcessName(Session oSession) 109 | { 110 | var process = ProcessesList.FirstOrDefault(x => x.Pid == oSession.LocalProcessID); 111 | return process == null ? oSession.LocalProcessID.ToString(CultureInfo.InvariantCulture) : process.Name; 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /ProcessProxifier/Core/SettingsManager.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Windows.Forms; 3 | using ProcessProxifier.Models; 4 | using ProcessProxifier.Utils; 5 | 6 | namespace ProcessProxifier.Core 7 | { 8 | public static class SettingsManager 9 | { 10 | public static string SettingsPath 11 | { 12 | get { return Path.Combine(Application.StartupPath, "settings.json"); } 13 | } 14 | 15 | public static ProxifierSettings LoadSettings(ProxifierSettings guiModelData) 16 | { 17 | var settings = SettingsSerializer.LoadSettings(SettingsPath); 18 | guiModelData.ProxifierPort = settings.ProxifierPort; 19 | guiModelData.DefaultServerInfo.ServerIP = settings.DefaultServerInfo.ServerIP; 20 | guiModelData.DefaultServerInfo.ServerPort = settings.DefaultServerInfo.ServerPort; 21 | guiModelData.DefaultServerInfo.ServerType = settings.DefaultServerInfo.ServerType; 22 | guiModelData.RunOnStartup = settings.RunOnStartup; 23 | guiModelData.AreAllChecked = settings.AreAllChecked; 24 | return settings; 25 | } 26 | 27 | public static void SaveSettings(ProxifierSettings guiModelData, ProxifierSettings settings) 28 | { 29 | if (guiModelData.RunOnStartup) 30 | RunOnWindowsStartup.Do(); 31 | else 32 | RunOnWindowsStartup.Undo(); 33 | 34 | addNewActiveItems(guiModelData, settings); 35 | SettingsSerializer.SaveSettings(guiModelData, SettingsPath); 36 | } 37 | 38 | private static void addNewActiveItems(ProxifierSettings guiModelData, ProxifierSettings settings) 39 | { 40 | foreach (var process in guiModelData.ProcessesList) 41 | { 42 | if (!process.IsEnabled && string.IsNullOrWhiteSpace(process.ServerInfo.ServerIP) && 43 | process.ServerInfo.ServerPort == 0) 44 | { 45 | continue; 46 | } 47 | 48 | if(!settings.ActiveProcessesList.Contains(process)) 49 | { 50 | settings.ActiveProcessesList.Add(process); 51 | } 52 | 53 | if (!guiModelData.ActiveProcessesList.Contains(process)) 54 | { 55 | guiModelData.ActiveProcessesList.Add(process); 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /ProcessProxifier/Core/SettingsSerializer.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Newtonsoft.Json; 3 | using ProcessProxifier.Models; 4 | 5 | namespace ProcessProxifier.Core 6 | { 7 | public static class SettingsSerializer 8 | { 9 | public static void SaveSettings(ProxifierSettings data, string configFilePath) 10 | { 11 | File.WriteAllText(configFilePath, JsonConvert.SerializeObject(data, new JsonSerializerSettings { Formatting = Formatting.Indented })); 12 | } 13 | 14 | public static ProxifierSettings LoadSettings(string configFilePath) 15 | { 16 | if (!File.Exists(configFilePath)) 17 | { 18 | SaveSettings(new ProxifierSettings(), configFilePath); 19 | } 20 | 21 | return JsonConvert.DeserializeObject(File.ReadAllText(configFilePath)); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /ProcessProxifier/Images/CopyHS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/CopyHS.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/copy.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/delete.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/pp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/pp.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/refresh.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/run.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/save.png -------------------------------------------------------------------------------- /ProcessProxifier/Images/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VahidN/Process-Proxifier/a80f8459cb5993bba2bc0ae1e8efb29200439b76/ProcessProxifier/Images/stop.png -------------------------------------------------------------------------------- /ProcessProxifier/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using ProcessProxifier.Utils; 3 | 4 | namespace ProcessProxifier 5 | { 6 | public partial class MainWindow 7 | { 8 | public MainWindow() 9 | { 10 | InitializeComponent(); 11 | 12 | // Enable "minimize to tray" behavior for this Window 13 | MinimizeToTray.Enable(this); 14 | this.Loaded += mainWindowLoaded; 15 | } 16 | 17 | static void mainWindowLoaded(object sender, RoutedEventArgs e) 18 | { 19 | Application.Current.MainWindow.WindowState = WindowState.Minimized; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /ProcessProxifier/Models/Process.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using Newtonsoft.Json; 4 | 5 | namespace ProcessProxifier.Models 6 | { 7 | public class Process : INotifyPropertyChanged 8 | { 9 | bool _isEnabled; 10 | string _name; 11 | int _pid; 12 | ServerInfo _serverInfo = new ServerInfo(); 13 | 14 | public bool IsEnabled 15 | { 16 | get { return _isEnabled; } 17 | set 18 | { 19 | _isEnabled = value; 20 | notifyPropertyChanged("IsEnabled"); 21 | } 22 | } 23 | 24 | public string Name 25 | { 26 | get { return _name; } 27 | set 28 | { 29 | _name = value; 30 | notifyPropertyChanged("Name"); 31 | } 32 | } 33 | 34 | public string Path { set; get; } 35 | 36 | [JsonIgnore] 37 | public int Pid 38 | { 39 | get { return _pid; } 40 | set 41 | { 42 | _pid = value; 43 | notifyPropertyChanged("Pid"); 44 | } 45 | } 46 | 47 | public ServerInfo ServerInfo 48 | { 49 | get { return _serverInfo; } 50 | set 51 | { 52 | _serverInfo = value; 53 | notifyPropertyChanged("ServerInfo"); 54 | } 55 | } 56 | 57 | public event PropertyChangedEventHandler PropertyChanged; 58 | private void notifyPropertyChanged(string propertyName) 59 | { 60 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 61 | } 62 | 63 | public override string ToString() 64 | { 65 | return $"{Name}, {Path}"; 66 | } 67 | 68 | public override bool Equals(object obj) 69 | { 70 | var process = obj as Process; 71 | if (process == null) 72 | return false; 73 | 74 | return this.Path.Equals(process.Path, StringComparison.OrdinalIgnoreCase); 75 | } 76 | 77 | public override int GetHashCode() 78 | { 79 | unchecked 80 | { 81 | var hash = 17; 82 | hash = hash * 23 + Path.GetHashCode(); 83 | return hash; 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /ProcessProxifier/Models/ProxifierSettings.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Newtonsoft.Json; 3 | using ProcessProxifier.Utils; 4 | 5 | namespace ProcessProxifier.Models 6 | { 7 | public class ProxifierSettings : INotifyPropertyChanged 8 | { 9 | bool _areAllChecked; 10 | bool _isEnabled = true; 11 | AsyncObservableCollection _processesList = new AsyncObservableCollection(); 12 | ICollectionView _processesListDataView; 13 | int _proxifierPort = 5656; 14 | AsyncObservableCollection _routedConnectionsList = new AsyncObservableCollection(); 15 | bool _runOnStartup = true; 16 | string _searchText; 17 | Process _selectedProcess; 18 | RoutedConnection _selectedRoutedConnection; 19 | ServerInfo _serverInfo = new ServerInfo(); 20 | 21 | public ProxifierSettings() 22 | { 23 | ActiveProcessesList = new AsyncObservableCollection(); 24 | } 25 | 26 | public bool AreAllChecked 27 | { 28 | get { return _areAllChecked; } 29 | set 30 | { 31 | _areAllChecked = value; 32 | notifyPropertyChanged("AreAllChecked"); 33 | 34 | foreach (var item in ProcessesList) 35 | item.IsEnabled = value; 36 | } 37 | } 38 | 39 | public ServerInfo DefaultServerInfo 40 | { 41 | get { return _serverInfo; } 42 | set 43 | { 44 | _serverInfo = value; 45 | notifyPropertyChanged("DefaultServerInfo"); 46 | } 47 | } 48 | 49 | [JsonIgnore] 50 | public bool IsEnabled 51 | { 52 | get { return _isEnabled; } 53 | set 54 | { 55 | _isEnabled = value; 56 | notifyPropertyChanged("IsEnabled"); 57 | } 58 | } 59 | 60 | [JsonIgnore] 61 | public AsyncObservableCollection ProcessesList 62 | { 63 | get { return _processesList; } 64 | set 65 | { 66 | _processesList = value; 67 | notifyPropertyChanged("ProcessesList"); 68 | } 69 | } 70 | 71 | public AsyncObservableCollection ActiveProcessesList 72 | { 73 | get; set; 74 | } 75 | 76 | [JsonIgnore] 77 | public ICollectionView ProcessesListDataView 78 | { 79 | get { return _processesListDataView; } 80 | set 81 | { 82 | _processesListDataView = value; 83 | notifyPropertyChanged("ProcessesListDataView"); 84 | } 85 | } 86 | 87 | public int ProxifierPort 88 | { 89 | get { return _proxifierPort; } 90 | set 91 | { 92 | _proxifierPort = value; 93 | notifyPropertyChanged("ProxifierPort"); 94 | } 95 | } 96 | 97 | [JsonIgnore] 98 | public AsyncObservableCollection RoutedConnectionsList 99 | { 100 | get { return _routedConnectionsList; } 101 | set 102 | { 103 | _routedConnectionsList = value; 104 | notifyPropertyChanged("RoutedConnectionsList"); 105 | } 106 | } 107 | 108 | public bool RunOnStartup 109 | { 110 | get { return _runOnStartup; } 111 | set 112 | { 113 | _runOnStartup = value; 114 | notifyPropertyChanged("RunOnStartup"); 115 | } 116 | } 117 | 118 | [JsonIgnore] 119 | public string SearchText 120 | { 121 | get { return _searchText; } 122 | set 123 | { 124 | _searchText = value; 125 | notifyPropertyChanged("SearchText"); 126 | } 127 | } 128 | 129 | [JsonIgnore] 130 | public Process SelectedProcess 131 | { 132 | get { return _selectedProcess; } 133 | set 134 | { 135 | _selectedProcess = value; 136 | notifyPropertyChanged("SelectedProcess"); 137 | } 138 | } 139 | 140 | [JsonIgnore] 141 | public RoutedConnection SelectedRoutedConnection 142 | { 143 | get { return _selectedRoutedConnection; } 144 | set 145 | { 146 | _selectedRoutedConnection = value; 147 | notifyPropertyChanged("SelectedRoutedConnection"); 148 | } 149 | } 150 | 151 | public event PropertyChangedEventHandler PropertyChanged; 152 | private void notifyPropertyChanged(string propertyName) 153 | { 154 | if (PropertyChanged != null) 155 | { 156 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 157 | } 158 | } 159 | } 160 | } -------------------------------------------------------------------------------- /ProcessProxifier/Models/RoutedConnection.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace ProcessProxifier.Models 3 | { 4 | public class RoutedConnection 5 | { 6 | public string ProcessName { set; get; } 7 | public int ProcessPid { set; get; } 8 | public string Url { set; get; } 9 | public string ProcessPath { set; get; } 10 | } 11 | } -------------------------------------------------------------------------------- /ProcessProxifier/Models/ServerInfo.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace ProcessProxifier.Models 4 | { 5 | public class ServerInfo : INotifyPropertyChanged 6 | { 7 | string _password = string.Empty; 8 | string _serverIP = string.Empty; 9 | int _serverPort; 10 | ServerType _serverType; 11 | string _username = string.Empty; 12 | 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | 15 | public string Password 16 | { 17 | get { return _password; } 18 | set 19 | { 20 | _password = value; 21 | notifyPropertyChanged("Password"); 22 | } 23 | } 24 | 25 | public string ServerIP 26 | { 27 | get { return _serverIP; } 28 | set 29 | { 30 | _serverIP = value; 31 | notifyPropertyChanged("ServerIP"); 32 | } 33 | } 34 | 35 | public int ServerPort 36 | { 37 | get { return _serverPort; } 38 | set 39 | { 40 | _serverPort = value; 41 | notifyPropertyChanged("ServerPort"); 42 | } 43 | } 44 | 45 | public ServerType ServerType 46 | { 47 | get { return _serverType; } 48 | set 49 | { 50 | _serverType = value; 51 | notifyPropertyChanged("ServerType"); 52 | } 53 | } 54 | 55 | public string Username 56 | { 57 | get { return _username; } 58 | set 59 | { 60 | _username = value; 61 | notifyPropertyChanged("Username"); 62 | } 63 | } 64 | 65 | private void notifyPropertyChanged(string propertyName) 66 | { 67 | if (PropertyChanged != null) 68 | { 69 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 70 | } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /ProcessProxifier/Models/ServerType.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace ProcessProxifier.Models 3 | { 4 | public enum ServerType 5 | { 6 | Proxy, 7 | Socks 8 | } 9 | } -------------------------------------------------------------------------------- /ProcessProxifier/ProcessProxifier.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {0644897E-EB19-44D8-B24F-2CE3C776C623} 9 | WinExe 10 | Properties 11 | ProcessProxifier 12 | ProcessProxifier 13 | v4.0 14 | 15 | 16 | 512 17 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 18 | 4 19 | 20 | 21 | x86 22 | pdbonly 23 | true 24 | bin\Release\ 25 | TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | Bin\ 32 | pdbonly 33 | true 34 | 35 | 36 | network.ico 37 | 38 | 39 | 40 | ..\Libs\DotNet4\FiddlerCore4.dll 41 | 42 | 43 | 44 | ..\packages\Newtonsoft.Json.10.0.2\lib\net40\Newtonsoft.Json.dll 45 | True 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 4.0 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | MSBuild:Compile 65 | Designer 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 | MSBuild:Compile 94 | Designer 95 | 96 | 97 | App.xaml 98 | Code 99 | 100 | 101 | 102 | MainWindow.xaml 103 | Code 104 | 105 | 106 | Designer 107 | MSBuild:Compile 108 | 109 | 110 | MSBuild:Compile 111 | Designer 112 | 113 | 114 | MSBuild:Compile 115 | Designer 116 | 117 | 118 | MSBuild:Compile 119 | Designer 120 | 121 | 122 | Designer 123 | MSBuild:Compile 124 | 125 | 126 | MSBuild:Compile 127 | Designer 128 | 129 | 130 | Designer 131 | MSBuild:Compile 132 | 133 | 134 | MSBuild:Compile 135 | Designer 136 | 137 | 138 | Designer 139 | MSBuild:Compile 140 | 141 | 142 | MSBuild:Compile 143 | Designer 144 | 145 | 146 | MSBuild:Compile 147 | Designer 148 | 149 | 150 | MSBuild:Compile 151 | Designer 152 | 153 | 154 | Designer 155 | MSBuild:Compile 156 | 157 | 158 | MSBuild:Compile 159 | Designer 160 | 161 | 162 | MSBuild:Compile 163 | Designer 164 | 165 | 166 | MSBuild:Compile 167 | Designer 168 | 169 | 170 | MSBuild:Compile 171 | Designer 172 | 173 | 174 | 175 | 176 | 177 | 178 | Code 179 | 180 | 181 | True 182 | True 183 | Resources.resx 184 | 185 | 186 | True 187 | Settings.settings 188 | True 189 | 190 | 191 | ResXFileCodeGenerator 192 | Resources.Designer.cs 193 | 194 | 195 | 196 | 197 | SettingsSingleFileGenerator 198 | Settings.Designer.cs 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 232 | -------------------------------------------------------------------------------- /ProcessProxifier/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ProcessProxifier")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ProcessProxifier")] 13 | [assembly: AssemblyCopyright("Copyright © vahid_nasiri@yahoo.com 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | //In order to begin building localizable applications, set 23 | //CultureYouAreCodingWith in your .csproj file 24 | //inside a . For example, if you are using US english 25 | //in your source files, set the to en-US. Then uncomment 26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 27 | //the line below to match the UICulture setting in the project file. 28 | 29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 30 | 31 | 32 | [assembly: ThemeInfo( 33 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 34 | //(used if a resource is not found in the page, 35 | // or application resource dictionaries) 36 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 37 | //(used if a resource is not found in the page, 38 | // app, or any theme specific resource dictionaries) 39 | )] 40 | 41 | 42 | // Version information for an assembly consists of the following four values: 43 | // 44 | // Major Version 45 | // Minor Version 46 | // Build Number 47 | // Revision 48 | // 49 | // You can specify all the values or you can default the Build and Revision Numbers 50 | // by using the '*' as shown below: 51 | // [assembly: AssemblyVersion("1.0.*")] 52 | [assembly: AssemblyVersion("1.3.0.0")] 53 | [assembly: AssemblyFileVersion("1.3.0.0")] 54 | -------------------------------------------------------------------------------- /ProcessProxifier/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.237 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ProcessProxifier.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProcessProxifier.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ProcessProxifier/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /ProcessProxifier/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.237 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ProcessProxifier.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ProcessProxifier/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ProcessProxifier/Styles/Common.xaml: -------------------------------------------------------------------------------- 1 |  3 | 6 | -------------------------------------------------------------------------------- /ProcessProxifier/Themes/BaseLight.xaml: -------------------------------------------------------------------------------- 1 |  3 | #FF000000 4 | #FFFFFFFF 5 | 6 | #FF000000 7 | #FFFFFFFF 8 | 9 | #FF7F7F7F 10 | #FF333333 11 | #FFD8D8D9 12 | #FFF7F7F7 13 | #FFE0E0E0 14 | 15 | #FFBEBEBE 16 | #FF333333 17 | -------------------------------------------------------------------------------- /ProcessProxifier/Themes/Blue.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | #FF086F9E 5 | #FF086F9E 6 | 7 | #FF1c739d 8 | 9 | 10 | #CC119EDA 11 | 12 | #99119EDA 13 | 14 | #66119EDA 15 | 16 | #33119EDA 17 | 18 | 21 | 23 | 25 | 26 | 27 | 29 | 30 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ProcessProxifier/Themes/Button.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 52 | 53 | 192 | 193 | 18 | 19 | 23 | -------------------------------------------------------------------------------- /ProcessProxifier/Themes/GroupBox.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 42 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 45 | 46 | 47 | 48 | 10 | 11 | 17 | 18 | 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 | 117 | 118 | 131 | 132 | 186 | 187 | 101 | 102 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 178 | 179 | 56 | 57 |