Files
29WxOrder/29WxOrderWpf/Views/PddMobileLoginView.xaml.cs
T

63 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using _29WxOrderWpf.BaseWindows;
using _29WxOrderWpf.ViewModels;
using AllBase.Model.DBModel;
using CefSharp.Wpf;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace _29WxOrderWpf.Views
{
/// <summary>
/// 拼多多买手移动版登录窗口(WPF 版 PddMobileLoginForm)
/// </summary>
public partial class PddMobileLoginView : UserControl
{
/// <summary>视图模型</summary>
public PddMobileLoginViewModel ViewModel { get; }
public PddMobileLoginView(BuyerLoginInfo buyerInfo)
{
InitializeComponent();
ViewModel = new PddMobileLoginViewModel(buyerInfo);
ViewModel.BrowserCreated += ViewModel_BrowserCreated;
ViewModel.RequestClose += ViewModel_RequestClose;
DataContext = ViewModel;
}
private void PddMobileLoginView_Loaded(object sender, RoutedEventArgs e)
{
ViewModel.Start();
}
private void PddMobileLoginView_Closed(object sender, System.EventArgs e)
{
ViewModel.Stop();
}
private void ViewModel_BrowserCreated(ChromiumWebBrowser browser)
{
Grid.SetRow(browser, 0);
Grid.SetColumn(browser, 0);
BrowserHost.Children.Add(browser);
}
private void ViewModel_RequestClose()
{
Window parentWindow = Window.GetWindow(this);
if (this.IsLoaded && parentWindow != null)
parentWindow.Close();
}
private void txtAddress_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ViewModel.ReloadCommand.Execute(null);
}
}
}
}