示例#1
0
        void DataGrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e)
        {
            if (DataContext is QualificationViewModel context && e.NewItemsSource != null && context?.Publication?.Evaluation_Disposition != null)
            {
                DataGrid.CustomDeserialize(context.Publication.Evaluation_Disposition, true);

                // On supprime les colonnes inutiles
                DataGrid.RemoveHiddenColumns();
                // On renomme les colonnes
                DataGrid.RenameColumns();

                DataGrid.DetailsViewPadding = new Thickness(0, 10, 10, 10);
                CustomColumnSizerBehavior.SetIsEnabled(DataGrid, true);

                //var columnSizer = (CustomColumnSizer)DataGrid.GridColumnSizer;
                //DataGrid.Columns["WBS"].Width = context.Publication.PublishedActions.Select(_ => columnSizer.MeasureText(IndentWBSConverter.Instance.Convert(_.WBS), DataGrid.Columns["WBS"]).Width).Max() + 10;
                DataGrid.Columns[nameof(PublishedAction.WBS)].DisplayBinding = new Binding(nameof(PublishedAction.WBS))
                {
                    Mode = BindingMode.OneWay, Converter = IndentWBSConverter.Instance
                };
                DataGrid.Columns[nameof(PublishedAction.Label)].CellTemplateSelector   = Resources["LabelStyleSelectorWithTriggers"] as DataTemplateSelector;
                DataGrid.Columns[nameof(Qualification.IsQualified)].CellStyle          = Application.Current.Resources["QualifiedGridCellStyle"] as Style;
                DataGrid.Columns[HeadersHelper.IsNotQualified].CellStyle               = Application.Current.Resources["NotQualifiedGridCellStyle"] as Style;
                DataGrid.Columns[HeadersHelper.QualificationStep_Comment].CellTemplate = Resources["CommentCellTemplate"] as DataTemplate;
                if (DataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.Thumbnail)))
                {
                    DataGrid.Columns[nameof(PublishedAction.Thumbnail)].CellTemplate = Resources["ThumbnailTemplate"] as DataTemplate;
                }
                if (DataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedResource)))
                {
                    DataGrid.Columns[nameof(PublishedAction.PublishedResource)].CellTemplateSelector = Resources["PublishedResourceDataGridTemplateSelector"] as DataTemplateSelector;
                }
                if (DataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedActionCategory)))
                {
                    DataGrid.Columns[nameof(PublishedAction.PublishedActionCategory)].CellTemplateSelector = Resources["PublishedCategoryDataGridTemplateSelector"] as DataTemplateSelector;
                }

                if (context != null)
                {
                    context.DataGrid = DataGrid;
                }
            }

            DataGrid_Loaded(sender, null);

            DataGrid.ExpandAllDetailsView();
            ScrollTo(sender, null);
        }
示例#2
0
        void DataGrid_DetailsViewLoading(object sender, DetailsViewLoadingAndUnloadingEventArgs e)
        {
            CustomColumnSizerBehavior.SetIsEnabled(e.DetailsViewDataGrid, true);
            var visualContainer = e.DetailsViewDataGrid.GetVisualContainer();

            try
            {
                var items   = (TrackableCollection <PublishedAction>)e.DetailsViewDataGrid.ItemsSource;
                int nbRows  = visualContainer.RowCount;
                int?nbItems = items?.Count;

                if (nbItems.HasValue)
                {
                    for (int i = 0; i < nbItems; i++)
                    {
                        if (items[i].IsGroup)
                        {
                            if (e.DetailsViewDataGrid.GridColumnSizer.GetAutoRowHeight(i, gridRowResizingOptions, out double autoHeight))
                            {
                                visualContainer.RowHeights[i + 1] = Math.Max(autoHeight, DefaultGroupHeight);
                            }
                            else
                            {
                                visualContainer.RowHeights[i + 1] = DefaultGroupHeight;
                            }
                        }
                        else
                        {
                            if (e.DetailsViewDataGrid.GridColumnSizer.GetAutoRowHeight(i, gridRowResizingOptions, out double autoHeight))
                            {
                                visualContainer.RowHeights[i + 1] = Math.Max(autoHeight, DefaultNotGroupHeight);
                            }
                            else
                            {
                                visualContainer.RowHeights[i + 1] = DefaultNotGroupHeight;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Locator.TraceManager.TraceError(ex, "Erreur lors de la modification de la hauteur des lignes du tableau.");
            }

            visualContainer.InvalidateMeasure();
        }
示例#3
0
        /// <summary>
        /// Méthode appellé lorsque la source de donnée de la grille caché change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DataGrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e)
        {
            if (DataContext is SelectInspectionSummaryViewModel context && e.NewItemsSource != null && context?.Publication?.Inspection_Disposition != null)
            {
                DataGrid.CustomDeserialize(context.Publication.Inspection_Disposition, true);

                // On supprime les colonnes inutiles
                DataGrid.RemoveHiddenColumns();
                // On renomme les colonnes
                DataGrid.RenameColumns();

                DataGrid.DetailsViewPadding = new Thickness(0, 10, 10, 10);
                CustomColumnSizerBehavior.SetIsEnabled(DataGrid, true);

                //var columnSizer = (CustomColumnSizer)DataGrid.GridColumnSizer;
                //DataGrid.Columns["WBS"].Width = context.Publication.PublishedActions.Select(_ => columnSizer.MeasureText(IndentWBSConverter.Instance.Convert(_.WBS), DataGrid.Columns["WBS"]).Width).Max() + 10;
                DataGrid.Columns[nameof(PublishedAction.WBS)].DisplayBinding = new Binding(nameof(PublishedAction.WBS))
                {
                    Mode = BindingMode.OneWay, Converter = IndentWBSConverter.Instance
                };
                DataGrid.Columns[nameof(PublishedAction.Label)].CellTemplateSelector = Resources["LabelStyleSelector"] as DataTemplateSelector;
                if (DataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedResource)))
                {
                    DataGrid.Columns[nameof(PublishedAction.PublishedResource)].CellTemplateSelector = Resources["PublishedResourceDataGridTemplateSelector"] as DataTemplateSelector;
                }
                if (DataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedActionCategory)))
                {
                    DataGrid.Columns[nameof(PublishedAction.PublishedActionCategory)].CellTemplateSelector = Resources["PublishedCategoryDataGridTemplateSelector"] as DataTemplateSelector;
                }

                if (context != null)
                {
                    context.DataGrid = DataGrid;
                }

                DataGrid_Loaded(sender, null);
            }
        }
