Statistics
| Branch: | Revision:

root / trunk / Pithos.ShellExtensions / FileContext.cs @ 5bcf6d70

History | View | Annotate | Download (2.1 kB)

1
// <copyright file="IoC.cs" company="GRNet">
2
// This project is open source. Released under the XYZ license
3
// </copyright>
4

    
5
using Microsoft.Win32;
6

    
7
namespace Pithos.ShellExtensions
8
{
9
    using System;
10
    using Pithos.Interfaces;
11
    using System.ComponentModel.Composition;
12
    using System.Diagnostics;
13
    using System.IO;
14

    
15
    [Export]
16
    public class FileContext
17
    {
18
        [Import]
19
        public IPithosSettings Settings { get; set; }
20

    
21
        [Import]
22
        public IStatusChecker StatusChecker { get; set; }
23

    
24
        public string PithosPath { get { return Settings.PithosPath.ToLower(); } }
25

    
26
        public FileContext()
27
        {
28
           /* if (Process.GetProcessesByName("Pithos.Client.WPF").Length == 0)
29
            {
30
                var appPath = (string)Registry.LocalMachine.GetValue(@"Software\Pithos\AppPath");
31
                Process.Start(appPath);
32
            }*/
33
        }
34

    
35
        public bool IsManaged
36
        {
37
            get
38
            {
39
                Trace.Write(String.Format("Managed path is {0}\r\n Current Path is {1}", PithosPath, CurrentFile));
40
                return CurrentFolder.StartsWith(PithosPath, true, null);
41
            }
42
        }
43

    
44
        public bool IsFolder { get; set; }
45
        private string _currentFolder;
46
        public string CurrentFolder
47
        {
48
            get { return _currentFolder; }
49
            set
50
            {
51
                _currentFolder = value.ToLower();
52
                IsFolder = true;
53
                _currentFile = _currentFolder;
54
            }
55
        }
56

    
57
        private string _currentFile;
58
        public string CurrentFile
59
        {
60
            get { return _currentFile; }
61
            set
62
            {
63
                _currentFile = value.ToLower();
64
                Trace.Write(String.Format("File is {0}", _currentFile));
65
                if (Directory.Exists(_currentFile))
66
                {
67
                    _currentFolder = _currentFile;
68
                    IsFolder = true;
69
                }
70
                else
71
                {
72
                    _currentFolder = Path.GetDirectoryName(_currentFile);
73
                    IsFolder = false;
74
                }
75

    
76
            }
77
        }
78
    }
79

    
80
}