Exemple #1
0
        private static DataGridColumn CreateColumn([NotNull] SolutionConfiguration solutionConfiguration)
        {
            Contract.Requires(solutionConfiguration != null);
            Contract.Ensures(Contract.Result <DataGridColumn>() != null);

            var path    = @"ShouldBuild[" + solutionConfiguration.UniqueName + @"]";
            var binding = new Binding(path)
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.TwoWay
            };

            var visualTree = new FrameworkElementFactory(typeof(CheckBox));

            // ReSharper disable AssignNullToNotNullAttribute
            visualTree.SetValue(ToggleButton.IsThreeStateProperty, true);
            visualTree.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
            visualTree.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            visualTree.SetBinding(ToggleButton.IsCheckedProperty, binding);
            // ReSharper restore AssignNullToNotNullAttribute

            var column = new DataGridTemplateColumn
            {
                IsReadOnly     = true,
                SortMemberPath = path,
                CanUserResize  = false,
                Header         = new TextBlock
                {
                    Text            = solutionConfiguration.UniqueName,
                    LayoutTransform = new RotateTransform(-90),
                },
                CellTemplate = new DataTemplate(typeof(ProjectConfiguration))
                {
                    VisualTree = visualTree
                }
            };

            column.SetIsFilterVisible(false);
            column.SetValue(_solutionConfigurationProperty, solutionConfiguration);

            return(column);
        }
        private static DataGridColumn CreateColumn(KeyValuePair <string, string> item)
        {
            Contract.Ensures(Contract.Result <DataGridColumn>() != null);

            var path    = @"IsProjectTypeGuidSelected[" + item.Key + @"]";
            var binding = new Binding(path)
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.TwoWay
            };

            var visualTree = new FrameworkElementFactory(typeof(CheckBox));

            visualTree.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
            visualTree.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            visualTree.SetBinding(ToggleButton.IsCheckedProperty, binding);

            var column = new DataGridTemplateColumn
            {
                IsReadOnly     = true,
                SortMemberPath = path,
                CanUserResize  = false,
                Header         = new TextBlock
                {
                    Text            = item.Value,
                    LayoutTransform = new RotateTransform(-90),
                },
                CellTemplate = new DataTemplate(typeof(ProjectConfiguration))
                {
                    VisualTree = visualTree
                }
            };

            column.SetIsFilterVisible(false);

            return(column);
        }
Exemple #3
0
        private DataGridColumn CreateColumn([NotNull] string weaver)
        {
            var configurationBindingPath = "Configuration[" + weaver + "]";
            var configurationBinding     = new Binding(configurationBindingPath);

            var contentStyle = new Style(typeof(ContentControl))
            {
                Setters = { new Setter {
                                Property = ContentControl.ContentProperty, Value = configurationBinding
                            } },
                Triggers =
                {
                    new DataTrigger {
                        Binding = configurationBinding, Value = -1, Setters ={ new Setter                                           {
                                          Property = ContentControl.ContentProperty, Value = null
                                      } }
                    },
                    new DataTrigger {
                        Binding = configurationBinding, Value = 0, Setters ={ new Setter                                           {
                                          Property = ContentControl.ContentProperty, Value = "S"
                                      } }
                    },
                }
            };

            // ReSharper disable AssignNullToNotNullAttribute
            var visualTree = new FrameworkElementFactory(typeof(Border));

            visualTree.SetBinding(Border.BackgroundProperty, new Binding(configurationBindingPath)
            {
                Converter = _indexToBrushConverter
            });

            var content = new FrameworkElementFactory(typeof(ContentControl));

            content.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            content.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
            content.SetValue(FrameworkElement.StyleProperty, contentStyle);
            content.SetResourceReference(TextElement.ForegroundProperty, SystemColors.WindowTextBrushKey);
            visualTree.AppendChild(content);
            // ReSharper restore AssignNullToNotNullAttribute

            var header = new TextBlock
            {
                Text            = weaver,
                LayoutTransform = new RotateTransform(-90),
                Margin          = new Thickness(2)
            };

            TextOptions.SetTextRenderingMode(header, TextRenderingMode.Grayscale);

            var column = new DataGridTemplateColumn
            {
                Header         = header,
                CanUserResize  = false,
                SortMemberPath = configurationBindingPath,
                CellTemplate   = new DataTemplate(typeof(int))
                {
                    VisualTree = visualTree
                }
            };

            column.SetIsFilterVisible(false);

            return(column);
        }