示例#4
0
        void DataGrid_DetailsViewLoading(object sender, DetailsViewLoadingAndUnloadingEventArgs e)
        {
            Publication linkedPublication = null;
            TrackableCollection <PublishedAction> publishedActions = null;

            if (e.DetailsViewDataGrid.ItemsSource is TrackableCollection <PublishedAction> source && source.Any())
            {
                publishedActions  = source;
                linkedPublication = source.First().Publication;
            }

            if (e.DetailsViewDataGrid.SerializationController != null && !(e.DetailsViewDataGrid.SerializationController is LinkedPublicationDataGridSerialization))
            {
                e.DetailsViewDataGrid.SerializationController = new LinkedPublicationDataGridSerialization(e.DetailsViewDataGrid);
                e.DetailsViewDataGrid.CellTapped += DetailsViewDataGrid_CellTapped;
                if (linkedPublication?.Inspection_Disposition != null && linkedPublication.Inspection_Disposition.Length > 1)
                {
                    e.DetailsViewDataGrid.CustomDeserialize(linkedPublication.Inspection_Disposition);

                    // On supprime les colonnes inutiles
                    e.DetailsViewDataGrid.RemoveHiddenColumns();
                    // On renomme les colonnes
                    e.DetailsViewDataGrid.RenameColumns();
                }
                e.DetailsViewDataGrid.SortComparers.Add(new SortComparer {
                    Comparer = new WBSComparer(), PropertyName = nameof(PublishedAction.WBS)
                });
                e.DetailsViewDataGrid.SortColumnDescriptions.Clear();
                e.DetailsViewDataGrid.SortColumnDescriptions.Add(new SortColumnDescription {
                    ColumnName = nameof(PublishedAction.WBS), SortDirection = ListSortDirection.Ascending
                });
                e.DetailsViewDataGrid.ExpanderColumnWidth = 0;
                CustomColumnSizerBehavior.SetIsEnabled(e.DetailsViewDataGrid, true);

                //var columnSizer = (CustomColumnSizer)e.DetailsViewDataGrid.GridColumnSizer;
                try
                {
                    //e.DetailsViewDataGrid.Columns["WBS"].Width = publishedActions.Select(_ => columnSizer.MeasureText(IndentWBSConverter.Instance.Convert(_.WBS), e.DetailsViewDataGrid.Columns["WBS"], true).Width).Max() + 10;
                    e.DetailsViewDataGrid.Columns[nameof(PublishedAction.WBS)].DisplayBinding = new Binding(nameof(PublishedAction.WBS))
                    {
                        Mode = BindingMode.OneWay, Converter = IndentWBSConverter.Instance
                    };
                }
                catch { }
                e.DetailsViewDataGrid.Columns[nameof(PublishedAction.Label)].CellTemplateSelector = Resources["LabelStyleSelector"] as DataTemplateSelector;
                if (e.DetailsViewDataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedResource)))
                {
                    e.DetailsViewDataGrid.Columns[nameof(PublishedAction.PublishedResource)].CellTemplateSelector = Resources["PublishedResourceDataGridTemplateSelector"] as DataTemplateSelector;
                }
                if (e.DetailsViewDataGrid.Columns.Any(_ => _.MappingName == nameof(PublishedAction.PublishedActionCategory)))
                {
                    e.DetailsViewDataGrid.Columns[nameof(PublishedAction.PublishedActionCategory)].CellTemplateSelector = Resources["PublishedCategoryDataGridTemplateSelector"] as DataTemplateSelector;
                }
            }

            var visualContainer = e.DetailsViewDataGrid.GetVisualContainer();

            try
            {
                var items   = (TrackableCollection <PublishedAction>)e.DetailsViewDataGrid.ItemsSource;
                int?nbItems = items?.Count;

                if (nbItems.HasValue)
                {
                    for (int i = 0; i < nbItems; i++)
                    {
                        if (items[i].IsGroup)
                        {
                            if (e.DetailsViewDataGrid.GridColumnSizer.GetAutoRowHeight(i, gridRowResizingOptions, out double autoHeight))
                            {
                                visualContainer.RowHeights[2 * i + 1] = Math.Max(autoHeight, DefaultGroupHeight);
                            }
                            else
                            {
                                visualContainer.RowHeights[2 * i + 1] = DefaultGroupHeight;
                            }
                        }
                        else
                        {
                            if (e.DetailsViewDataGrid.GridColumnSizer.GetAutoRowHeight(i, gridRowResizingOptions, out double autoHeight))
                            {
                                visualContainer.RowHeights[2 * i + 1] = Math.Max(autoHeight, DefaultNotGroupHeight);
                            }
                            else
                            {
                                visualContainer.RowHeights[2 * i + 1] = DefaultNotGroupHeight;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Locator.TraceManager.TraceError(ex, "Erreur lors de la modification de la hauteur des lignes du tableau.");
            }

            visualContainer.InvalidateMeasure();
        }