public override void OnApplyTemplate() { base.OnApplyTemplate(); IEventAggregator _events = new EventAggregator(); IWindowManager _windowManager = new AppWindowManager(); IProfile _exProfile = new FileSystemInfoExProfile(_events, _windowManager); IProfile _ioProfile = new FileSystemInfoProfile(_events); IProfile[] _profiles = new IProfile[] { _exProfile, _ioProfile }; IEntryModel[] _rootDirs = new IEntryModel[] { AsyncUtils.RunSync(() => _exProfile.ParseAsync("")) }; explorer.WindowManager = _windowManager; explorer.ViewModel.Initializer = new ScriptCommandInitializer() { OnModelCreated = ScriptCommands.Run("{OnModelCreated}"), OnViewAttached = ScriptCommands.Run("{OnViewAttached}"), RootModels = _rootDirs, WindowManager = _windowManager, StartupParameters = new ParameterDic() { { "Profiles", _profiles }, { "RootDirectories", _rootDirs }, { "GlobalEvents", _events }, { "WindowManager", _windowManager }, { "StartupPath", "" }, { "ViewMode", "List" }, { "ItemSize", 16 }, { "EnableDrag", true }, { "EnableDrop", true }, { "FileListNewWindowCommand", NullScriptCommand.Instance }, //Disable NewWindow Command. { "EnableMultiSelect", true }, { "ShowToolbar", true }, { "ShowGridHeader", true }, { "OnModelCreated", IOInitializeHelpers.Explorer_Initialize_Default }, { "OnViewAttached", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } } }; cbCommand.ItemsSource = ScriptCommandDictionary.CommandList; }
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(); }