| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Interop;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using Muchinfo.MTPClient.Account.ViewModels;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Resources;
- namespace Muchinfo.MTPClient.Account.Views
- {
- /// <summary>
- /// TradeParamSetView.xaml 的交互逻辑
- /// </summary>
- public partial class TradeParamSetView : Window
- {
- private TradeParamsSetViewModel viewModel = null;
- public TradeParamSetView()
- {
- InitializeComponent();
- this.DataContext = new TradeParamsSetViewModel();
- }
- /// <summary>
- /// 在这个方法执行的时候,可以获取到Style中元素的对象,这样我就可以给TradeTabControl注册时间
- /// </summary>
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- TabControl tabControl = GetTemplateChild("TradeTabControl") as TabControl;
- if (tabControl != null)
- {
- tabControl.SelectionChanged += tabControl_SelectionChanged;
- }
-
- }
- /// <summary>
- /// tabControl 的选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- InitViewModel();
- TabItem item = e.AddedItems[0] as TabItem;
- if (item != null && item.IsSelected && viewModel != null)
- {
- if (Client_Resource.TradeParamerSet_Title.Equals(item.Header))// 交易参数设置
- {
- viewModel.SettingTadIndex = SettingTadIndex.TRADE_SETTING;
- }
- else if (Client_Resource.Auto_Entrust_Profit_Loss.Equals(item.Header)) // 自动止盈止损
- {
- viewModel.SettingTadIndex = SettingTadIndex.TRADE_AUTO_ENTRUST;
- }
- }
- }
- private void InitViewModel()
- {
- if (viewModel == null)
- {
- viewModel = this.DataContext as TradeParamsSetViewModel;
- }
- }
- private void TextBoxBase_SP_OnTextChanged(object sender, TextChangedEventArgs e)
- {
- InitViewModel();
- int i = 0;
- if (int.TryParse((((TextBox)sender).Text), out i))
- {
- viewModel.SP_TextChanged.Execute(i);
- }
- }
- private void TextBoxBase_SL_OnTextChanged(object sender, TextChangedEventArgs e)
- {
- InitViewModel();
- int i = 0;
- if (int.TryParse((((TextBox)sender).Text), out i))
- {
- viewModel.SL_TextChanged.Execute(i);
- }
- }
- }
- }
|