private void VmOnDataChanged()
 {
     if (!_updatingUI)
     {
         ViewModel.SaveBoard(ExchangeEditor.GetSelectedExchange());
     }
 }
        private void BoardSelector_OnSelectionChanged(object sender, EventArgs e)
        {
            var cb = (ComboBox)sender;

            if (cb.IsDropDownOpen || ViewModel == null || _updatingUI)
            {
                return;
            }

            if (cb.SelectedItem != null)
            {
                var curText = cb.SelectedValue as string;
                if (!curText.IsEmpty())
                {
                    SetBoardCode(curText);
                }
            }
            else
            {
                var curText = cb.Text.Trim();
                if (curText.IsEmpty())
                {
                    return;
                }

                ExchangeEditor.SetExchange(null);
                SetBoardCode(curText);
            }
        }
        public ExchangeEditorViewModel(ExchangeEditor editor, IExchangeInfoProvider provider)
        {
            if (editor == null)
            {
                throw new ArgumentNullException(nameof(editor));
            }

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            _editor  = editor;
            Provider = provider;
            _isNew   = true;
        }
        private void ResetBoardEditor()
        {
            _updatingUI = true;

            try
            {
                ViewModel.SetBoard(null);
                SetSaveError(null);
                CbBoardCode.Text = string.Empty;
                ExchangeEditor.SetExchange(null);
            }
            finally
            {
                _updatingUI = false;
            }
        }
        /// <summary>
        /// To set the board for editing.
        /// </summary>
        /// <param name="boardCode">The editing board code. The board for editing is loaded by the code from EntityRegistry.</param>
        public void SetBoardCode(string boardCode)
        {
            _updatingUI = true;

            try
            {
                if (boardCode.IsEmpty())
                {
                    ResetBoardEditor();
                    ExchangeEditor.SetExchange(null);
                    return;
                }

                ViewModel.SetBoard(boardCode);
                CbBoardCode.SelectedItem = Boards.FirstOrDefault(b => b.Code == ViewModel.BoardCode);
                ExchangeEditor.SetExchange(ViewModel.Board == null ? null : ViewModel.Board.Exchange.Name);
            }
            finally
            {
                _updatingUI = false;
            }
        }
 private void ButtonClear_Click(object sender, RoutedEventArgs e)
 {
     ResetBoardEditor();
     ExchangeEditor.SetExchange(null);
 }