Browse Source

Wpf.Example - Remove MvvmLight

pull/3282/head
campersau 5 years ago
committed by Alex Maitland
parent
commit
8ad0c76f1b
  1. 16
      CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj
  2. 1
      CefSharp.Wpf.Example/CefSharp.Wpf.Example.netcore.csproj
  3. 1
      CefSharp.Wpf.Example/Controls/ChromiumWebBrowserWithScreenshotSupport.cs
  4. 3
      CefSharp.Wpf.Example/Handlers/MenuHandler.cs
  5. 55
      CefSharp.Wpf.Example/RelayCommand.cs
  6. 17
      CefSharp.Wpf.Example/ViewModels/BrowserTabViewModel.cs
  7. 2
      CefSharp.Wpf.Example/packages.config

16
CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj

@ -74,27 +74,12 @@
<StartupObject>CefSharp.Wpf.Example.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommonServiceLocator, Version=2.0.2.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.4.1.0, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
@ -121,6 +106,7 @@
<Compile Include="JavascriptCallbackMainWindow.xaml.cs">
<DependentUpon>JavascriptCallbackMainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="RelayCommand.cs" />
<Compile Include="StandardTabControlWindow.xaml.cs">
<DependentUpon>StandardTabControlWindow.xaml</DependentUpon>
</Compile>

1
CefSharp.Wpf.Example/CefSharp.Wpf.Example.netcore.csproj

@ -27,7 +27,6 @@
<ProjectReference Include="..\CefSharp.Example\CefSharp.Example.netcore.csproj" />
<ProjectReference Include="..\CefSharp.Wpf\CefSharp.Wpf.netcore.csproj" />
<ProjectReference Include="..\CefSharp\CefSharp.netcore.csproj" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="cef.redist.x86" Version="87.1.1" />
<PackageReference Include="cef.redist.x64" Version="87.1.1" />
</ItemGroup>

1
CefSharp.Wpf.Example/Controls/ChromiumWebBrowserWithScreenshotSupport.cs

@ -15,7 +15,6 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using GalaSoft.MvvmLight.Command;
using Size = System.Windows.Size;
namespace CefSharp.Wpf.Example.Controls

3
CefSharp.Wpf.Example/Handlers/MenuHandler.cs

@ -7,7 +7,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Command;
namespace CefSharp.Wpf.Example.Handlers
{
@ -199,7 +198,7 @@ namespace CefSharp.Wpf.Example.Handlers
break;
}
}
}, keepTargetAlive: true)
})
});
}
webBrowser.ContextMenu = menu;

55
CefSharp.Wpf.Example/RelayCommand.cs

@ -0,0 +1,55 @@
// Copyright © 2017 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Windows.Input;
namespace CefSharp.Wpf.Example
{
public class RelayCommand : ICommand
{
private readonly Action<object> commandHandler;
private readonly Func<object, bool> canExecuteHandler;
public event EventHandler CanExecuteChanged;
public RelayCommand(Action<object> commandHandler, Func<object, bool> canExecuteHandler = null)
{
this.commandHandler = commandHandler;
this.canExecuteHandler = canExecuteHandler;
}
public RelayCommand(Action commandHandler, Func<bool> canExecuteHandler = null)
: this(_ => commandHandler(), canExecuteHandler == null ? null : new Func<object, bool>(_ => canExecuteHandler()))
{
}
public void Execute(object parameter)
{
commandHandler(parameter);
}
public bool CanExecute(object parameter)
{
return
canExecuteHandler == null ||
canExecuteHandler(parameter);
}
public void RaiseCanExecuteChanged()
{
if (CanExecuteChanged != null)
{
CanExecuteChanged(this, EventArgs.Empty);
}
}
}
public class RelayCommand<T> : RelayCommand
{
public RelayCommand(Action<T> commandHandler, Func<T, bool> canExecuteHandler = null)
: base(o => commandHandler(o is T t ? t : default(T)), canExecuteHandler == null ? null : new Func<object, bool>(o => canExecuteHandler(o is T t ? t : default(T))))
{
}
}
}

17
CefSharp.Wpf.Example/ViewModels/BrowserTabViewModel.cs

@ -4,16 +4,15 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using CefSharp.Example;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
namespace CefSharp.Wpf.Example.ViewModels
{
public class BrowserTabViewModel : ViewModelBase
public class BrowserTabViewModel : INotifyPropertyChanged
{
private string address;
public string Address
@ -93,6 +92,9 @@ namespace CefSharp.Wpf.Example.ViewModels
}
private bool legacyBindingEnabled;
public event PropertyChangedEventHandler PropertyChanged;
public bool LegacyBindingEnabled
{
get { return legacyBindingEnabled; }
@ -228,5 +230,14 @@ namespace CefSharp.Wpf.Example.ViewModels
WebBrowser.LoadUrlWithPostData("https://cefsharp.com/PostDataTest.html", postData);
}
protected void Set<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
field = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

2
CefSharp.Wpf.Example/packages.config

@ -2,7 +2,5 @@
<packages>
<package id="cef.redist.x64" version="87.1.1" targetFramework="net472" />
<package id="cef.redist.x86" version="87.1.1" targetFramework="net472" />
<package id="CommonServiceLocator" version="2.0.2" targetFramework="net462" requireReinstallation="true" />
<package id="Microsoft.Net.Compilers" version="2.9.0" targetFramework="net462" developmentDependency="true" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net462" />
</packages>
Loading…
Cancel
Save