private void btnBrowse_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Programs and shortcuts|"; foreach (string ext in appGrabber.ExecutableExtensions) { dlg.Filter += "*" + ext + ";"; } dlg.Filter = dlg.Filter.Substring(0, dlg.Filter.Length - 2); System.Windows.Forms.DialogResult result; try { result = dlg.ShowDialog(); } catch { // show retro dialog if the better one fails to load dlg.AutoUpgradeEnabled = false; result = dlg.ShowDialog(); } if (result == System.Windows.Forms.DialogResult.OK && Interop.Shell.Exists(dlg.FileName)) { ApplicationInfo customApp = appGrabber.PathToApp(dlg.FileName, true); if (!object.ReferenceEquals(customApp, null)) { programsMenuAppsCollection.Add(customApp); } } }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { string filter = "Programs and shortcuts|"; foreach (string ext in AppGrabber.ExecutableExtensions) { filter += "*" + ext + ";"; } filter = filter.Substring(0, filter.Length - 2); string filename; DialogResult result = SupportingClasses.Dialogs.OpenFileDialog(filter, out filename); if (result == System.Windows.Forms.DialogResult.OK && Interop.Shell.Exists(filename)) { ApplicationInfo customApp = AppGrabber.PathToApp(filename, true); if (!ReferenceEquals(customApp, null)) { if (!programsMenuAppsCollection.Contains(customApp) && !(InstalledAppsView.ItemsSource as ObservableCollection <ApplicationInfo>).Contains(customApp)) { programsMenuAppsCollection.Add(customApp); } else { // disallow adding a duplicate CairoLogger.Instance.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target); } } } }
private void Programs_Drop(object sender, DragEventArgs e) { string[] fileNames = e.Data.GetData(DataFormats.FileDrop) as string[]; if (fileNames != null) { int count = 0; foreach (String fileName in fileNames) { if (Shell.Exists(fileName)) { ApplicationInfo customApp = appGrabber.PathToApp(fileName, false); if (!object.ReferenceEquals(customApp, null)) { appGrabber.CategoryList.GetCategory("Uncategorized").Add(customApp); count++; } } } if (count > 0) { appGrabber.Save(); } } }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Programs and shortcuts|"; foreach (string ext in AppGrabber.ExecutableExtensions) { dlg.Filter += "*" + ext + ";"; } dlg.Filter = dlg.Filter.Substring(0, dlg.Filter.Length - 2); System.Windows.Forms.DialogResult result; try { result = dlg.ShowDialog(); } catch { // show retro dialog if the better one fails to load dlg.AutoUpgradeEnabled = false; result = dlg.ShowDialog(); } if (result == System.Windows.Forms.DialogResult.OK && Interop.Shell.Exists(dlg.FileName)) { ApplicationInfo customApp = AppGrabber.PathToApp(dlg.FileName, true); if (!object.ReferenceEquals(customApp, null)) { if (!programsMenuAppsCollection.Contains(customApp) && !(InstalledAppsView.ItemsSource as ObservableCollection <ApplicationInfo>).Contains(customApp)) { programsMenuAppsCollection.Add(customApp); } else { // disallow adding a duplicate CairoLogger.Instance.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target); } } } }
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; }