Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanggaolei001 committed Jun 25, 2021
0 parents commit 954925e
Show file tree
Hide file tree
Showing 26 changed files with 850 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
11 changes: 11 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Application x:Class="JdLoginTool.Wpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:JdLoginTool.Wpf.Converter"
StartupUri="MainWindow.xaml">
<Application.Resources>
<converter:TitleConverter x:Key="TitleConverter"/>
<converter:EnvironmentConverter x:Key="EnvironmentConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</Application.Resources>
</Application>
36 changes: 36 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
36 changes: 36 additions & 0 deletions Behaviours/HoverLinkBehaviour.cs
Original file line number Diff line number Diff line change
@@ -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<ChromiumWebBrowser>
{
// 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));
}
}
}
28 changes: 28 additions & 0 deletions Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.Xaml.Behaviors;

namespace JdLoginTool.Wpf.Behaviours
{
public class TextBoxBindingUpdateOnEnterBehaviour : Behavior<TextBox>
{
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();
}
}
}
}
19 changes: 19 additions & 0 deletions Converter/EnvironmentConverter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
19 changes: 19 additions & 0 deletions Converter/TitleConverter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
77 changes: 77 additions & 0 deletions JdLoginTool.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Note: We cannot use the recommended style of specifying <Project Sdk=...> because we need
to set BaseIntermediateOutputPath and BaseOutputPath before the SDK props are imported. -->
<PropertyGroup>
<BaseIntermediateOutputPath>obj.netcore\</BaseIntermediateOutputPath>
<BaseOutputPath>bin.netcore\</BaseOutputPath>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>JdLoginTool.Wpf</RootNamespace>
<ApplicationIcon>chromium-256.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Platforms>x86;x64</Platforms>
<StartupObject>JdLoginTool.Wpf.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
<Compile Remove="bin\**" />
<Compile Remove="obj\**" />
<EmbeddedResource Remove="bin\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="bin\**" />
<None Remove="obj\**" />
<Page Remove="bin\**" />
<Page Remove="obj\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CefSharp.Wpf" Version="85.3.130" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
</ItemGroup>

<ItemGroup>
<!-- TODO: These updates are currently required because CefSharp.Wpf specifies
<Private>false</Private>, which means these libraries will not be specified in
the .deps.json file, and so the CoreCLR wouldn't load these. -->
<Reference Update="CefSharp">
<Private>true</Private>
</Reference>
<Reference Update="CefSharp.Core">
<Private>true</Private>
</Reference>
<Reference Update="CefSharp.Wpf">
<Private>true</Private>
</Reference>
</ItemGroup>

<!-- Include CefSharp.BrowserSubprocess.Core so we can selfhost the BrowserSubProcess using our exe -->
<Choose>
<When Condition="'$(PlatformTarget)' == 'x64'">
<ItemGroup>
<Reference Include="CefSharp.BrowserSubprocess.Core">
<HintPath>$(CefSharpBrowserProcessCore64)</HintPath>
<Private>true</Private>
</Reference>
</ItemGroup>
</When>
<!-- x86, Win32 and AnyCPU -->
<Otherwise>
<ItemGroup>
<Reference Include="CefSharp.BrowserSubprocess.Core">
<HintPath>$(CefSharpBrowserProcessCore32)</HintPath>
<Private>true</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />
</Project>
6 changes: 6 additions & 0 deletions JdLoginTool.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\Administrator\Desktop\CustomRuntime-dotnetDemo\JdTry\src\JdIOSWebLoginTool\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
31 changes: 31 additions & 0 deletions JdLoginTool.sln
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 954925e

Please sign in to comment.