/// <summary>
        /// Initializes the specified view configurator.
        /// </summary>
        /// <param name="viewConfigurator">The view configurator.</param>
        /// <param name="parentViewModel">The parent view model.</param>
        public void Init(IProcessViewConfigurator viewConfigurator, ProcessViewsViewModel parentViewModel)
        {
            _viewConfigurator = (DataCollectProcessViewConfigurator) viewConfigurator;
            RaisePropertyChanged(() => ViewConfigurator);

            _parentViewModel = parentViewModel;
            RaisePropertyChanged(() => Parent);

            AvailableFields = new ObservableCollection<IDisplayFieldViewModel>();

            SelectedDisplayFields.Clear();
            foreach (var df in _viewConfigurator.ExistingRecordFields)
            {
                var vm = new SelectedFieldViewModel();
                vm.Initialize(df, this);
                SelectedDisplayFields.Add(vm);

                var node = FindNode(df.FullPath);
                if (node != null)
                {
                    node.IsSelected = false;
                }
            }

            UpdateCanMoveFields();

            SetupProcessFields();
            LoadFilters();

            SetEventListener();
        }
        public void MoveDisplayFieldDown(SelectedFieldViewModel field)
        {
            var orderedFields = SelectedDisplayFields.OrderBy(f => f.Order).ToArray();
            var index = Array.IndexOf(orderedFields, field);

            if (index < 0)
                return;

            if (index < orderedFields.Length - 1)
            {
                if (index < orderedFields.Length - 2)
                {
                    field.Model.Order = (orderedFields[index + 1].Order + orderedFields[index + 2].Order) / 2.0;
                }
                else
                {
                    field.Model.Order = orderedFields[index + 1].Order + 1.0;
                }
            }

            UpdateCanMoveFields();

            _viewConfigurator.RaiseConfigurationChanged();

            OrderedSelectedFields.View.Refresh();
        }
        public void SelectDisplayField(IDisplayFieldViewModel fieldViewModel)
        {
            var path = fieldViewModel.FullSystemPath;

            if (ContainsSelectedField(path))
            {
                return;
            }

            var maxOrder = 0.0;

            if (this.ViewConfigurator.ExistingRecordFields.Any())
            {
                maxOrder = this.ViewConfigurator.ExistingRecordFields.Max(x => x.Order);
            }

            var newField = new DisplayField(fieldViewModel.FullPath, fieldViewModel.FullSystemPath, maxOrder + 1.0, fieldViewModel.Model.IsBuiltIn);
            this.ViewConfigurator.ExistingRecordFields.Add(newField);

            var vm = new SelectedFieldViewModel();
            vm.Initialize(newField, this);
            this.SelectedDisplayFields.Add(vm);

            this.UpdateCanMoveFields();
        }
        public void MoveDisplayFieldUp(SelectedFieldViewModel field)
        {
            var orderedFields = SelectedDisplayFields.OrderBy(f => f.Order).ToArray();
            var index = Array.IndexOf(orderedFields, field);

            if (index <= 0)
                return;

            var order = orderedFields[index - 1].Order;

            if (index - 2 >= 0)
                order += orderedFields[index - 2].Order;

            field.Model.Order = order / 2.0;

            UpdateCanMoveFields();

            _viewConfigurator.RaiseConfigurationChanged();

            OrderedSelectedFields.View.Refresh();
        }
 /// <summary>
 /// Moves the display field down.
 /// </summary>
 /// <param name="selectedFieldViewModel">The selected field view model.</param>
 public void MoveDisplayFieldDown(SelectedFieldViewModel selectedFieldViewModel)
 {
 }