protected override void OnRender(DrawingContext drawingContext)
 {
     if (_type.HasFlag(DataSourceDropType.ArrangeTop))
     {
         drawingContext.DrawLine(_pen, new Point(0, 0), new Point(ActualWidth, 0));
     }
     else if (_type.HasFlag(DataSourceDropType.ArrangeBottom))
     {
         drawingContext.DrawLine(_pen, new Point(0, ActualHeight), new Point(ActualWidth, ActualHeight));
     }
 }
Пример #2
0
        private void DropToArrange(IDataSourceViewModel source, IDataSourceViewModel dest, DataSourceDropType dropType)
        {
            IDataSourceViewModel sourceParent = source.Parent;
            if (sourceParent != null)
            {
                //
                // When the source is part of a group, then any arrange is going to remove it
                // from said group.
                //
                var group = ((MergedDataSourceViewModel) sourceParent);
                group.RemoveChild(source);
                if (sourceParent != dest.Parent)
                {
                    //
                    // If both source and dest are part of different groups, then
                    // we need to check if source's group needs to be dissolved due to
                    // having only 1 child left.
                    //
                    DissolveGroupIfNecessary(group);
                }
            }
            else
            {
                _observable.Remove(source);
            }

            if (dest.Parent != null)
            {
                //
                // If the destination has a parent then we need to insert
                // the source into it's collection.
                //
                var merged = ((MergedDataSourceViewModel) dest.Parent);
                int index = merged.Observable.IndexOf(dest);
                if (dropType.HasFlag(DataSourceDropType.ArrangeBottom))
                    ++index;

                merged.Insert(index, source);
            }
            else
            {
                //
                // Otherwise we insert the source into the flat, or root
                // collection.
                //
                int index = _observable.IndexOf(dest);
                if (dropType.HasFlag(DataSourceDropType.ArrangeBottom))
                    ++index;
                if (index < 0)
                    index = 0;

                _observable.Insert(index, source);
            }

            SelectedItem = source;
        }
Пример #3
0
        private void DropToArrange(IDataSourceViewModel source, IDataSourceViewModel dest, DataSourceDropType dropType)
        {
            IDataSourceViewModel sourceParent = source.Parent;

            if (sourceParent != null)
            {
                //
                // When the source is part of a group, then any arrange is going to remove it
                // from said group.
                //
                var group = ((MergedDataSourceViewModel)sourceParent);
                group.RemoveChild(source);
                if (sourceParent != dest.Parent)
                {
                    //
                    // If both source and dest are part of different groups, then
                    // we need to check if source's group needs to be dissolved due to
                    // having only 1 child left.
                    //
                    DissolveGroupIfNecessary(group);
                }
            }
            else
            {
                _observable.Remove(source);
            }

            if (dest.Parent != null)
            {
                //
                // If the destination has a parent then we need to insert
                // the source into it's collection.
                //
                var merged = ((MergedDataSourceViewModel)dest.Parent);
                int index  = merged.Observable.IndexOf(dest);
                if (dropType.HasFlag(DataSourceDropType.ArrangeBottom))
                {
                    ++index;
                }

                merged.Insert(index, source);
            }
            else
            {
                //
                // Otherwise we insert the source into the flat, or root
                // collection.
                //
                int index = _observable.IndexOf(dest);
                if (dropType.HasFlag(DataSourceDropType.ArrangeBottom))
                {
                    ++index;
                }
                if (index < 0)
                {
                    index = 0;
                }

                _observable.Insert(index, source);
                if (dropType.HasFlag(DataSourceDropType.ArrangeTop))
                {
                    if (index + 1 < _observable.Count)
                    {
                        var tmp    = source.DataSource.Settings;
                        var before = _observable[index + 1].DataSource.Settings;
                        _settings.DataSources.MoveBefore(tmp, before);
                    }
                }
            }

            SelectedItem = source;
            _settings.SaveAsync();
        }