Changed overlays to use TortoiseOverlays. Added register/unregister functionality...
[pithos-ms-client] / trunk / Pithos.ShellExtensions / FileContext.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel.Composition;
4 using System.Diagnostics;
5 using System.IO;
6 using System.Linq;
7 using System.Text;
8 using Pithos.Interfaces;
9
10 namespace Pithos.ShellExtensions
11 {
12     [Export]
13     public class FileContext
14     {
15         [Import]
16         public IPithosSettings Settings { get; set; }
17
18         [Import]
19         public IStatusChecker StatusChecker { get; set; }
20
21         public string PithosPath { get { return Settings.PithosPath.ToLower(); } }
22
23
24         public bool IsManaged
25         {
26             get
27             {
28                 Trace.Write(String.Format("Managed path is {0}\r\n Current Path is {1}", PithosPath, CurrentFile));
29                 return CurrentFolder.StartsWith(PithosPath, true, null);
30             }
31         }
32
33         public bool IsFolder { get; set; }
34         private string _currentFolder;
35         public string CurrentFolder
36         {
37             get { return _currentFolder; }
38             set
39             {
40                 _currentFolder = value.ToLower();
41                 IsFolder = true;
42                 _currentFile = _currentFolder;
43             }
44         }
45
46         private string _currentFile;
47         public string CurrentFile
48         {
49             get { return _currentFile; }
50             set
51             {
52                 _currentFile = value.ToLower();
53                 Trace.Write(String.Format("File is {0}", _currentFile));
54                 if (Directory.Exists(_currentFile))
55                 {
56                     _currentFolder = _currentFile;
57                     IsFolder = true;
58                 }
59                 else
60                 {
61                     _currentFolder = Path.GetDirectoryName(_currentFile);
62                     IsFolder = false;
63                 }
64
65             }
66         }
67     }
68
69 }