示例#1
0
 private void ListView_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(ApplicationInfo)) && sourceView != sender)
     {
         System.Diagnostics.Debug.WriteLine(e.Data.GetData(typeof(ApplicationInfo)).ToString());
         ListView dropTarget = sender as ListView;
         if (dropTarget.ItemsSource is Category)
         {
             if ((dropTarget.ItemsSource as Category).Name == "Quick Launch")
             {
                 e.Effects = DragDropEffects.Copy;
             }
             else
             {
                 e.Effects = DragDropEffects.Move;
             }
         }
         else
         {
             e.Effects = DragDropEffects.Move;
         }
         ApplicationInfo dropData = e.Data.GetData(typeof(ApplicationInfo)) as ApplicationInfo;
         if (e.Effects == DragDropEffects.Move)
         {
             (sourceView.ItemsSource as IList <ApplicationInfo>).Remove(dropData);
             if (dropTarget.ItemsSource is Category)
             {
                 if ((sourceView.ItemsSource as Category).Name != "Quick Launch")
                 {
                     ((dropTarget.ItemsSource) as IList <ApplicationInfo>).Add(dropData);
                 }
             }
             else
             {
                 ((dropTarget.ItemsSource) as IList <ApplicationInfo>).Add(dropData);
             }
         }
         else if (e.Effects == DragDropEffects.Copy)
         {
             ApplicationInfo dropClone = dropData.Clone();
             // Do not duplicate entries
             if (!((dropTarget.ItemsSource) as Category).Contains(dropClone))
             {
                 ((dropTarget.ItemsSource) as Category).Add(dropClone);
             }
         }
         if (dropTarget.Items.Count > 0)
         {
             dropTarget.ScrollIntoView(dropTarget.Items[dropTarget.Items.Count - 1]);
         }
     }
     sourceView = null;
     isDragging = false;
 }
示例#2
0
        public void AddToQuickLaunch(ApplicationInfo app)
        {
            if (!QuickLaunch.Contains(app))
            {
                ApplicationInfo appClone = app.Clone();
                appClone.Icon = null;

                QuickLaunch.Add(appClone);

                Save();
            }
        }
        public void AddToQuickLaunch(ApplicationInfo app)
        {
            if (_appGrabber.QuickLaunch.Contains(app))
            {
                return;
            }

            ApplicationInfo appClone = app.Clone();

            appClone.Icon = null;

            _appGrabber.QuickLaunch.Add(appClone);

            _appGrabber.Save();
        }
示例#4
0
        public void AddToQuickLaunch(ApplicationInfo app)
        {
            Category quickLaunch = CategoryList.GetSpecialCategory(3);

            if (!quickLaunch.Contains(app))
            {
                ApplicationInfo appClone = app.Clone();
                appClone.Icon     = null;
                appClone.IconPath = null;

                quickLaunch.Add(appClone);

                Save();
            }
        }
示例#5
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;
        }
示例#6
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;
        }
示例#7
0
        private void ListView_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ApplicationInfo)))
            {
                CairoLogger.Instance.Debug(e.Data.GetData(typeof(ApplicationInfo)).ToString());
                ApplicationInfo dropData   = e.Data.GetData(typeof(ApplicationInfo)) as ApplicationInfo;
                ListView        dropTarget = sender as ListView;

                if (dropTarget.ItemsSource is Category)
                {
                    Category target = dropTarget.ItemsSource as Category;

                    if (target.Type == AppCategoryType.QuickLaunch)
                    {
                        e.Effects = DragDropEffects.Copy;

                        // Do not duplicate entries
                        if (!target.Contains(dropData))
                        {
                            ApplicationInfo dropClone = dropData.Clone();

                            if (e.OriginalSource != null && e.OriginalSource is FrameworkElement && (e.OriginalSource as FrameworkElement).DataContext != null && (e.OriginalSource as FrameworkElement).DataContext is ApplicationInfo)
                            {
                                target.Insert(target.IndexOf((e.OriginalSource as FrameworkElement).DataContext as ApplicationInfo), dropClone);
                            }
                            else
                            {
                                target.Add(dropClone);
                            }

                            dropClone.Icon     = null; // icon may differ depending on category
                            dropClone.IconPath = null;
                        }
                        else
                        {
                            // reorder existing
                            if (e.OriginalSource != null && e.OriginalSource is FrameworkElement && (e.OriginalSource as FrameworkElement).DataContext != null && (e.OriginalSource as FrameworkElement).DataContext is ApplicationInfo)
                            {
                                target.Move(target.IndexOf(dropData), target.IndexOf((e.OriginalSource as FrameworkElement).DataContext as ApplicationInfo));
                            }
                        }
                    }
                    else if (sourceView != null && sourceView != sender)
                    {
                        e.Effects = DragDropEffects.Move;

                        Category source = sourceView.ItemsSource as Category;

                        source.Remove(dropData);

                        if (source.Type != AppCategoryType.QuickLaunch)
                        {
                            target.Add(dropData); // if coming from quick launch, simply remove from quick launch

                            if (dropTarget.Items.Contains(dropData))
                            {
                                dropTarget.ScrollIntoView(dropTarget.Items[dropTarget.Items.IndexOf(dropData)]);
                            }
                        }
                    }
                }
                else
                {
                    e.Effects = DragDropEffects.Move;

                    (sourceView.ItemsSource as IList <ApplicationInfo>).Remove(dropData);
                    (dropTarget.ItemsSource as IList <ApplicationInfo>).Add(dropData);

                    if (dropTarget.Items.Contains(dropData))
                    {
                        dropTarget.ScrollIntoView(dropTarget.Items[dropTarget.Items.IndexOf(dropData)]);
                    }
                }
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] fileNames = e.Data.GetData(DataFormats.FileDrop) as string[];
                if (fileNames != null)
                {
                    ListView dropTarget = sender as ListView;

                    if (!(dropTarget.ItemsSource is Category))
                    {
                        foreach (String fileName in fileNames)
                        {
                            CairoLogger.Instance.Debug(fileName);

                            if (Shell.Exists(fileName))
                            {
                                ApplicationInfo customApp = AppGrabber.PathToApp(fileName, false, false);
                                if (!object.ReferenceEquals(customApp, null))
                                {
                                    (dropTarget.ItemsSource as IList <ApplicationInfo>).Add(customApp);

                                    if (dropTarget.Items.Contains(customApp))
                                    {
                                        dropTarget.ScrollIntoView(dropTarget.Items[dropTarget.Items.IndexOf(customApp)]);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            sourceView = null;
            isDragging = false;
        }