public AddBookmarksViewModel(BookmarkProfile bProfile, IWindowManager windowManager, IEventAggregator events)
        {
            Profile = bProfile;
            _events = events;
            events.Subscribe(this);


            AddBookmarkCommand           = new RelayCommand(e => AddBookmark());
            GotoBookmarkDirectoryCommand = new RelayCommand(e => GotoBookmarkDirectory());
            //CurrentBookmarkDirectory = Profile.RootModel;
        }
Esempio n. 2
0
        private void setProfiles(IProfile[] profiles)
        {
            _profiles = profiles;
            if (profiles != null && profiles.Length > 0)
            {
                (Selection as ITreeRootSelector <IBreadcrumbItemViewModel, IEntryModel>)
                .Comparers     = profiles.Select(p => p.HierarchyComparer);
                SuggestSources = profiles.Select(p => p.SuggestSource);
            }

            BookmarkProfile bProfile = profiles.FirstOrDefault(p => p is BookmarkProfile) as BookmarkProfile;

            if (bProfile != null)
            {
                AddBookmarks = new AddBookmarksViewModel(bProfile, null, _events);
            }
        }
Esempio n. 3
0
        public AppViewModel(IEventAggregator events, IWindowManager windowManager)
        {
            //FileExplorer.Models.Bookmark.BookmarkSerializeTest.Test();
            _windowManager = windowManager;
            _events        = events;

            _events.Subscribe(this);

            _profile   = new FileSystemInfoProfile(_events);
            _profileEx = new FileSystemInfoExProfile(_events, _windowManager, new FileExplorer.Models.SevenZipSharp.SzsProfile(_events));

            Func <string> loginSkyDrive = () =>
            {
                var login = new SkyDriveLogin(AuthorizationKeys.SkyDrive_Client_Id);
                if (_windowManager.ShowDialog(new LoginViewModel(login)).Value)
                {
                    return(login.AuthCode);
                }
                return(null);
            };

            if (AuthorizationKeys.SkyDrive_Client_Secret != null)
            {
                _profileSkyDrive = new SkyDriveProfile(_events, AuthorizationKeys.SkyDrive_Client_Id, loginSkyDrive, skyDriveAliasMask);
            }


            Func <UserLogin> loginDropBox = () =>
            {
                var login = new DropBoxLogin(AuthorizationKeys.DropBox_Client_Id,
                                             AuthorizationKeys.DropBox_Client_Secret);
                if (_windowManager.ShowDialog(new LoginViewModel(login)).Value)
                {
                    return(login.AccessToken);
                }
                return(null);
            };

            if (AuthorizationKeys.DropBox_Client_Secret != null)
            {
                _profileDropBox = new DropBoxProfile(_events,
                                                     AuthorizationKeys.DropBox_Client_Id,
                                                     AuthorizationKeys.DropBox_Client_Secret,
                                                     loginDropBox);
            }

            if (System.IO.File.Exists("gapi_client_secret.json"))
            {
                using (var gapi_secret_stream = System.IO.File.OpenRead("gapi_client_secret.json")) //For demo only.
                {
                    _profileGoogleDrive = new GoogleDriveProfile(_events, gapi_secret_stream);
                }
            }


            string appDataPath = Environment.ExpandEnvironmentVariables("%AppData%\\FileExplorer3");

            System.IO.Directory.CreateDirectory(appDataPath);
            string bookmarkPath = Path.Combine(appDataPath, "Bookmarks.xml");

            _profileBm = new BookmarkProfile(_profileEx as IDiskProfile, bookmarkPath,
                                             new IProfile[] { _profileEx, _profileSkyDrive, _profileDropBox, _profileGoogleDrive });


            RootModels.Add((_profileBm as BookmarkProfile).RootModel);
            RootModels.Add(AsyncUtils.RunSync(() => _profileEx.ParseAsync(System.IO.DirectoryInfoEx.DesktopDirectory.FullName)));

            _profiles = new IProfile[] {
                _profileBm, _profileEx, _profileSkyDrive, _profileDropBox, _profileGoogleDrive
            }.Where(p => p != null).ToArray();
        }