├── .upgrade-assistant ├── AirspaceFixerSample ├── App.config ├── packages.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── App.xaml ├── App.xaml.cs ├── MainWindow.xaml.cs ├── app.manifest ├── MainWindow.xaml └── AirspaceFixerSample.csproj ├── AirspaceFixer ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Themes │ ├── Generic.xaml │ └── AirspacePanel.xaml ├── LICENSE.txt ├── Readme.md ├── AirspaceFixer.csproj └── AirspacePanel.cs ├── AirspaceFixerSampleNet6 ├── App.xaml ├── App.xaml.cs ├── AirspaceFixerSampleNet6.csproj ├── AssemblyInfo.cs ├── MainWindow.xaml.cs └── MainWindow.xaml ├── .gitattributes ├── LICENSE ├── Readme.md ├── AirspaceFixer.sln ├── AnalysisReport.sarif └── .gitignore /.upgrade-assistant: -------------------------------------------------------------------------------- 1 | {"Build":"0.3.326103\u002B3dfe0925b5198e8bb4cae20f02bfd968e95eb1e8","CurrentProject":"AirspaceFixer.csproj","EntryPoints":["AirspaceFixer.csproj"],"Properties":{}} -------------------------------------------------------------------------------- /AirspaceFixerSample/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AirspaceFixer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AirspaceFixerSample/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /AirspaceFixerSample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AirspaceFixerSample/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace Test2 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AirspaceFixerSample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace AirspaceFixerSample 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/AirspaceFixerSampleNet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /AirspaceFixer/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /AirspaceFixer/Themes/AirspacePanel.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 chris84948 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /AirspaceFixer/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 chris84948 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /AirspaceFixer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 AirspaceFixer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.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 | -------------------------------------------------------------------------------- /AirspaceFixerSample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 AirspaceFixerSample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.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 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## Airspace Fixer 2 | 3 | AirspaceFixer is a small lightweight project that only contains a single control - `AirspacePanel`. 4 | 5 | If you've ever had to host any WinForms forms inside a WPF project, you might know about the dreaded Airspace problem. Basically, the WinForms control **must** always be on top. Even if you try to put a modal dialog on top of the WinForms control, this Airspace issue forces the WinForms control on top. 6 | 7 | Now, you may be thinking, WinForms, gross, I'll never do that, well, me too, but I had to use the `WebBrowser` control recently, and since it's a legacy control (made in WinForms), the same Airspace problem applies. 8 | 9 | `AirspacePanel` aims to fix this problem by allowing you to host any content you like inside of it, and swapping out the content for a screenshot of the content when you need to place a modal dialog on top of it. This swap is done by using the dependency property `FixAirspace`. Here's an example - 10 | 11 | xmlns:asf="clr-namespace:AirspaceFixer;assembly=AirspaceFixer" 12 | 13 | 14 | 15 | 16 | 17 | See the sample app for more info on how to use it. 18 | 19 | AirspaceFixer is also available in Nuget to include as a package. -------------------------------------------------------------------------------- /AirspaceFixer/Readme.md: -------------------------------------------------------------------------------- 1 | ## Airspace Fixer 2 | 3 | AirspaceFixer is a small lightweight project that only contains a single control - `AirspacePanel`. 4 | 5 | If you've ever had to host any WinForms forms inside a WPF project, you might know about the dreaded Airspace problem. Basically, the WinForms control **must** always be on top. Even if you try to put a modal dialog on top of the WinForms control, this Airspace issue forces the WinForms control on top. 6 | 7 | Now, you may be thinking, WinForms, gross, I'll never do that, well, me too, but I had to use the `WebBrowser` control recently, and since it's a legacy control (made in WinForms), the same Airspace problem applies. 8 | 9 | `AirspacePanel` aims to fix this problem by allowing you to host any content you like inside of it, and swapping out the content for a screenshot of the content when you need to place a modal dialog on top of it. This swap is done by using the dependency property `FixAirspace`. Here's an example - 10 | 11 | xmlns:asf="clr-namespace:AirspaceFixer;assembly=AirspaceFixer" 12 | 13 | 14 | 15 | 16 | 17 | See the sample app for more info on how to use it. 18 | 19 | AirspaceFixer is also available in Nuget to include as a package. -------------------------------------------------------------------------------- /AirspaceFixer/AirspaceFixer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0-windows;net452 4 | Library 5 | false 6 | true 7 | true 8 | true 9 | True 10 | 1.1.0 11 | ChrisBJohnsonDev 12 | ChrisBJohnsonDev 13 | AirspacePanel fixes all Airspace issues with WPF-hosted Winforms. 14 | https://github.com/chris84948/AirspaceFixer 15 | https://github.com/chris84948/AirspaceFixer 16 | git 17 | Removing unnecessary code 18 | LICENSE.txt 19 | Readme.md 20 | True 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | all 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | using System.Windows.Navigation; 4 | 5 | namespace Test2 6 | { 7 | /// 8 | /// Interaction logic for MainWindow.xaml 9 | /// 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | Loaded += WebBrowserView_Loaded; 16 | } 17 | 18 | private void WebBrowserView_Loaded(object sender, RoutedEventArgs e) 19 | { 20 | Browser.Navigate("http://www.google.com"); 21 | } 22 | 23 | private void btnForward_Click(object sender, RoutedEventArgs e) 24 | { 25 | if (Browser != null && Browser.CanGoForward) 26 | Browser.GoForward(); 27 | } 28 | 29 | private void btnBack_Click(object sender, RoutedEventArgs e) 30 | { 31 | if (Browser != null && Browser.CanGoBack) 32 | Browser.GoBack(); 33 | } 34 | 35 | private void Browser_Navigating(object sender, NavigatingCancelEventArgs e) 36 | { 37 | txtUrl.Text = e.Uri.OriginalString; 38 | } 39 | 40 | private void txtUrl_KeyUp(object sender, KeyEventArgs e) 41 | { 42 | Browser.Navigate(txtUrl.Text); 43 | } 44 | 45 | private void btnSettings_Click(object sender, RoutedEventArgs e) 46 | { 47 | airspacePanel.FixAirspace = true; 48 | gridDialog.Visibility = Visibility.Visible; 49 | } 50 | 51 | private void btnCloseDialog_Click(object sender, RoutedEventArgs e) 52 | { 53 | airspacePanel.FixAirspace = false; 54 | gridDialog.Visibility = Visibility.Hidden; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /AirspaceFixerSample/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | using System.Windows.Navigation; 4 | 5 | namespace AirspaceFixerSample 6 | { 7 | /// 8 | /// Interaction logic for MainWindow.xaml 9 | /// 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | Loaded += WebBrowserView_Loaded; 16 | } 17 | 18 | private void WebBrowserView_Loaded(object sender, RoutedEventArgs e) 19 | { 20 | Browser.Navigate("http://www.google.com"); 21 | Browser2.Navigate("http://www.google.com"); 22 | } 23 | 24 | private void btnForward_Click(object sender, RoutedEventArgs e) 25 | { 26 | if (Browser != null && Browser.CanGoForward) 27 | Browser.GoForward(); 28 | } 29 | 30 | private void btnBack_Click(object sender, RoutedEventArgs e) 31 | { 32 | if (Browser != null && Browser.CanGoBack) 33 | Browser.GoBack(); 34 | } 35 | 36 | private void Browser_Navigating(object sender, NavigatingCancelEventArgs e) 37 | { 38 | txtUrl.Text = e.Uri.OriginalString; 39 | } 40 | 41 | private void txtUrl_KeyUp(object sender, KeyEventArgs e) 42 | { 43 | Browser.Navigate(txtUrl.Text); 44 | } 45 | 46 | private void btnSettings_Click(object sender, RoutedEventArgs e) 47 | { 48 | airspacePanel.FixAirspace = true; 49 | gridDialog.Visibility = Visibility.Visible; 50 | } 51 | 52 | private void btnCloseDialog_Click(object sender, RoutedEventArgs e) 53 | { 54 | airspacePanel.FixAirspace = false; 55 | airspacePanel2.FixAirspace = false; 56 | gridDialog.Visibility = Visibility.Hidden; 57 | } 58 | 59 | private void ButtonResizable_Click(object sender, RoutedEventArgs e) 60 | { 61 | airspacePanel2.FixAirspace = true; 62 | gridDialog.Visibility = Visibility.Visible; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /AirspaceFixer.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32126.317 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirspaceFixer", "AirspaceFixer\AirspaceFixer.csproj", "{9B83BCF9-6835-490D-91BE-2334BC1A548C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirspaceFixerSample", "AirspaceFixerSample\AirspaceFixerSample.csproj", "{FEFA7E80-EDE6-492B-B18D-0BFD04EBF846}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirspaceFixerSampleNet6", "AirspaceFixerSampleNet6\AirspaceFixerSampleNet6.csproj", "{51E0427B-066F-4055-ABAA-B11B2672C42F}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {9B83BCF9-6835-490D-91BE-2334BC1A548C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {9B83BCF9-6835-490D-91BE-2334BC1A548C}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {9B83BCF9-6835-490D-91BE-2334BC1A548C}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {9B83BCF9-6835-490D-91BE-2334BC1A548C}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {FEFA7E80-EDE6-492B-B18D-0BFD04EBF846}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {FEFA7E80-EDE6-492B-B18D-0BFD04EBF846}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {FEFA7E80-EDE6-492B-B18D-0BFD04EBF846}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {FEFA7E80-EDE6-492B-B18D-0BFD04EBF846}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {51E0427B-066F-4055-ABAA-B11B2672C42F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {51E0427B-066F-4055-ABAA-B11B2672C42F}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {51E0427B-066F-4055-ABAA-B11B2672C42F}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {51E0427B-066F-4055-ABAA-B11B2672C42F}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {011E0719-2EB0-42C4-8D2E-9E483E577B22} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /AirspaceFixerSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("AirspaceFixerSample")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("AirspaceFixerSample")] 15 | [assembly: AssemblyCopyright("Copyright © 2016")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /AirspaceFixer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("AirspaceFixer")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("AirspaceFixer")] 15 | [assembly: AssemblyCopyright("Copyright © 2022")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly:ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.1.0")] 55 | [assembly: AssemblyFileVersion("1.1.0")] 56 | 57 | #if NET6_0_OR_GREATER 58 | [assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")] 59 | [assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")] 60 | #endif -------------------------------------------------------------------------------- /AirspaceFixer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 AirspaceFixer.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("AirspaceFixer.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 | -------------------------------------------------------------------------------- /AirspaceFixerSample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 AirspaceFixerSample.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", "17.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("AirspaceFixerSample.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 | -------------------------------------------------------------------------------- /AirspaceFixerSample/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 58 | 59 | 60 | 61 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /AnalysisReport.sarif: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", 3 | "version": "2.1.0", 4 | "runs": [ 5 | { 6 | "tool": { 7 | "driver": { 8 | "name": "Dependency Analysis", 9 | "semanticVersion": "0.3.326103", 10 | "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview", 11 | "rules": [ 12 | { 13 | "id": "UA106", 14 | "name": "PackageToBeAdded", 15 | "fullDescription": { 16 | "text": "Packages that need to be added in order to upgrade the project to chosen TFM" 17 | }, 18 | "helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" 19 | } 20 | ] 21 | } 22 | }, 23 | "results": [ 24 | { 25 | "ruleId": "UA106", 26 | "message": { 27 | "text": "Package Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.3.326103 needs to be added." 28 | }, 29 | "locations": [ 30 | { 31 | "physicalLocation": { 32 | "artifactLocation": { 33 | "uri": "file:///c:/github/c%23/AirspaceFixer/AirspaceFixer/AirspaceFixer.csproj" 34 | }, 35 | "region": {} 36 | } 37 | } 38 | ] 39 | }, 40 | { 41 | "ruleId": "UA106", 42 | "message": { 43 | "text": "Package Microsoft.Windows.Compatibility, Version=6.0.0 needs to be added." 44 | }, 45 | "locations": [ 46 | { 47 | "physicalLocation": { 48 | "artifactLocation": { 49 | "uri": "file:///c:/github/c%23/AirspaceFixer/AirspaceFixer/AirspaceFixer.csproj" 50 | }, 51 | "region": {} 52 | } 53 | } 54 | ] 55 | }, 56 | { 57 | "ruleId": "UA106", 58 | "message": { 59 | "text": "Package Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.3.326103 needs to be added." 60 | }, 61 | "locations": [ 62 | { 63 | "physicalLocation": { 64 | "artifactLocation": { 65 | "uri": "file:///c:/github/c%23/AirspaceFixer/AirspaceFixerSample/AirspaceFixerSample.csproj" 66 | }, 67 | "region": {} 68 | } 69 | } 70 | ] 71 | }, 72 | { 73 | "ruleId": "UA106", 74 | "message": { 75 | "text": "Package Microsoft.Windows.Compatibility, Version=6.0.0 needs to be added." 76 | }, 77 | "locations": [ 78 | { 79 | "physicalLocation": { 80 | "artifactLocation": { 81 | "uri": "file:///c:/github/c%23/AirspaceFixer/AirspaceFixerSample/AirspaceFixerSample.csproj" 82 | }, 83 | "region": {} 84 | } 85 | } 86 | ] 87 | } 88 | ], 89 | "columnKind": "utf16CodeUnits" 90 | }, 91 | { 92 | "tool": { 93 | "driver": { 94 | "name": "API Upgradability", 95 | "semanticVersion": "0.3.326103", 96 | "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" 97 | } 98 | }, 99 | "results": [], 100 | "columnKind": "utf16CodeUnits" 101 | }, 102 | { 103 | "tool": { 104 | "driver": { 105 | "name": "Component Analysis", 106 | "semanticVersion": "0.3.326103", 107 | "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" 108 | } 109 | }, 110 | "results": [], 111 | "columnKind": "utf16CodeUnits" 112 | } 113 | ] 114 | } -------------------------------------------------------------------------------- /AirspaceFixer/AirspacePanel.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing.Imaging; 2 | using System.IO; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | using System.Windows.Media.Imaging; 7 | 8 | namespace AirspaceFixer 9 | { 10 | public class AirspacePanel : ContentControl 11 | { 12 | public static readonly DependencyProperty FixAirspaceProperty = 13 | DependencyProperty.Register("FixAirspace", 14 | typeof(bool), 15 | typeof(AirspacePanel), 16 | new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnFixAirspaceChanged))); 17 | public bool FixAirspace 18 | { 19 | get { return (bool)GetValue(FixAirspaceProperty); } 20 | set { SetValue(FixAirspaceProperty, value); } 21 | } 22 | 23 | private Image airspaceScreenshot; 24 | private ContentControl airspaceContent; 25 | 26 | static AirspacePanel() 27 | { 28 | DefaultStyleKeyProperty.OverrideMetadata(typeof(AirspacePanel), new FrameworkPropertyMetadata(typeof(AirspacePanel))); 29 | } 30 | 31 | public override void OnApplyTemplate() 32 | { 33 | base.OnApplyTemplate(); 34 | 35 | airspaceContent = GetTemplateChild("PART_AirspaceContent") as ContentControl; 36 | airspaceScreenshot = GetTemplateChild("PART_AirspaceScreenshot") as Image; 37 | } 38 | 39 | private void AirspacePanel_SizeChanged(object sender, SizeChangedEventArgs e) 40 | { 41 | // On resize, make sure to update the image 42 | if (FixAirspace) 43 | FixAirspaceShared(true); 44 | } 45 | 46 | private static void OnFixAirspaceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 47 | { 48 | if (d is AirspacePanel panel) 49 | panel.FixAirspaceShared((bool)e.NewValue); 50 | } 51 | 52 | private void FixAirspaceShared(bool fix) 53 | { 54 | if (ActualWidth == 0 || ActualHeight == 0 || PresentationSource.FromVisual(this) == null) 55 | return; 56 | 57 | if (fix) 58 | { 59 | CreateScreenshotFromContent(); 60 | airspaceContent.Visibility = Visibility.Hidden; 61 | airspaceScreenshot.Visibility = Visibility.Visible; 62 | } 63 | else 64 | { 65 | airspaceContent.Visibility = Visibility.Visible; 66 | airspaceScreenshot.Visibility = Visibility.Hidden; 67 | airspaceScreenshot.Source = null; 68 | } 69 | } 70 | 71 | private void CreateScreenshotFromContent() 72 | { 73 | // https://stackoverflow.com/questions/1918877/how-can-i-get-the-dpi-in-wpf 74 | double scalingFactor = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice.M11 ?? 1.0; 75 | 76 | Point upperLeftPoint = airspaceContent.PointToScreen(new Point(0, 0)); 77 | var bounds = new System.Drawing.Rectangle((int)(upperLeftPoint.X * scalingFactor), 78 | (int)(upperLeftPoint.Y * scalingFactor), 79 | (int)(airspaceContent.RenderSize.Width * scalingFactor), 80 | (int)(airspaceContent.RenderSize.Height * scalingFactor)); 81 | 82 | if (bounds.Width == 0 || bounds.Height == 0) 83 | return; 84 | 85 | using (var bitmap = new System.Drawing.Bitmap((int)bounds.Width, (int)bounds.Height)) 86 | { 87 | using (var g = System.Drawing.Graphics.FromImage(bitmap)) 88 | { 89 | g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), 90 | System.Drawing.Point.Empty, 91 | new System.Drawing.Size((int)bounds.Width, (int)bounds.Height)); 92 | } 93 | 94 | airspaceScreenshot.Source = GetImageSourceFromBitmap(bitmap); 95 | } 96 | } 97 | 98 | public ImageSource GetImageSourceFromBitmap(System.Drawing.Bitmap bitmap) 99 | { 100 | using (var memory = new MemoryStream()) 101 | { 102 | bitmap.Save(memory, ImageFormat.Png); 103 | memory.Position = 0; 104 | BitmapImage bitmapImage = new BitmapImage(); 105 | bitmapImage.BeginInit(); 106 | bitmapImage.StreamSource = memory; 107 | bitmapImage.CacheOption = BitmapCacheOption.OnLoad; 108 | bitmapImage.EndInit(); 109 | return bitmapImage; 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /AirspaceFixerSampleNet6/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |