Exemplo n.º 1
0
        private void TextBlock_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(Category)))
            {
                TextBlock dropBlock        = sender as TextBlock;
                Category  replacedCategory = dropBlock.DataContext as Category;

                System.Diagnostics.Debug.WriteLine(e.Data.GetData(typeof(Category)).ToString());
                Category dropData = e.Data.GetData(typeof(Category)) as Category;

                CategoryList parent       = replacedCategory.ParentCategoryList;
                int          initialIndex = parent.IndexOf(dropData);
                int          dropIndex    = parent.IndexOf(replacedCategory);
                parent.Move(initialIndex, dropIndex);
            }
            else if (e.Data.GetDataPresent(typeof(ApplicationInfo)))
            {
                if (((sender as TextBlock).DataContext as Category).Name == "Quick Launch")
                {
                    e.Effects = DragDropEffects.Copy;
                }
                else
                {
                    e.Effects = DragDropEffects.Move;
                }
                ApplicationInfo dropData       = e.Data.GetData(typeof(ApplicationInfo)) as ApplicationInfo;
                Category        dropCollection = (sender as TextBlock).DataContext as Category;
                if (e.Effects == DragDropEffects.Move)
                {
                    (sourceView.ItemsSource as IList <ApplicationInfo>).Remove(dropData);
                    if ((sourceView.ItemsSource as Category).Name != "Quick Launch")
                    {
                        dropCollection.Add(dropData);
                    }
                }
                else if (e.Effects == DragDropEffects.Copy)
                {
                    ApplicationInfo dropClone = dropData.Clone();
                    // Do not duplicate entries
                    if (!dropCollection.Contains(dropClone))
                    {
                        dropCollection.Add(dropClone);
                    }
                }
                sourceView = null;
            }
            isDragging = false;
        }
Exemplo n.º 2
0
        private void TextBlock_Drop(object sender, DragEventArgs e)
        {
            TextBlock dropBlock    = sender as TextBlock;
            Category  dropCategory = dropBlock.DataContext as Category;

            if (e.Data.GetDataPresent(typeof(Category)))
            {
                CairoLogger.Instance.Debug(e.Data.GetData(typeof(Category)).ToString());
                Category dropData = e.Data.GetData(typeof(Category)) as Category;

                CategoryList parent       = dropCategory.ParentCategoryList;
                int          initialIndex = parent.IndexOf(dropData);
                int          dropIndex    = parent.IndexOf(dropCategory);
                parent.Move(initialIndex, dropIndex);
            }
            else if (e.Data.GetDataPresent(typeof(ApplicationInfo)))
            {
                ApplicationInfo dropData = e.Data.GetData(typeof(ApplicationInfo)) as ApplicationInfo;
                if (dropCategory.Type == AppCategoryType.QuickLaunch)
                {
                    e.Effects = DragDropEffects.Copy;

                    // Do not duplicate entries
                    if (!dropCategory.Contains(dropData))
                    {
                        ApplicationInfo dropClone = dropData.Clone();
                        dropCategory.Add(dropClone);
                        dropClone.Icon     = null; // icon may differ depending on category
                        dropClone.IconPath = null;
                    }
                }
                else if (sourceView != null)
                {
                    e.Effects = DragDropEffects.Move;

                    (sourceView.ItemsSource as Category).Remove(dropData);
                    if ((sourceView.ItemsSource as Category).Type != AppCategoryType.QuickLaunch)
                    {
                        dropCategory.Add(dropData);
                    }
                }

                sourceView = null;
            }

            isDragging = false;
        }