public InstrumentSourceRelationWindow(VmInstrument vmInstrument, EditMode editMode, VmInstrumentSourceRelation vmRelation = null)
        {
            InitializeComponent();
            this._EditMode = editMode;
            this._vmInstrument = vmInstrument;
            this._originRelation = vmRelation;

            if (editMode == EditMode.AddNew)
            {
                this._Relation = new InstrumentSourceRelation() { InstrumentId = this._vmInstrument.Id, SwitchTimeout = 60, Priority = 30 };
                this._Relation.IsActive = vmInstrument.SourceRelations.Count == 0;  // Only for UI display(the backend can process normally)
                this._Relation.IsDefault = false;
                this.IsDefaultCheckBox.IsEnabled = false;
            }
            else
            {
                this._Relation = vmRelation.InstrumentSourceRelation.Clone();
                this.SourcesComboBox.IsEnabled = false;
            }
            InstrumentCodeTextBlock.Text = vmInstrument.Code;
            this.BindSourcesComboBox();
            this.DataContext = this._Relation;

            this._HintMessage = new HintMessage(this.HintTextBlock);
            this.Loaded += InstrumentSourceRelationWindow_Loaded;
        }
        public DerivedInstrumentWindow(EditMode editMode, VmInstrument vmInstrument = null)
        {
            InitializeComponent();
            this._EditMode = editMode;
            this._vmInstrument = vmInstrument;
            this._InstrumentData = new InstrumentData();
            if (editMode == EditMode.AddNew)
            {
                this._InstrumentData.Instrument = new Instrument() { IsDerivative = true };
                this._InstrumentData.DerivativeRelation = new DerivativeRelation()
                {
                    AskOperand1Type = OperandType.Ask,
                    AskOperand2Type = OperandType.Ask,
                    AskOperator1Type = OperatorType.Multiply,
                    AskOperator2Type = OperatorType.Multiply,
                    AskOperand3 = 1,
                    BidOperand1Type = OperandType.Bid,
                    BidOperand2Type = OperandType.Bid,
                    BidOperator1Type = OperatorType.Multiply,
                    BidOperator2Type = OperatorType.Multiply,
                    BidOperand3 = 1,
                    LastOperand1Type = OperandType.Last,
                    LastOperand2Type = OperandType.Last,
                    LastOperator1Type = OperatorType.Multiply,
                    LastOperator2Type = OperatorType.Multiply,
                    LastOperand3 = 1,
                    UnderlyingInstrument1IdInverted = false,
                    UnderlyingInstrument2Id = null
                };
                if(VmQuotationManager.Instance.Instruments.Count>0)
                {
                    this._InstrumentData.DerivativeRelation.UnderlyingInstrument1Id = VmQuotationManager.Instance.Instruments[0].Id;
                }
            }
            else
            {
                this._InstrumentData.Instrument = vmInstrument.Instrument.Clone();
                this._InstrumentData.DerivativeRelation = vmInstrument.VmDerivativeRelation.DerivativeRelation.Clone();
            }

            this.DataContext = this._InstrumentData;
            this._HintMessage = new HintMessage(this.HintTextBlock);
        }
        public InstrumentWindow(EditMode editMode, VmInstrument vmInstrument =  null)
        {
            InitializeComponent();
            this._EditMode = editMode;
            this._vmInstrument = vmInstrument;
            this._InstrumentData = new InstrumentData();
            if (editMode == EditMode.AddNew)
            {
                this._InstrumentData.Instrument = new Instrument() { IsDerivative = false, IsSwitchUseAgio = false, UseWeightedPrice = false };
                this._InstrumentData.PriceRangeCheckRule = new PriceRangeCheckRule();
                this._InstrumentData.WeightedPriceRule = new WeightedPriceRule();
            }
            else
            {
                this._InstrumentData.Instrument = vmInstrument.Instrument.Clone();
                this._InstrumentData.PriceRangeCheckRule = vmInstrument.VmPriceRangeCheckRule.PriceRangeCheckRule.Clone();
                this._InstrumentData.WeightedPriceRule = vmInstrument.VmWeightedPriceRule.WeightedPriceRule.Clone();
            }

            this.DataContext = this._InstrumentData;
            this._HintMessage = new HintMessage(this.HintTextBlock);
        }
 public LoginWindow(Action<LoginResult> loginSuccssAction)
 {
     InitializeComponent();
     this._LoginSuccssAction = loginSuccssAction;
     this._HintMessage = new HintMessage(this.HintMessageTextBlock);
 }