コード例 #1
0
        private void ShowStyleProperties(IntellectualEntityStyle style)
        {
            var topGrid = new Grid();

            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            topGrid.RowDefinitions.Add(new RowDefinition());

            #region Set main data

            var headerName = new TextBlock
            {
                Margin = (Thickness)FindResource("ModPlusDefaultMargin"),
                Text   = ModPlusAPI.Language.GetItem(Invariables.LangItem, "h54")
            };
            Grid.SetRow(headerName, 0);
            topGrid.Children.Add(headerName);

            var tbName = new TextBox {
                IsEnabled = style.StyleType == StyleType.User
            };
            Grid.SetRow(tbName, 1);
            var binding = new Binding
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Source = style,
                Path   = new PropertyPath("Name")
            };
            BindingOperations.SetBinding(tbName, TextBox.TextProperty, binding);
            topGrid.Children.Add(tbName);

            var headerDescription = new TextBlock
            {
                Margin = (Thickness)FindResource("ModPlusDefaultMargin"),
                Text   = ModPlusAPI.Language.GetItem(Invariables.LangItem, "h55")
            };
            Grid.SetRow(headerDescription, 2);
            topGrid.Children.Add(headerDescription);

            var tbDescription = new TextBox {
                IsEnabled = style.StyleType == StyleType.User
            };
            Grid.SetRow(tbDescription, 3);
            binding = new Binding
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Source = style,
                Path   = new PropertyPath("Description")
            };
            BindingOperations.SetBinding(tbDescription, TextBox.TextProperty, binding);
            topGrid.Children.Add(tbDescription);

            #endregion

            var propertiesGrid = new Grid();
            propertiesGrid.ColumnDefinitions.Add(new ColumnDefinition());
            propertiesGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            propertiesGrid.ColumnDefinitions.Add(new ColumnDefinition());
            Grid.SetRow(propertiesGrid, 4);

            var groupsByCategory = style.Properties.GroupBy(p => p.Category).ToList();
            groupsByCategory.Sort((g1, g2) => g1.Key.CompareTo(g2.Key));
            var rowIndex = 0;
            foreach (var categoryGroup in groupsByCategory)
            {
                propertiesGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                var categoryHeader = new TextBox {
                    Text = LocalizationUtils.GetCategoryLocalizationName(categoryGroup.Key)
                };
                Grid.SetRow(categoryHeader, rowIndex);
                Grid.SetColumn(categoryHeader, 0);
                Grid.SetColumnSpan(categoryHeader, 3);
                categoryHeader.Style = Resources["HeaderTextBoxForStyleEditor"] as Style;
                propertiesGrid.Children.Add(categoryHeader);
                rowIndex++;
                var gridSplitterStartIndex = rowIndex;
                foreach (var property in categoryGroup.OrderBy(p => p.OrderIndex))
                {
                    propertiesGrid.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });

                    // property name
                    var propertyDescription = GetPropertyDescription(property);
                    var propertyHeader      = new TextBox
                    {
                        Text  = GetPropertyDisplayName(property),
                        Style = Resources["PropertyHeaderInStyleEditor"] as Style
                    };
                    SetDescription(propertyHeader, propertyDescription);
                    Grid.SetColumn(propertyHeader, 0);
                    Grid.SetRow(propertyHeader, rowIndex);
                    propertiesGrid.Children.Add(propertyHeader);

                    if (property.Name == "LayerName")
                    {
                        try
                        {
                            var cb = new ComboBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(cb, 2);
                            Grid.SetRow(cb, rowIndex);
                            var layers = AcadUtils.Layers;
                            layers.Insert(0, ModPlusAPI.Language.GetItem(Invariables.LangItem, "defl")); // "По умолчанию"
                            if (!layers.Contains(style.GetLayerNameProperty()))
                            {
                                layers.Insert(1, style.GetLayerNameProperty());
                            }

                            cb.ItemsSource = layers;
                            cb.Style       = Resources["PropertyValueComboBoxForStyleEditor"] as Style;
                            SetDescription(cb, propertyDescription);
                            BindingOperations.SetBinding(cb, Selector.SelectedItemProperty, CreateTwoWayBindingForProperty(property));
                            propertiesGrid.Children.Add(cb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Name == "Scale")
                    {
                        try
                        {
                            var cb = new ComboBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(cb, 2);
                            Grid.SetRow(cb, rowIndex);
                            cb.ItemsSource = AcadUtils.Scales;
                            cb.Style       = Resources["PropertyValueComboBoxForStyleEditor"] as Style;
                            SetDescription(cb, propertyDescription);
                            BindingOperations.SetBinding(cb, ComboBox.TextProperty, CreateTwoWayBindingForProperty(property, new AnnotationScaleValueConverter()));
                            propertiesGrid.Children.Add(cb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Name == "LineType")
                    {
                        try
                        {
                            var tb = new TextBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(tb, 2);
                            Grid.SetRow(tb, rowIndex);
                            tb.Cursor            = Cursors.Hand;
                            tb.Style             = Resources["PropertyValueTextBoxForStyleEditor"] as Style;
                            tb.PreviewMouseDown += LineType_OnPreviewMouseDown;
                            SetDescription(tb, propertyDescription);
                            BindingOperations.SetBinding(tb, TextBox.TextProperty, CreateTwoWayBindingForProperty(property));
                            propertiesGrid.Children.Add(tb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Name.Contains("TextStyle"))
                    {
                        try
                        {
                            var cb = new ComboBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(cb, 2);
                            Grid.SetRow(cb, rowIndex);
                            cb.ItemsSource = AcadUtils.TextStyles;
                            cb.Style       = Resources["PropertyValueComboBoxForStyleEditor"] as Style;
                            SetDescription(cb, propertyDescription);
                            BindingOperations.SetBinding(cb, Selector.SelectedItemProperty, CreateTwoWayBindingForProperty(property));
                            propertiesGrid.Children.Add(cb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Value is Enum)
                    {
                        try
                        {
                            var cb = new ComboBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(cb, 2);
                            Grid.SetRow(cb, rowIndex);
                            cb.Style = Resources["PropertyValueComboBoxForStyleEditor"] as Style;
                            var type = property.Value.GetType();
                            SetDescription(cb, propertyDescription);
                            cb.ItemsSource = LocalizationUtils.GetEnumPropertyLocalizationFields(type);

                            BindingOperations.SetBinding(cb, ComboBox.TextProperty,
                                                         CreateTwoWayBindingForProperty(property, new EnumPropertyValueConverter()));

                            propertiesGrid.Children.Add(cb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Value is int)
                    {
                        try
                        {
                            var tb = new NumericBox
                            {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(tb, 2);
                            Grid.SetRow(tb, rowIndex);
                            tb.Minimum = Convert.ToInt32(property.Minimum);
                            tb.Maximum = Convert.ToInt32(property.Maximum);
                            tb.Style   = Resources["PropertyValueIntTextBoxForStyleEditor"] as Style;
                            SetDescription(tb, propertyDescription);
                            BindingOperations.SetBinding(tb, NumericBox.ValueProperty, CreateTwoWayBindingForPropertyForNumericValue(property, true));
                            propertiesGrid.Children.Add(tb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Value is double)
                    {
                        try
                        {
                            var tb = new NumericBox
                            {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(tb, 2);
                            Grid.SetRow(tb, rowIndex);
                            tb.Minimum = Convert.ToDouble(property.Minimum);
                            tb.Maximum = Convert.ToDouble(property.Maximum);
                            tb.Style   = Resources["PropertyValueDoubleTextBoxForStyleEditor"] as Style;
                            SetDescription(tb, propertyDescription);
                            BindingOperations.SetBinding(tb, NumericBox.ValueProperty, CreateTwoWayBindingForPropertyForNumericValue(property, false));

                            propertiesGrid.Children.Add(tb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Value is bool)
                    {
                        try
                        {
                            var chb = new CheckBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            SetDescription(chb, propertyDescription);
                            BindingOperations.SetBinding(chb, ToggleButton.IsCheckedProperty, CreateTwoWayBindingForProperty(property));

                            var outerBorder = new Border();
                            outerBorder.Style = Resources["PropertyBorderForCheckBoxForStyleEditor"] as Style;
                            Grid.SetColumn(outerBorder, 2);
                            Grid.SetRow(outerBorder, rowIndex);

                            outerBorder.Child = chb;
                            propertiesGrid.Children.Add(outerBorder);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }
                    else if (property.Value is string)
                    {
                        try
                        {
                            var tb = new TextBox {
                                IsEnabled = style.StyleType == StyleType.User
                            };
                            Grid.SetColumn(tb, 2);
                            Grid.SetRow(tb, rowIndex);
                            tb.Style = Resources["PropertyValueTextBoxForStyleEditor"] as Style;
                            SetDescription(tb, propertyDescription);
                            BindingOperations.SetBinding(tb, TextBox.TextProperty, CreateTwoWayBindingForProperty(property));

                            propertiesGrid.Children.Add(tb);
                        }
                        catch (Exception exception)
                        {
                            ExceptionBox.Show(exception);
                        }
                    }

                    rowIndex++;
                }

                propertiesGrid.Children.Add(CreateGridSplitter(gridSplitterStartIndex, rowIndex - gridSplitterStartIndex));
            }

            topGrid.Children.Add(propertiesGrid);
            BorderProperties.Child = topGrid;
        }
コード例 #2
0
        /// <summary>
        /// Построение элементов в палитре по данным коллекции свойств
        /// </summary>
        /// <param name="collection"><see cref="SummaryPropertyCollection"/></param>
        public void SetData(SummaryPropertyCollection collection)
        {
            var different = $"*{ModPlusAPI.Language.GetItem("vc1")}*";

            var entityGroups = collection.Where(sp => sp.EntityPropertyDataCollection.Any())
                               .GroupBy(sp => sp.EntityType);

            foreach (var entityGroup in entityGroups)
            {
                // Тип примитива может содержать атрибуты указывающие зависимость видимости свойств
                // Собираю их в список для последующей работы
                var visibilityDependencyAttributes = GetVisibilityDependencyAttributes(entityGroup.Key);
                var allEntitySummaryProperties     = entityGroup.Select(g => g).ToList();

                var c = entityGroup.SelectMany(sp => sp.EntityPropertyDataCollection).Select(p => p.OwnerObjectId).Distinct().Count();
                var entityExpander = new Expander
                {
                    IsExpanded = true,
                    Header     = $"{LocalizationUtils.GetEntityLocalizationName(entityGroup.Key)} [{c}]",
                    Style      = Resources["EntityExpander"] as Style
                };

                var mainGrid = new Grid
                {
                    Visibility = Visibility.Collapsed,
                    Opacity    = 0.0
                };
                Transitions.SetOpacity(mainGrid, new OpacityParams
                {
                    From         = 0.0,
                    To           = 1.0,
                    Duration     = 300,
                    TransitionOn = TransitionOn.Visibility
                });
                var categoryIndex           = 0;
                var summaryPropertiesGroups = entityGroup.GroupBy(sp => sp.Category).ToList();
                summaryPropertiesGroups.Sort((sp1, sp2) => sp1.Key.CompareTo(sp2.Key));

                foreach (var summaryPropertiesGroup in summaryPropertiesGroups)
                {
                    mainGrid.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });

                    var grid = new Grid();
                    Grid.SetRow(grid, categoryIndex);

                    var headerRowDefinition = new RowDefinition {
                        Height = GridLength.Auto
                    };
                    var firstColumn = new ColumnDefinition {
                        MinWidth = 50
                    };
                    BindingOperations.SetBinding(firstColumn, ColumnDefinition.WidthProperty, CreateBindingForColumnWidth());
                    var secondColumn = new ColumnDefinition {
                        Width = GridLength.Auto
                    };
                    var thirdColumn = new ColumnDefinition {
                        MinWidth = 50
                    };
                    grid.RowDefinitions.Add(headerRowDefinition);
                    grid.ColumnDefinitions.Add(firstColumn);
                    grid.ColumnDefinitions.Add(secondColumn);
                    grid.ColumnDefinitions.Add(thirdColumn);

                    var categoryHeader = new TextBox
                    {
                        Text = LocalizationUtils.GetCategoryLocalizationName(summaryPropertiesGroup.Key)
                    };
                    Grid.SetRow(categoryHeader, 0);
                    Grid.SetColumn(categoryHeader, 0);
                    Grid.SetColumnSpan(categoryHeader, 3);
                    categoryHeader.Style = Resources["HeaderTextBox"] as Style;
                    grid.Children.Add(categoryHeader);

                    // sort
                    var j = 1;
                    foreach (var summaryProperty in summaryPropertiesGroup.OrderBy(sp => sp.OrderIndex))
                    {
                        if (summaryProperty.PropertyScope == PropertyScope.Hidden)
                        {
                            continue;
                        }

                        var rowDefinition = new RowDefinition {
                            Height = GridLength.Auto
                        };
                        grid.RowDefinitions.Add(rowDefinition);

                        // property name
                        var propertyDescription = GetPropertyDescription(summaryProperty);
                        var propertyHeader      = new TextBox
                        {
                            Text  = GetPropertyDisplayName(summaryProperty),
                            Style = Resources["PropertyNameTextBox"] as Style
                        };
                        SetDescription(propertyHeader, propertyDescription);
                        SetVisibilityDependency(visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, propertyHeader);
                        Grid.SetColumn(propertyHeader, 0);
                        Grid.SetRow(propertyHeader, j);
                        grid.Children.Add(propertyHeader);

                        var entityProperty = summaryProperty.EntityPropertyDataCollection.FirstOrDefault();

                        if (entityProperty != null)
                        {
                            if (summaryProperty.PropertyName == "Style")
                            {
                                try
                                {
                                    var cb = new ComboBox();
                                    Grid.SetColumn(cb, 2);
                                    Grid.SetRow(cb, j);
                                    cb.ItemsSource = StyleManager.GetStyles(entityProperty.EntityType).Select(s => s.Name);
                                    cb.Style       = Resources["PropertyValueComboBox"] as Style;
                                    SetDescription(cb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, cb);
                                    SetForegroundBinding(cb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        cb, ComboBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    grid.Children.Add(cb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (summaryProperty.PropertyName == "LayerName")
                            {
                                try
                                {
                                    var cb = new ComboBox();
                                    Grid.SetColumn(cb, 2);
                                    Grid.SetRow(cb, j);
                                    cb.ItemsSource = AcadUtils.Layers;
                                    cb.Style       = Resources["PropertyValueComboBox"] as Style;
                                    SetDescription(cb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, cb);
                                    SetForegroundBinding(cb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        cb, ComboBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    grid.Children.Add(cb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (summaryProperty.PropertyName == "Scale")
                            {
                                try
                                {
                                    var cb = new ComboBox();
                                    Grid.SetColumn(cb, 2);
                                    Grid.SetRow(cb, j);
                                    cb.ItemsSource = AcadUtils.Scales;
                                    cb.Style       = Resources["PropertyValueComboBox"] as Style;
                                    SetDescription(cb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, cb);
                                    SetForegroundBinding(cb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        cb, ComboBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    grid.Children.Add(cb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (summaryProperty.PropertyName == "LineType")
                            {
                                try
                                {
                                    var tb = new TextBox();
                                    Grid.SetColumn(tb, 2);
                                    Grid.SetRow(tb, j);
                                    tb.Style             = Resources["PropertyValueTextBoxClickable"] as Style;
                                    tb.PreviewMouseDown += LineType_OnPreviewMouseDown;
                                    SetDescription(tb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, tb);
                                    SetForegroundBinding(tb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        tb, TextBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    grid.Children.Add(tb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (summaryProperty.PropertyName.Contains("TextStyle"))
                            {
                                try
                                {
                                    var cb = new ComboBox();
                                    Grid.SetColumn(cb, 2);
                                    Grid.SetRow(cb, j);
                                    cb.ItemsSource = AcadUtils.TextStyles;
                                    cb.Style       = Resources["PropertyValueComboBox"] as Style;
                                    SetDescription(cb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, cb);
                                    SetForegroundBinding(cb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        cb, ComboBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    grid.Children.Add(cb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (entityProperty.Value is Enum)
                            {
                                try
                                {
                                    var cb = new ComboBox();
                                    Grid.SetColumn(cb, 2);
                                    Grid.SetRow(cb, j);
                                    cb.Style = Resources["PropertyValueComboBox"] as Style;
                                    var type = entityProperty.Value.GetType();
                                    SetDescription(cb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, cb);
                                    cb.ItemsSource = LocalizationUtils.GetEnumPropertyLocalizationFields(type);
                                    cb.IsEnabled   = !entityProperty.IsReadOnly;
                                    SetForegroundBinding(cb, summaryProperty);

                                    BindingOperations.SetBinding(cb, ComboBox.TextProperty,
                                                                 CreateTwoWayBindingForProperty(summaryProperty, new EnumPropertyValueConverter()));

                                    grid.Children.Add(cb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (entityProperty.Value is int)
                            {
                                try
                                {
                                    if (entityProperty.IsReadOnly)
                                    {
                                        var tb = new TextBox
                                        {
                                            Style = Resources["PropertyValueReadOnlyTextBox"] as Style
                                        };
                                        Grid.SetColumn(tb, 2);
                                        Grid.SetRow(tb, j);

                                        SetDescription(tb, propertyDescription);
                                        SetVisibilityDependency(visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, tb);
                                        tb.Text = summaryProperty.IntValue.HasValue
                                            ? summaryProperty.IntValue.ToString()
                                            : different;

                                        grid.Children.Add(tb);
                                    }
                                    else
                                    {
                                        var numericBox = new NumericBox();
                                        Grid.SetColumn(numericBox, 2);
                                        Grid.SetRow(numericBox, j);
                                        numericBox.Minimum = summaryProperty.EntityPropertyDataCollection
                                                             .Select(p => Convert.ToInt32(p.Minimum)).Max();
                                        numericBox.Maximum = summaryProperty.EntityPropertyDataCollection
                                                             .Select(p => Convert.ToInt32(p.Maximum)).Min();
                                        numericBox.Interval         = 1.0;
                                        numericBox.NumericInputMode = NumericInput.Numbers;
                                        numericBox.Style            = Resources["PropertyValueNumericTextBox"] as Style;
                                        HintAssist.SetHint(numericBox, different);
                                        SetDescription(numericBox, propertyDescription);
                                        SetVisibilityDependency(
                                            visibilityDependencyAttributes,
                                            allEntitySummaryProperties,
                                            summaryProperty.PropertyName,
                                            numericBox);

                                        BindingOperations.SetBinding(
                                            numericBox,
                                            NumericBox.ValueProperty,
                                            CreateTwoWayBindingForPropertyForNumericValue(summaryProperty, true));

                                        grid.Children.Add(numericBox);
                                    }
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (entityProperty.Value is double)
                            {
                                try
                                {
                                    if (entityProperty.IsReadOnly)
                                    {
                                        var tb = new TextBox
                                        {
                                            Style = Resources["PropertyValueReadOnlyTextBox"] as Style
                                        };
                                        Grid.SetColumn(tb, 2);
                                        Grid.SetRow(tb, j);
                                        SetDescription(tb, propertyDescription);
                                        SetVisibilityDependency(
                                            visibilityDependencyAttributes,
                                            allEntitySummaryProperties,
                                            summaryProperty.PropertyName,
                                            tb);
                                        tb.Text = summaryProperty.DoubleValue.HasValue
                                            ? summaryProperty.DoubleValue.ToString()
                                            : different;

                                        grid.Children.Add(tb);
                                    }
                                    else
                                    {
                                        var numericBox = new NumericBox();
                                        Grid.SetColumn(numericBox, 2);
                                        Grid.SetRow(numericBox, j);
                                        numericBox.Minimum = summaryProperty.EntityPropertyDataCollection
                                                             .Select(p => Convert.ToDouble(p.Minimum)).Max();
                                        numericBox.Maximum = summaryProperty.EntityPropertyDataCollection
                                                             .Select(p => Convert.ToDouble(p.Maximum)).Min();
                                        numericBox.NumericInputMode = NumericInput.Decimal;
                                        numericBox.Speedup          = true;
                                        numericBox.Interval         = 0.1;
                                        numericBox.Style            = Resources["PropertyValueNumericTextBox"] as Style;
                                        HintAssist.SetHint(numericBox, different);
                                        SetDescription(numericBox, propertyDescription);
                                        SetVisibilityDependency(
                                            visibilityDependencyAttributes,
                                            allEntitySummaryProperties,
                                            summaryProperty.PropertyName,
                                            numericBox);
                                        BindingOperations.SetBinding(
                                            numericBox,
                                            NumericBox.ValueProperty,
                                            CreateTwoWayBindingForPropertyForNumericValue(summaryProperty, false));

                                        grid.Children.Add(numericBox);
                                    }
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (entityProperty.Value is bool)
                            {
                                try
                                {
                                    var chb = new CheckBox
                                    {
                                        Style = Resources["PropertyValueCheckBox"] as Style
                                    };
                                    SetDescription(chb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes,
                                        allEntitySummaryProperties,
                                        summaryProperty.PropertyName,
                                        chb);
                                    chb.IsEnabled = !entityProperty.IsReadOnly;
                                    BindingOperations.SetBinding(
                                        chb,
                                        ToggleButton.IsCheckedProperty,
                                        CreateTwoWayBindingForProperty(summaryProperty));

                                    var outerBorder = new Border
                                    {
                                        Style = Resources["BorderForValueCheckBox"] as Style
                                    };
                                    Grid.SetColumn(outerBorder, 2);
                                    Grid.SetRow(outerBorder, j);

                                    outerBorder.Child = chb;
                                    grid.Children.Add(outerBorder);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }
                            else if (entityProperty.Value is string)
                            {
                                try
                                {
                                    var tb = new TextBox();
                                    Grid.SetColumn(tb, 2);
                                    Grid.SetRow(tb, j);
                                    tb.Style = Resources["PropertyValueTextBox"] as Style;
                                    SetDescription(tb, propertyDescription);
                                    SetVisibilityDependency(
                                        visibilityDependencyAttributes, allEntitySummaryProperties, summaryProperty.PropertyName, tb);
                                    SetForegroundBinding(tb, summaryProperty);
                                    BindingOperations.SetBinding(
                                        tb, TextBox.TextProperty, CreateTwoWayBindingForProperty(summaryProperty));
                                    tb.IsReadOnly = entityProperty.IsReadOnly;

                                    grid.Children.Add(tb);
                                }
                                catch (Exception exception)
                                {
                                    ExceptionBox.Show(exception);
                                }
                            }

                            j++;
                        }
                    }

                    grid.Children.Add(CreateGridSplitter(j));

                    mainGrid.Children.Add(grid);

                    categoryIndex++;
                }

                entityExpander.Content = mainGrid;

                StackPanelProperties.Children.Add(entityExpander);

                mainGrid.Visibility = Visibility.Visible;
            }
        }