private List <StartupEntry> GetAppsFromDirectory(StartupLocation location)
        {
            List <StartupEntry> startupApps     = new List <StartupEntry>();
            List <string>       disallowedItems = GetDisallowedItems(location);
            string locationExpanded             = Environment.ExpandEnvironmentVariables(location.Location);

            try
            {
                if (Shell.Exists(locationExpanded))
                {
                    SystemDirectory directory = new SystemDirectory(locationExpanded, Dispatcher.CurrentDispatcher, false);

                    foreach (SystemFile startupFile in directory.Files)
                    {
                        // only add items that are not disabled
                        if (!disallowedItems.Contains(startupFile.Name))
                        {
                            startupApps.Add(new StartupEntry
                            {
                                Location = location,
                                Path     = startupFile.FullName
                            });
                        }
                    }

                    directory.Dispose();
                }
            }
            catch
            {
                CairoLogger.Instance.Warning($"StartupRunner: Unable to load startup items from directory {location}");
            }

            return(startupApps);
        }
        public bool AddLocation(string path)
        {
            if (CanAdd(path))
            {
                SystemDirectory dir = new SystemDirectory(path, Dispatcher.CurrentDispatcher);
                StackLocations.Add(dir);

                return(true);
            }

            return(false);
        }
        public bool SetFilePath(string filePath, SystemDirectory parentDirectory)
        {
            if (Interop.Shell.Exists(filePath))
            {
                FullName = filePath;

                ParentDirectory = parentDirectory;
                OnPropertyChanged("ParentDirecrory");

                return(true);
            }
            return(false);
        }
        public bool SetFilePath(string filePath, SystemDirectory parentDirectory)
        {
            if (ShellHelper.Exists(filePath))
            {
                FullName = filePath;
                InteractiveRenameRequested = false;

                ParentDirectory = parentDirectory;
                OnPropertyChanged("ParentDirectory");

                return(true);
            }
            return(false);
        }
        public static bool AddLocation(string path)
        {
            if (Directory.Exists(path))
            {
                SystemDirectory dir = new SystemDirectory(path, Dispatcher.CurrentDispatcher);

                if (!StackLocations.Contains(dir))
                {
                    StackLocations.Add(dir);
                    return(true);
                }
            }

            return(false);
        }
        private static void deserializeStacks()
        {
            if (Interop.Shell.Exists(stackConfigFile))
            {
                System.Xml.XmlReader reader        = System.Xml.XmlReader.Create(stackConfigFile);
                List <String>        locationPaths = serializer.Deserialize(reader) as List <String>;
                foreach (String path in locationPaths)
                {
                    StacksManager.AddLocation(path);
                }
                reader.Close();
            }
            else
            {
                // Add some default folders on FirstRun

                // Check for Documents Folder
                String myDocsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Documents);
                if (Directory.Exists(myDocsPath))
                {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(myDocsSysDir))
                    {
                        StackLocations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                String downloadsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Downloads);
                if (Directory.Exists(downloadsPath))
                {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(downloadsSysDir))
                    {
                        StackLocations.Add(downloadsSysDir);
                    }
                }

                // save
                serializeStacks();
            }
        }
        public ShellContextMenu(SystemDirectory directory, FolderItemSelectAction folderItemSelected)
        {
            lock (Shell.ComLock)
            {
                CreateHandle(new CreateParams());
                this.directory = directory;
                folder         = directory.FullName;

                parent            = getParentDir(folder);
                parentShellFolder = getParentShellFolder(folder);
                folderPidl        = pathToFullPidl(folder);
                folderRelPidl     = pathToRelPidl(folder);
                x = Cursor.Position.X;
                y = Cursor.Position.Y;

                this.folderItemSelected = folderItemSelected;

                ShowFolderMenu();
            }
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the SystemFile class.
 /// </summary>
 /// <param name="filePath">The file path of the file in question.</param>
 /// <param name="parentDirectory">The SystemDirectory that contains this SystemFile.</param>
 public SystemFile(string filePath, SystemDirectory parentDirectory)
 {
     SetFilePath(filePath, parentDirectory);
 }
 public void RemoveLocation(SystemDirectory directory)
 {
     directory.Dispose();
     StackLocations.Remove(directory);
 }