/// <summary> /// Создать <see cref="OrdersPanel"/>. /// </summary> public OrdersPanel() { InitializeComponent(); Security prevSecurity = null; Portfolio prevPortfolio = null; var prevType = OrderTypes.Limit; Func <OrderTypes, Order> createOrder = type => new Order { Type = type, Security = prevSecurity, Portfolio = prevPortfolio, }; OrderGrid.OrderRegistering += () => { var wnd = new OrderWindow { SecurityProvider = ConfigManager.GetService <ISecurityProvider>(), MarketDataProvider = ConfigManager.GetService <IMarketDataProvider>(), Order = createOrder(prevType), Portfolios = ConfigManager.GetService <PortfolioDataSource>() }; if (!wnd.ShowModal(this)) { return; } var order = wnd.Order; prevType = order.Type; prevSecurity = order.Security; prevPortfolio = order.Portfolio; new RegisterOrderCommand(order).Process(this); }; OrderGrid.OrderReRegistering += order => { var window = new OrderWindow { Title = LocalizedStrings.Str2976Params.Put(order.TransactionId), Order = order.ReRegisterClone(newVolume: order.Balance), }; if (window.ShowModal(this)) { new ReRegisterOrderCommand(order, window.Order).Process(this); } }; OrderGrid.OrderCanceling += orders => new CancelOrderCommand(orders).Process(this); OrderGrid.SelectionChanged += (s, e) => new SelectCommand <Order>(OrderGrid.SelectedOrder, false).Process(this); OrderGrid.PropertyChanged += (s, e) => new ControlChangedCommand(this).Process(this); GotFocus += (s, e) => new SelectCommand <Order>(OrderGrid.SelectedOrder, false).Process(this); var cmdSvc = ConfigManager.GetService <IStudioCommandService>(); cmdSvc.Register <ResetedCommand>(this, false, cmd => OrderGrid.Orders.Clear()); cmdSvc.Register <OrderCommand>(this, false, cmd => { if (cmd.Action == OrderActions.Registering && cmd.Order.Type != OrderTypes.Conditional) { OrderGrid.Orders.Add(cmd.Order); } }); cmdSvc.Register <ReRegisterOrderCommand>(this, false, cmd => OrderGrid.Orders.Add(cmd.NewOrder)); cmdSvc.Register <OrderFailCommand>(this, false, cmd => { if (cmd.Action == OrderActions.Registering) { OrderGrid.AddRegistrationFail(cmd.Fail); } }); cmdSvc.Register <BindStrategyCommand>(this, false, cmd => { prevSecurity = cmd.Source.Security; prevPortfolio = cmd.Source.Portfolio; }); WhenLoaded(() => new RequestBindSource(this).SyncProcess(this)); }
private void OnStrategyOrderRegisterFailed(OrderFail fail) { OrderGrid.AddRegistrationFail(fail); }