From 954925e0535be6d6947e12ec3c8571612e3b7540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=A3=8A=20=E5=BC=A0?= Date: Fri, 25 Jun 2021 09:42:10 +0800 Subject: [PATCH] first commit --- .gitignore | 23 ++++ App.config | 6 + App.xaml | 11 ++ App.xaml.cs | 36 ++++++ Behaviours/HoverLinkBehaviour.cs | 36 ++++++ .../TextBoxBindingUpdateOnEnterBehaviour.cs | 28 +++++ Converter/EnvironmentConverter.cs | 19 +++ Converter/TitleConverter.cs | 19 +++ JdLoginTool.csproj | 77 ++++++++++++ JdLoginTool.csproj.user | 6 + JdLoginTool.sln | 31 +++++ MainWindow.xaml | 97 +++++++++++++++ MainWindow.xaml.cs | 34 +++++ Program.netcore.cs | 60 +++++++++ Properties/AssemblyInfo.cs | 53 ++++++++ .../PublishProfiles/FolderProfile.pubxml | 12 ++ .../PublishProfiles/FolderProfile.pubxml.user | 6 + Properties/Resources.Designer.cs | 63 ++++++++++ Properties/Resources.resx | 117 ++++++++++++++++++ Properties/Settings.Designer.cs | 26 ++++ Properties/Settings.settings | 7 ++ README.MD | 3 + app.manifest | 60 +++++++++ chromium-256.ico | Bin 0 -> 49741 bytes crash_reporter.cfg | 12 ++ packages.config | 8 ++ 26 files changed, 850 insertions(+) create mode 100644 .gitignore create mode 100644 App.config create mode 100644 App.xaml create mode 100644 App.xaml.cs create mode 100644 Behaviours/HoverLinkBehaviour.cs create mode 100644 Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs create mode 100644 Converter/EnvironmentConverter.cs create mode 100644 Converter/TitleConverter.cs create mode 100644 JdLoginTool.csproj create mode 100644 JdLoginTool.csproj.user create mode 100644 JdLoginTool.sln create mode 100644 MainWindow.xaml create mode 100644 MainWindow.xaml.cs create mode 100644 Program.netcore.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 Properties/PublishProfiles/FolderProfile.pubxml.user create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 README.MD create mode 100644 app.manifest create mode 100644 chromium-256.ico create mode 100644 crash_reporter.cfg create mode 100644 packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09f7543 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/bin +/obj +/.vs +/LinesWithUI/obj +/LinesWithUI/bin +/packages +/src/LinesConsole/obj +/src/LinesConsole/bin +/src/LinesWithUI/bin +/src/LinesWithUI/obj +/JdTry.WebAPI/obj +/JdTry.WebAPI/bin +/JdTry.WebAPI/db +/JdTry/.vs +/JdTry.Console/bin +/JdTry.Console/obj +/JdTry/bin +/JdTry/obj +/JdIOSWebLoginTool/obj.netcore +/JdIOSWebLoginTool/bin.netcore +/JdIOSWebLoginTool/bin +/bin.netcore +/obj.netcore diff --git a/App.config b/App.config new file mode 100644 index 0000000..5de900d --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..d6b21c0 --- /dev/null +++ b/App.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..6ef817c --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,36 @@ +using CefSharp.Wpf; +using System; +using System.IO; +using System.Windows; + +namespace JdLoginTool.Wpf +{ + public partial class App : Application + { + public App() + { +#if !NETCOREAPP + var settings = new CefSettings() + { + //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data + CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") + }; + + //Example of setting a command line argument + //Enables WebRTC + // - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access + // - CEF Doesn't currently support displaying a UI for media access permissions + // + //NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart + settings.CefCommandLineArgs.Add("enable-media-stream"); + //https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream + settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream"); + //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180) + settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing"); + + //Perform dependency check to make sure all relevant resources are in our output directory. + Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); +#endif + } + } +} diff --git a/Behaviours/HoverLinkBehaviour.cs b/Behaviours/HoverLinkBehaviour.cs new file mode 100644 index 0000000..8a2e3e1 --- /dev/null +++ b/Behaviours/HoverLinkBehaviour.cs @@ -0,0 +1,36 @@ +using CefSharp.Wpf; +using System.Windows; +using System; +using CefSharp; +using Microsoft.Xaml.Behaviors; + +namespace JdLoginTool.Wpf.Behaviours +{ + public class HoverLinkBehaviour : Behavior + { + // Using a DependencyProperty as the backing store for HoverLink. This enables animation, styling, binding, etc... + public static readonly DependencyProperty HoverLinkProperty = DependencyProperty.Register("HoverLink", typeof(string), typeof(HoverLinkBehaviour), new PropertyMetadata(string.Empty)); + + public string HoverLink + { + get { return (string)GetValue(HoverLinkProperty); } + set { SetValue(HoverLinkProperty, value); } + } + + protected override void OnAttached() + { + AssociatedObject.StatusMessage += OnStatusMessageChanged; + } + + protected override void OnDetaching() + { + AssociatedObject.StatusMessage -= OnStatusMessageChanged; + } + + private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e) + { + var chromiumWebBrowser = sender as ChromiumWebBrowser; + chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() => HoverLink = e.Value)); + } + } +} diff --git a/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs b/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs new file mode 100644 index 0000000..80a4364 --- /dev/null +++ b/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs @@ -0,0 +1,28 @@ +using System.Windows.Controls; +using System.Windows.Input; +using Microsoft.Xaml.Behaviors; + +namespace JdLoginTool.Wpf.Behaviours +{ + public class TextBoxBindingUpdateOnEnterBehaviour : Behavior + { + protected override void OnAttached() + { + AssociatedObject.KeyDown += OnTextBoxKeyDown; + } + + protected override void OnDetaching() + { + AssociatedObject.KeyDown -= OnTextBoxKeyDown; + } + + private void OnTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + var txtBox = sender as TextBox; + txtBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); + } + } + } +} diff --git a/Converter/EnvironmentConverter.cs b/Converter/EnvironmentConverter.cs new file mode 100644 index 0000000..2b59310 --- /dev/null +++ b/Converter/EnvironmentConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace JdLoginTool.Wpf.Converter +{ + public class EnvironmentConverter : IValueConverter + { + object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return Environment.Is64BitProcess ? "x64" : "x86"; + } + + object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return Binding.DoNothing; + } + } +} diff --git a/Converter/TitleConverter.cs b/Converter/TitleConverter.cs new file mode 100644 index 0000000..a2ff215 --- /dev/null +++ b/Converter/TitleConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace JdLoginTool.Wpf.Converter +{ + public class TitleConverter : IValueConverter + { + object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return "JdLoginTool.Wpf - " + (value ?? "No Title Specified"); + } + + object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return Binding.DoNothing; + } + } +} diff --git a/JdLoginTool.csproj b/JdLoginTool.csproj new file mode 100644 index 0000000..2a20464 --- /dev/null +++ b/JdLoginTool.csproj @@ -0,0 +1,77 @@ + + + + + obj.netcore\ + bin.netcore\ + + + + + + WinExe + netcoreapp3.0 + true + JdLoginTool.Wpf + chromium-256.ico + app.manifest + false + x86;x64 + JdLoginTool.Wpf.Program + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + + + + + + + $(CefSharpBrowserProcessCore64) + true + + + + + + + + $(CefSharpBrowserProcessCore32) + true + + + + + + + \ No newline at end of file diff --git a/JdLoginTool.csproj.user b/JdLoginTool.csproj.user new file mode 100644 index 0000000..856eb16 --- /dev/null +++ b/JdLoginTool.csproj.user @@ -0,0 +1,6 @@ + + + + <_LastSelectedProfileId>C:\Users\Administrator\Desktop\CustomRuntime-dotnetDemo\JdTry\src\JdIOSWebLoginTool\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file diff --git a/JdLoginTool.sln b/JdLoginTool.sln new file mode 100644 index 0000000..316a271 --- /dev/null +++ b/JdLoginTool.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JdLoginTool", "JdLoginTool.csproj", "{A780186E-1599-4351-AC24-82A9798B89E6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A780186E-1599-4351-AC24-82A9798B89E6}.Debug|x64.ActiveCfg = Debug|x64 + {A780186E-1599-4351-AC24-82A9798B89E6}.Debug|x64.Build.0 = Debug|x64 + {A780186E-1599-4351-AC24-82A9798B89E6}.Debug|x86.ActiveCfg = Debug|x86 + {A780186E-1599-4351-AC24-82A9798B89E6}.Debug|x86.Build.0 = Debug|x86 + {A780186E-1599-4351-AC24-82A9798B89E6}.Release|x64.ActiveCfg = Release|x64 + {A780186E-1599-4351-AC24-82A9798B89E6}.Release|x64.Build.0 = Release|x64 + {A780186E-1599-4351-AC24-82A9798B89E6}.Release|x86.ActiveCfg = Release|x86 + {A780186E-1599-4351-AC24-82A9798B89E6}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CEE52165-D1C0-4831-911E-A0567ECD770F} + EndGlobalSection +EndGlobal diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..d51f698 --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + +