| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.Trade.ViewModels;
- using Muchinfo.MTPClient.Trade.ViewModels.Unified;
- namespace Muchinfo.MTPClient.Trade.Views
- {
- /// <summary>
- /// EntrustOrderView.xaml 的交互逻辑
- /// </summary>
- public partial class EntrustOrderView : Window
- {
-
- public EntrustOrderView(QuoteGoods goods, Direction direction )
- {
- InitializeComponent();
- this.DataContext = new TradeOrderViewModel(goods, direction);
- InitView();
- DeliveryPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(DeliveryPopupPlacementCallback);
- MessengerHelper.DefaultRegister<bool>(this, MessengerTokens.SetButtonFoucsToken, (result) =>
- {
- btnOKCommand.Focus();
- });
- }
- public EntrustOrderView(OrderBase orderBase,ePriceMode orderPriceMode)
- {
- InitializeComponent();
- this.DataContext = new TradeOrderViewModel(orderBase, orderPriceMode);
- InitView();
- DeliveryPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(DeliveryPopupPlacementCallback);
- MessengerHelper.DefaultRegister<bool>(this, MessengerTokens.SetButtonFoucsToken, (result) =>
- {
- btnOKCommand.Focus();
- });
- }
- private void InitView()
- {
- var viewModel = this.DataContext as TradeOrderViewModel;
- if (!ApplicationParameter.ShowBuyOrSellPrice &&
- viewModel != null &&
- viewModel.OrderModel == OrderModel.Normal)
- {
- var width = MinWidth - 200;
- MinWidth = width;
- Width = width;
- viewModel.ShowOkCancel = false;
- }
- else
- {
- if (viewModel != null &&
- viewModel.OrderModel == OrderModel.SPSL)
- {
- viewModel.ShowOkCancel = true;
- }
-
- }
- }
- public EntrustOrderView(TradeOrderViewModel OrderViewModel)
- {
- InitializeComponent();
- this.DataContext = OrderViewModel;
- InitView();
- DeliveryPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(DeliveryPopupPlacementCallback);
- MessengerHelper.DefaultRegister<bool>(this, MessengerTokens.SetButtonFoucsToken, (result) =>
- {
- btnOKCommand.Focus();
- });
-
- }
- protected override void OnClosed(EventArgs e)
- {
- base.OnClosed(e);
- MessengerHelper.DefaultUnregister<bool>(this, MessengerTokens.SetButtonFoucsToken);
- }
- private void openOrderWindow_Closed(object sender, EventArgs e)
- {
- if(this.DataContext is TradeOrderViewModel)
- {
- (this.DataContext as TradeOrderViewModel).Cleanup();
- }
- }
- private CustomPopupPlacement[] DeliveryPopupPlacementCallback(Size popupSize, Size targetSize, Point offset)
- {
- DeliveryPopup.Height = this.ActualHeight - 20;
- CustomPopupPlacement hPlacement = new CustomPopupPlacement(new Point(this.ActualWidth - 10,10), PopupPrimaryAxis.Horizontal);
- CustomPopupPlacement vPlacement = new CustomPopupPlacement(new Point(-260, 10), PopupPrimaryAxis.Vertical);
- CustomPopupPlacement[] placements = new CustomPopupPlacement[] { hPlacement ,vPlacement};
-
- return placements;
- }
- //private void openOrderWindow_MouseMove(object sender, MouseEventArgs e)
- //{
- // Point p = e.MouseDevice.GetPosition(this);
- // var pp = this.DeliveryPopup.PointToScreen(p);
- // if (pp.Y < this.DeliveryPopup.Height)
- // {
- // this.DeliveryPopup.IsOpen = false;
- // }
- //}
- }
- }
|