Inheritance: System.Windows.DependencyObject
        public AppGrabberUI(AppGrabber appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            Height = SystemParameters.MaximizedPrimaryScreenHeight - 100;
        }
        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);
                    }
                }
            }
        }
Exemple #3
0
        public AppGrabberUI(AppGrabber appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();


            // Grab the Programs
            List <ApplicationInfo> apps = appGrabber.ProgramList;

            // Now to add them to the list on the AppGrabber
            // Create ObservableCollections to bind to the ListViews

            ObservableCollection <ApplicationInfo> installedAppsCollection = new ObservableCollection <ApplicationInfo>();

            programsMenuAppsCollection       = new ObservableCollection <ApplicationInfo>(appGrabber.CategoryList.FlatList.ToList());
            InstalledAppsView.ItemsSource    = installedAppsCollection;
            ProgramsMenuAppsView.ItemsSource = programsMenuAppsCollection;
            // Need to use an event handler to remove Apps from categories when moved to the "Installed Applications" listing
            programsMenuAppsCollection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(programsMenuAppsCollection_CollectionChanged);

            // Iterate thru the apps, creating ApplicationInfoPanels and
            // add them to the installedAppsCollection
            foreach (ApplicationInfo app in apps)
            {
                if (!programsMenuAppsCollection.Contains(app))
                {
                    installedAppsCollection.Add(app);
                }
            }
            AppViewSorter.Sort(installedAppsCollection, "Name");
            AppViewSorter.Sort(programsMenuAppsCollection, "Name");
            GC.Collect();
        }
Exemple #4
0
        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);
                }
            }
        }
        public AppGrabberUI(AppGrabber appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            // Grab the Programs
            List<ApplicationInfo> apps = appGrabber.ProgramList;

            // Now to add them to the list on the AppGrabber
            // Create ObservableCollections to bind to the ListViews

            ObservableCollection<ApplicationInfo> installedAppsCollection = new ObservableCollection<ApplicationInfo>();
            programsMenuAppsCollection = new ObservableCollection<ApplicationInfo>(appGrabber.CategoryList.FlatList.ToList());
            InstalledAppsView.ItemsSource = installedAppsCollection;
            ProgramsMenuAppsView.ItemsSource = programsMenuAppsCollection;
            // Need to use an event handler to remove Apps from categories when moved to the "Installed Applications" listing
            programsMenuAppsCollection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(programsMenuAppsCollection_CollectionChanged);

            // Iterate thru the apps, creating ApplicationInfoPanels and
            // add them to the installedAppsCollection
            foreach (ApplicationInfo app in apps)
            {
                if (!programsMenuAppsCollection.Contains(app)) {
                    installedAppsCollection.Add(app);
                }
            }
            AppViewSorter.Sort(installedAppsCollection, "Name");
            AppViewSorter.Sort (programsMenuAppsCollection, "Name");
            GC.Collect ();
        }
        public AppGrabberUI_Page2(AppGrabber appGrabber, ObservableCollection<ApplicationInfo> selectedApps)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            // Grab the Programs
            CategoryList catList = appGrabber.CategoryList;

            // Get the Uncategorized category - create it if it doesn't exist.
            Category uncat = catList.GetCategory("Uncategorized");
            if (uncat == null) {
                uncat = new Category("Uncategorized");
                uncat.ShowInMenu = false;
                catList.Add(uncat);
            }

            // Get the Quick Launch category - create it if it doesn't exist.
            Category quicklaunch = catList.GetCategory("Quick Launch");
            if (quicklaunch == null) {
                quicklaunch = new Category("Quick Launch");
                quicklaunch.ShowInMenu = false;
                catList.Add(quicklaunch);
            }
            // Add Apps to uncat if they haven't been added to a category yet.
            foreach (ApplicationInfo app in selectedApps) {
                if (app.Category == null) {
                    uncat.Add(app);
                }
            }

            categoryView.ItemsSource = catList;
        }
        public AppGrabberUI(AppGrabber appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            Height    = (SystemParameters.MaximizedPrimaryScreenHeight / Shell.DpiScaleAdjustment) - 100;
            MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight / Shell.DpiScaleAdjustment;
        }
Exemple #8
0
        public Taskbar()
        {
            InitializeComponent();
            // Set custom theme if selected
            string theme = Properties.Settings.Default.CairoTheme;
            if (theme != "Default")
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + theme)) this.Resources.MergedDictionaries.Add((ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme)));

            appGrabber = AppGrabber.AppGrabber.Instance;
            this.quickLaunchList.ItemsSource = appGrabber.QuickLaunch;
            this.TaskbarBorder.MaxWidth = AppBarHelper.PrimaryMonitorSize.Width - 36;
            this.grdTaskbar.Width = AppBarHelper.PrimaryMonitorSize.Width;
        }
 public Taskbar()
 {
     InitializeComponent();
     if (Properties.Settings.Default.MenuBarWhite)
     {
         ResourceDictionary CairoDictionary = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + "CairoStyles_alt.xaml"));
         this.Resources.MergedDictionaries[0] = CairoDictionary;
     }
     appGrabber = AppGrabber.AppGrabber.Instance;
     this.quickLaunchList.ItemsSource = appGrabber.QuickLaunch;
     this.TaskbarBorder.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth - 36;
     // Dodgy - set to top of task bar.
     this.Top = SystemParameters.WorkArea.Bottom - this.Height;
 }
Exemple #10
0
        public Taskbar()
        {
            InitializeComponent();
            // Sets the Theme for Cairo
            string theme = Properties.Settings.Default.CairoTheme;

            if (theme != "Cairo.xaml")
            {
                ResourceDictionary CairoDictionary = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme));
                this.Resources.MergedDictionaries[0] = CairoDictionary;
            }
            appGrabber = AppGrabber.AppGrabber.Instance;
            this.quickLaunchList.ItemsSource = appGrabber.QuickLaunch;
            this.TaskbarBorder.MaxWidth      = SystemParameters.MaximizedPrimaryScreenWidth - 36;
            // Dodgy - set to top of task bar.
            this.Top = SystemParameters.WorkArea.Bottom - this.Height;
        }
Exemple #11
0
        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);
                    }
                }
            }
        }
        public AppGrabberUI_Page2(AppGrabber appGrabber, ObservableCollection <ApplicationInfo> selectedApps)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();


            // Grab the Programs
            CategoryList catList = appGrabber.CategoryList;

            // Get the Uncategorized category - create it if it doesn't exist.
            Category uncat = catList.GetCategory("Uncategorized");

            if (uncat == null)
            {
                uncat = new Category("Uncategorized");
                catList.Add(uncat);
            }

            // Get the Quick Launch category - create it if it doesn't exist.
            Category quicklaunch = catList.GetCategory("Quick Launch");

            if (quicklaunch == null)
            {
                quicklaunch            = new Category("Quick Launch");
                quicklaunch.ShowInMenu = false;
                catList.Add(quicklaunch);
            }
            // Add Apps to uncat if they haven't been added to a category yet.
            foreach (ApplicationInfo app in selectedApps)
            {
                if (app.Category == null)
                {
                    uncat.Add(app);
                }
            }

            categoryView.ItemsSource = catList;
        }
Exemple #13
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;
        }