Exemplo n.º 1
0
        protected internal override void ApplyChangesFrom(DtoBaseViewModel otherBase)
        {
            base.ApplyChangesFrom(otherBase);
            var other = otherBase as DtoTableViewModel;

            DtoBuilder.Merge(this.Rows, other.Rows);
            DtoBuilder.Merge(this.Columns, other.Columns);
            DtoBuilder.Merge(this.Cells, other.Cells);
        }
Exemplo n.º 2
0
        protected internal override void ApplyChangesFrom(DtoBaseViewModel otherBase)
        {
            base.ApplyChangesFrom(otherBase);
            var other = otherBase as DtoGroupedViewModel;

            this.AlternateBackground = other.AlternateBackground;
            var selectedIdx = other.Items.IndexOf(other.SelectedItem);

            DtoBuilder.Merge(this.Items, other.Items);

            if (selectedIdx >= 0 && selectedIdx < this.Items.Count)
            {
                this.SelectedItem = this.Items[selectedIdx];
            }
            else
            {
                this.SelectedItem = this.Items.FirstOrDefault();
            }
        }
Exemplo n.º 3
0
        public static void Merge <Tdto>(ObservableCollection <Tdto> a, ObservableCollection <Tdto> b)
            where Tdto : DtoBaseViewModel
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            if (b == null)
            {
                throw new ArgumentNullException("b");
            }

            int idx = 0;

            for (; idx < a.Count && idx < b.Count; idx++)
            {
                a[idx] = DtoBuilder.Combine(a[idx], b[idx]);
            }

            // delete from last element downwards
            if (b.Count < a.Count)
            {
                int deleteIdx = a.Count - 1;
                while (deleteIdx > idx)
                {
                    a.RemoveAt(deleteIdx);
                    deleteIdx -= 1;
                }
            }
            else if (b.Count > a.Count)
            {
                // add leftover items
                while (idx < b.Count)
                {
                    a.Add(b[idx]);
                    idx += 1;
                }
            }
        }
Exemplo n.º 4
0
        protected internal override void ApplyChangesFrom(DtoBaseViewModel otherBase)
        {
            base.ApplyChangesFrom(otherBase);
            var other = otherBase as DtoCellViewModel;

            //other.Parent is left behind
            //this.Parent == other.Parent;
            //other.Row is left behind
            //this.Row == other.Row;
            //other.Column is left behind
            //this.Column == other.Column;
            this.Location = other.Location;
            var thisDtoViewModel  = this.Value as DtoBaseViewModel;
            var otherDtoViewModel = other.Value as DtoBaseViewModel;

            if (thisDtoViewModel != null && otherDtoViewModel != null)
            {
                this.Value = DtoBuilder.Combine(thisDtoViewModel, otherDtoViewModel);
            }
            else
            {
                this.Value = other.Value;
            }
        }