Пример #1
0
            public ItemInfo(object dataItem, object destItem)
            {
                this.Item     = dataItem;
                this.destItem = destItem;
                this.Fields   = DiffUtility.GetFields(destItem);

                var dataChildItems = new List <object>();
                var destChildItems = new List <object>();

                foreach (var item in DiffUtility.GetChilds(dataItem))
                {
                    dataChildItems.Add(item);
                }
                foreach (var item in DiffUtility.GetChilds(destItem))
                {
                    destChildItems.Add(item);
                }

                var query = from dataChild in dataChildItems
                            join destChild in destChildItems
                            on $"{DiffUtility.GetListName(dataChild)}{DiffUtility.GetItemKey(dataChild)}"
                            equals $"{DiffUtility.GetListName(destChild)}{DiffUtility.GetItemKey(destChild)}"
                            select new { DataItem = dataChild, DestItem = destChild };

                foreach (var item in query)
                {
                    this.childList.Add(new ItemInfo(item.DataItem, item.DestItem));
                }
            }
Пример #2
0
 public object FindItem(CollectionView items, object key)
 {
     if (key != null)
     {
         foreach (var item in items)
         {
             var key2 = DiffUtility.GetItemKey(item);
             if (object.Equals(key, key2) == true)
             {
                 return(item);
             }
         }
     }
     return(null);
 }
Пример #3
0
        private void SyncSelection(DiffDataGridControl destControl)
        {
            using (destControl.preventSelection.Set(true))
            {
                {
                    this.SelectedItemRanges.Clear();
                    foreach (var item in DataGridControl.GetDataGridContext(this).GetChildContexts())
                    {
                        item.SelectedItemRanges.Clear();
                    }
                }

                if (destControl.GlobalCurrentItem != null)
                {
                    var destContext = DataGridControl.GetDataGridContext(destControl);
                    Select(destContext);

                    foreach (var item in destContext.GetChildContexts())
                    {
                        Select(item);
                    }
                }
            }

            void Select(DataGridContext destContext)
            {
                var gridContext = this.FindContext(destContext);
                var query       = from item in destContext.GetSelectedItems()
                                  let obj = this.FindItem(gridContext.Items, DiffUtility.GetItemKey(item))
                                            where obj != null
                                            select obj;

                if (query.Count() == destContext.GetSelectedItems().Count())
                {
                    var selectionRanges = gridContext.GenerateSelectionRanges(query);
                    foreach (var item in selectionRanges)
                    {
                        gridContext.SelectedItemRanges.Add(item);
                    }
                }
            }
        }
Пример #4
0
        private void SyncCurrentItem(DiffDataGridControl destControl)
        {
            var destCurrentItem = destControl.GlobalCurrentItem;

            if (destCurrentItem == null)
            {
                return;
            }

            var dataContext = this.FindContext(destControl.CurrentContext);

            if (dataContext == null)
            {
                return;
            }

            using (destControl.preventEvent.Set(true))
            {
                dataContext.CurrentItem = this.FindItem(dataContext.Items, DiffUtility.GetItemKey(destControl.GlobalCurrentItem));
            }
        }