// // This project is open source. Released under the XYZ license // using Microsoft.Win32; namespace Pithos.ShellExtensions { using System; using Pithos.Interfaces; using System.ComponentModel.Composition; using System.Diagnostics; using System.IO; [Export] public class FileContext { [Import] public IPithosSettings Settings { get; set; } [Import] public IStatusChecker StatusChecker { get; set; } public string PithosPath { get { return Settings.PithosPath.ToLower(); } } public FileContext() { } public bool IsManaged { get { Debug.WriteLine( String.Format("Managed path is {0}\r\n Current Path is {1}", PithosPath, CurrentFile),LogCategories.Shell); return CurrentFolder.StartsWith(PithosPath, true, null); } } public bool IsFolder { get; set; } private string _currentFolder; public string CurrentFolder { get { return _currentFolder; } set { _currentFolder = value.ToLower(); IsFolder = true; _currentFile = _currentFolder; } } private string _currentFile; public string CurrentFile { get { return _currentFile; } set { _currentFile = value.ToLower(); Debug.WriteLine(String.Format("File is {0}", _currentFile), LogCategories.Shell); if (Directory.Exists(_currentFile)) { _currentFolder = _currentFile; IsFolder = true; } else { _currentFolder = Path.GetDirectoryName(_currentFile); IsFolder = false; } } } } }