コード例 #1
0
        private void DataRowView_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (this.DataContext == null)
            {
                return;
            }

            if (e.PropertyName == DiffUtility.DiffFieldsKey || e.PropertyName == string.Empty)
            {
                this.diffFields = new HashSet <string>(DiffUtility.GetDiffFields(this.DataContext));
            }
            if (e.PropertyName == DiffUtility.DiffStateKey || e.PropertyName == DiffUtility.DiffEnabledKey || e.PropertyName == string.Empty)
            {
                this.SetValue(DiffStatePropertyKey, DiffUtility.GetDiffState(this.DataContext));
            }
            if (e.PropertyName == CremaSchema.Index)
            {
                this.Dispatcher.InvokeAsync(this.SetSelectionProperty);
            }

            if (e.PropertyName == string.Empty)
            {
                if (sender is IDataErrorInfo errorInfo)
                {
                    if (errorInfo.Error == string.Empty && this.HasValidationError == true)
                    {
                        this.Dispatcher.InvokeAsync(() =>
                        {
                            this.EndEditCore();
                        });
                    }
                }
            }
            this.RefreshError();
        }
コード例 #2
0
        protected override void PrepareContainer(DataGridContext dataGridContext, object item)
        {
            if (this.DataContext is INotifyPropertyChanged oldRow)
            {
                oldRow.PropertyChanged -= DataRowView_PropertyChanged;
            }

            if (item is ICustomTypeDescriptor descriptor)
            {
                this.diffFields = new HashSet <string>(DiffUtility.GetDiffFields(item));
            }
            else
            {
                this.diffFields = null;
            }

            if (item is INotifyPropertyChanged newRow)
            {
                newRow.PropertyChanged += DataRowView_PropertyChanged;
            }

            this.SetValue(DiffStatePropertyKey, DiffUtility.GetDiffState(item));
            this.PropertyChanged -= DiffDataContainer_PropertyChanged;
            dataGridContext.DataGridControl.SelectionChanged -= DataGridControl_SelectionChanged;
            base.PrepareContainer(dataGridContext, item);
            this.SetSelectionProperty();
            dataGridContext.DataGridControl.SelectionChanged += DataGridControl_SelectionChanged;
            this.PropertyChanged += DiffDataContainer_PropertyChanged;
        }
コード例 #3
0
 private static DiffMinimapItemState GetDiffState(object item)
 {
     if (DiffUtility.HasDiffState(item) == false)
     {
         return(DiffMinimapItemState.Null);
     }
     return((DiffMinimapItemState)DiffUtility.GetDiffState(item));
 }
コード例 #4
0
        protected override void PrepareContainer(DataGridContext dataGridContext, object item)
        {
            base.PrepareContainer(dataGridContext, item);
            var columnItem = CremaDataTableItemControl.GetReference(this.ParentColumn);
            var diffState  = columnItem != null?DiffUtility.GetDiffState(columnItem) : DiffState.Unchanged;

            this.SetValue(DiffStatePropertyKey, diffState);
            this.SetValue(IsDummyPropertyKey, this.FieldName.StartsWith(DiffUtility.DiffDummyKey));
        }
コード例 #5
0
 public ItemViewModel(DiffDataTable diffTable, DependencyObject parent)
 {
     this.diffTable = diffTable;
     this.parent    = parent;
     this.diffState = DiffUtility.GetDiffState(this.diffTable.SourceItem1) == DiffState.Imaginary ? DiffState.Inserted : DiffUtility.GetDiffState(this.diffTable.SourceItem1);
     BindingOperations.SetBinding(this, ReadOnlyProperty, new Binding("ReadOnly")
     {
         Source = parent,
     });
 }
コード例 #6
0
        private void InitializeDetail(DetailConfiguration detail)
        {
            var childTable = CremaDataTableItemControl.GetReference(detail) as CremaDataTable;
            var diffState  = DiffUtility.GetDiffState(childTable);

            detail.Title = new DetailsDescriptor()
            {
                Title = childTable.TableName, DiffState = diffState,
            };
            detail.TitleTemplate = this.FindResource("Diff_DetailConfiguration_Title_Template") as DataTemplate;

            foreach (var item in detail.Columns)
            {
                item.PropertyChanged += Column_PropertyChanged;
            }
        }
コード例 #7
0
ファイル: DiffHorzMinimap.cs プロジェクト: teize001/Crema
        private void ResetHorizontalMinimap(Grid grid, DataGridContext gridContext)
        {
            if (gridContext.VisibleColumns.Any() == false || gridContext.CurrentItem == null)
            {
                grid.Visibility = Visibility.Hidden;
                return;
            }

            var diffState  = DiffUtility.GetDiffState(gridContext.CurrentItem);
            var fixedCount = (int)gridContext.GetValue(TableView.FixedColumnCountProperty);
            var prevState  = (int)DiffState.Unchanged;
            var count      = (double)0;
            var list       = new List <double>();
            var states     = new List <int>();
            var fields     = DiffUtility.GetDiffFields(gridContext.CurrentItem);
            var totalWidth = (double)0;
            var fixedSize  = (double)0;

            foreach (var item in gridContext.VisibleColumns)
            {
                var rowState = (int)diffState;
                if (rowState == (int)DiffState.Modified)
                {
                    rowState = fields.Contains(item.FieldName) == true ? (int)DiffState.Modified : (int)DiffState.Unchanged;
                }

                if (gridContext.CurrentItem is IDataErrorInfo errorInfo && errorInfo[item.FieldName] != string.Empty)
                {
                    rowState |= (1 << 16);
                }


                if (item.Index < fixedCount)
                {
                    fixedSize += item.ActualWidth;
                }
                if (rowState != prevState)
                {
                    if (count != 0)
                    {
                        list.Add(count);
                        states.Add(prevState);
                    }
                    count     = 0;
                    prevState = rowState;
                }
                else
                {
                }
                count      += item.ActualWidth;
                totalWidth += item.ActualWidth;
            }

            list.Add(count);
            states.Add(prevState);

            grid.Children.Clear();
            grid.ColumnDefinitions.Clear();

            for (var i = 0; i < list.Count; i++)
            {
                var item   = list[i];
                var state  = states[i] & 0x0000ffff;
                var error  = (states[i] & 0xffff0000) >> 16;
                var brush  = DiffBrushes.GetBackgroundBrush((DiffState)state);
                var border = new Border()
                {
                    BorderThickness = new Thickness(0, error != 0 ? 4 : 0, 0, 0), BorderBrush = Brushes.Red, Background = brush,
                };
                Grid.SetColumn(border, grid.ColumnDefinitions.Count);
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(item / totalWidth, GridUnitType.Star),
                });
                grid.Children.Add(border);
            }
            grid.Visibility = Visibility.Visible;
        }