예제 #1
0
        private void Drag(IDataSourceViewModel source, IDataSourceViewModel dest)
        {
            var merged = dest as MergedDataSourceViewModel;
            if (merged != null)
            {
                // Drag from ungrouped onto an existing group
                // => add to existing group
                AddFileToGroup(source, merged);
            }
            else
            {
                // Drag from ungrouped onto a dest within a group
                // => find group of dest and addd to it
                merged = dest.Parent as MergedDataSourceViewModel;
                if (merged != null)
                {
                    AddFileToGroup(source, merged);
                }
                else
                {
                    // Drag from ungrouped onto another ungrouped source
                    // => remove dest as well and create new group
                    int destIndex = _observable.IndexOf(dest);
                    if (destIndex != -1)
                    {
                        _observable.Remove(dest);

                        MergedDataSource mergedDataSource = _dataSources.AddGroup();
                        merged = new MergedDataSourceViewModel(mergedDataSource);
                        merged.Remove += OnRemove;
                        merged.AddChild(source);
                        merged.AddChild(dest);
                        _observable.Insert(destIndex, merged);
                        SelectedItem = merged;
                    }
                }
            }
        }
예제 #2
0
 private static void AddFileToGroup(IDataSourceViewModel source, MergedDataSourceViewModel viewModel)
 {
     viewModel.AddChild(source);
 }