示例#1
0
        private void LoadCollectionView()
        {
            var vm = (SimilarityMatrixViewModel)DataContext;

            SimMatrixGrid.Columns.Clear();
            var view = new DataGridCollectionView(vm.Varieties, typeof(SimilarityMatrixVarietyViewModel), false, false);

            view.ItemProperties.Add(new DataGridItemProperty("Variety", ".", typeof(SimilarityMatrixVarietyViewModel)));
            for (int i = 0; i < vm.Varieties.Count; i++)
            {
                view.ItemProperties.Add(new DataGridItemProperty("Variety" + i, string.Format("VarietyPairs[{0}]", i), typeof(SimilarityMatrixVarietyPairViewModel)));
            }
            SimMatrixGrid.ItemsSource = view;

            var headerColumn = new Column {
                FieldName = "Variety", Title = ""
            };

            DataGridControlBehaviors.SetIsRowHeader(headerColumn, true);
            DataGridControlBehaviors.SetAutoSize(headerColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(headerColumn, 18);
            SimMatrixGrid.Columns.Add(headerColumn);
            for (int i = 0; i < vm.Varieties.Count; i++)
            {
                var column = new Column {
                    FieldName = "Variety" + i, Width = 30
                };
                var titleBinding = new Binding(string.Format("DataGridControl.DataContext.Varieties[{0}].Name", i))
                {
                    RelativeSource = RelativeSource.Self
                };
                BindingOperations.SetBinding(column, ColumnBase.TitleProperty, titleBinding);
                SimMatrixGrid.Columns.Add(column);
            }
        }
示例#2
0
        private void LoadCollectionView()
        {
            var vm = (SegmentsViewModel)DataContext;

            SegmentsDataGrid.CurrentColumn = null;
            SegmentsDataGrid.Columns.Clear();
            var view = new DataGridCollectionView(vm.Varieties, typeof(SegmentsVarietyViewModel), false, false);

            view.ItemProperties.Add(new DataGridItemProperty("Variety", ".", typeof(SegmentsVarietyViewModel)));
            for (int i = 0; i < vm.Segments.Count; i++)
            {
                view.ItemProperties.Add(new DataGridItemProperty(vm.Segments[i].StrRep, string.Format("Segments[{0}].Frequency", i), typeof(int)));
            }
            SegmentsDataGrid.ItemsSource = view;
            SegmentsDataGrid.Items.SortDescriptions.Clear();

            var headerColumn = new Column {
                FieldName = "Variety"
            };

            DataGridControlBehaviors.SetIsRowHeader(headerColumn, true);
            DataGridControlBehaviors.SetAutoSize(headerColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(headerColumn, 18);
            SegmentsDataGrid.Columns.Add(headerColumn);
            foreach (SegmentViewModel segment in vm.Segments)
            {
                SegmentsDataGrid.Columns.Add(new Column {
                    FieldName = segment.StrRep, Title = segment.StrRep, Width = 67, CellHorizontalContentAlignment = HorizontalAlignment.Center
                });
            }
        }
示例#3
0
        private void LoadCollectionView()
        {
            var vm = (WordListsViewModel)DataContext;

            if (vm == null)
            {
                return;
            }

            WordListsGrid.CurrentColumn = null;
            WordListsGrid.CurrentItem   = null;
            WordListsGrid.Columns.Clear();
            var view = new DataGridCollectionView(vm.Varieties, typeof(WordListsVarietyViewModel), false, false);

            view.ItemProperties.Add(new DataGridItemProperty("Variety", ".", typeof(WordListsVarietyViewModel)));
            IComparer sortComparer = ProjectionComparer <WordListsVarietyMeaningViewModel> .Create(meaning => meaning.StrRep);

            for (int i = 0; i < vm.Meanings.Count; i++)
            {
                view.ItemProperties.Add(new DataGridItemProperty("Meaning" + i, $"Meanings[{i}]", typeof(WordListsVarietyMeaningViewModel))
                {
                    SortComparer = sortComparer
                });
            }
            vm.VarietiesView = view;
            WordListsGrid.Items.SortDescriptions.Clear();

            var headerColumn = new Column {
                FieldName = "Variety"
            };

            DataGridControlBehaviors.SetIsRowHeader(headerColumn, true);
            DataGridControlBehaviors.SetAutoSize(headerColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(headerColumn, 18);
            WordListsGrid.Columns.Add(headerColumn);
            for (int i = 0; i < vm.Meanings.Count; i++)
            {
                var column = new Column {
                    FieldName = "Meaning" + i, Width = 100, CellEditor = WordListsGrid.DefaultCellEditors[typeof(WordListsVarietyMeaningViewModel)]
                };
                var titleBinding = new Binding($"DataGridControl.DataContext.Meanings[{i}].Gloss")
                {
                    RelativeSource = RelativeSource.Self
                };
                BindingOperations.SetBinding(column, ColumnBase.TitleProperty, titleBinding);
                WordListsGrid.Columns.Add(column);
            }
        }
        private void LoadCollectionView()
        {
            var vm = (SegmentMappingsTableViewModel)DataContext;

            SegmentsDataGrid.CurrentColumn = null;
            SegmentsDataGrid.Columns.Clear();
            var view = new DataGridCollectionView(vm.Segments.Reverse(), typeof(SegmentMappingsTableSegmentViewModel), false, false);

            view.ItemProperties.Add(new DataGridItemProperty("Segment", ".", typeof(SegmentMappingsTableSegmentViewModel)));
            for (int i = 0; i < vm.Segments.Count; i++)
            {
                view.ItemProperties.Add(new DataGridItemProperty(vm.Segments[i].StrRep, string.Format("SegmentPairs[{0}]", i), typeof(SegmentMappingsTableSegmentPairViewModel)));
            }
            SegmentsDataGrid.ItemsSource = view;

            var headerColumn = new Column {
                FieldName = "Segment"
            };

            DataGridControlBehaviors.SetIsRowHeader(headerColumn, true);
            headerColumn.Width = 30;
            headerColumn.CellVerticalContentAlignment   = VerticalAlignment.Center;
            headerColumn.CellHorizontalContentAlignment = HorizontalAlignment.Center;
            SegmentsDataGrid.Columns.Add(headerColumn);
            foreach (SegmentMappingsTableSegmentViewModel segment in vm.Segments)
            {
                SegmentsDataGrid.Columns.Add(new Column
                {
                    FieldName = segment.StrRep,
                    Title     = segment.StrRep,
                    Width     = 30,
                    AllowSort = false,
                    CellHorizontalContentAlignment = HorizontalAlignment.Center,
                    CellVerticalContentAlignment   = VerticalAlignment.Center,
                    CellContentTemplate            = (DataTemplate)SegmentsDataGrid.Resources["SegmentPairTemplate"],
                    CellEditor = SegmentsDataGrid.DefaultCellEditors[typeof(SegmentMappingsTableSegmentPairViewModel)]
                });
            }
        }
示例#5
0
        private void LoadCollectionView()
        {
            var vm = (MultipleWordAlignmentViewModel)DataContext;

            AlignmentGrid.Columns.Clear();

            var view = new DataGridCollectionView(vm.Words, typeof(MultipleWordAlignmentWordViewModel), false, false);

            view.ItemProperties.Add(new DataGridItemProperty("Variety", "Variety", typeof(VarietyViewModel))
            {
                SortComparer = ProjectionComparer <VarietyViewModel> .Create(v => v.Name)
            });
            view.ItemProperties.Add(new DataGridItemProperty("StrRep", "StrRep", typeof(string)));
            view.ItemProperties.Add(new DataGridItemProperty("CognateSetIndex", "CognateSetIndex", typeof(int)));
            view.ItemProperties.Add(new DataGridItemProperty("Prefix", "Prefix", typeof(string)));
            for (int i = 0; i < vm.ColumnCount; i++)
            {
                view.ItemProperties.Add(new DataGridItemProperty("Column" + i, string.Format("Columns[{0}]", i), typeof(string)));
            }
            view.ItemProperties.Add(new DataGridItemProperty("Suffix", "Suffix", typeof(string)));
            if (vm.GroupByCognateSet)
            {
                Debug.Assert(view.GroupDescriptions != null);
                view.GroupDescriptions.Add(new DataGridGroupDescription("CognateSetIndex"));
            }
            vm.WordsView = view;

            var headerColumn = new Column {
                FieldName = "Variety"
            };

            DataGridControlBehaviors.SetIsRowHeader(headerColumn, true);
            DataGridControlBehaviors.SetAutoSize(headerColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(headerColumn, 18);
            AlignmentGrid.Columns.Add(headerColumn);

            object fontSizeObj = System.Windows.Application.Current.FindResource("PhoneticFontSize");

            Debug.Assert(fontSizeObj != null);
            var fontSize = (double)fontSizeObj;

            var prefixColumn = new Column {
                FieldName = "Prefix", ReadOnly = true, CanBeCurrentWhenReadOnly = false
            };

            DataGridControlBehaviors.SetAutoSize(prefixColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(prefixColumn, 9);
            DataGridControlBehaviors.SetFontSizeHint(prefixColumn, fontSize);
            AlignmentGrid.Columns.Add(prefixColumn);
            for (int i = 0; i < vm.ColumnCount; i++)
            {
                var column = new Column {
                    FieldName = "Column" + i
                };
                DataGridControlBehaviors.SetAutoSize(column, true);
                DataGridControlBehaviors.SetAutoSizePadding(column, 9);
                DataGridControlBehaviors.SetFontSizeHint(column, fontSize);
                AlignmentGrid.Columns.Add(column);
            }
            var suffixColumn = new Column {
                FieldName = "Suffix", ReadOnly = true, CanBeCurrentWhenReadOnly = false
            };

            DataGridControlBehaviors.SetAutoSize(suffixColumn, true);
            DataGridControlBehaviors.SetAutoSizePadding(suffixColumn, 9);
            DataGridControlBehaviors.SetFontSizeHint(suffixColumn, fontSize);
            AlignmentGrid.Columns.Add(suffixColumn);

            AlignmentGrid.CurrentItem = null;
        }