private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            string filter = "Programs and shortcuts|";

            foreach (string ext in AppGrabberService.ExecutableExtensions)
            {
                filter += $"*{ext};";
            }

            filter = filter.Substring(0, filter.Length - 2);

            using (OpenFileDialog dlg = new OpenFileDialog
            {
                Filter = filter
            })
            {
                if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK && ShellHelper.Exists(dlg.FileName))
                {
                    ApplicationInfo customApp = AppGrabberService.PathToApp(dlg.FileName, true, true);
                    if (!ReferenceEquals(customApp, null))
                    {
                        if (!programsMenuAppsCollection.Contains(customApp) && !(InstalledAppsView.ItemsSource as ObservableCollection <ApplicationInfo>).Contains(customApp))
                        {
                            programsMenuAppsCollection.Add(customApp);
                        }
                        else
                        {
                            // disallow adding a duplicate
                            ShellLogger.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target);
                        }
                    }
                }
            }
        }
示例#2
0
        public AppGrabberUI(AppGrabberService appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            Height    = (SystemParameters.MaximizedPrimaryScreenHeight / DpiHelper.DpiScaleAdjustment) - 100;
            MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight / DpiHelper.DpiScaleAdjustment;
        }
示例#3
0
        public TaskCategoryProvider(AppGrabberService appGrabber)
        {
            _appGrabber = appGrabber;

            foreach (Category category in _appGrabber.CategoryList)
            {
                category.PropertyChanged += Category_PropertyChanged;
            }
        }
示例#4
0
        private void ListView_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ApplicationInfo)))
            {
                ShellLogger.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
                        }
                        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)
                        {
                            ShellLogger.Debug(fileName);

                            if (ShellHelper.Exists(fileName))
                            {
                                ApplicationInfo customApp = AppGrabberService.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;
        }
示例#5
0
 public QuickLaunchManager(AppGrabberService appGrabber)
 {
     _appGrabber = appGrabber;
 }