public void Navigate(DroidExplorer.Core.IO.LinuxDirectoryInfo path) { if (NavigateThread != null && NavigateThread.IsAlive) { try { NavigateThread.Abort( ); } catch (ThreadAbortException taex) { } } NavigateThread = new Thread(new ParameterizedThreadStart(delegate(object state) { if (state is DroidExplorer.Core.IO.LinuxDirectoryInfo) { DroidExplorer.Core.IO.LinuxDirectoryInfo dir = state as DroidExplorer.Core.IO.LinuxDirectoryInfo; PrivateNavigate(dir); } })); NavigateThread.Start(path); }
/// <summary> /// Executes the specified plugin host. /// </summary> /// <param name="pluginHost">The plugin host.</param> /// <param name="currentDirectory">The current directory.</param> /// <param name="args">The args.</param> public override void Execute(IPluginHost pluginHost, DroidExplorer.Core.IO.LinuxDirectoryInfo currentDirectory, string[] args) { if (PortManagerWindow == null) { PortManagerWindow = new PortManagerForm(pluginHost); } if (pluginHost != null && pluginHost.GetHostWindow( ) != null) { if (!this.PortManagerWindow.Visible) { PortManagerWindow.Show(pluginHost.GetHostWindow( )); } } else { PortManagerWindow.ShowDialog( ); }; }
public override void Execute(IPluginHost pluginHost, DroidExplorer.Core.IO.LinuxDirectoryInfo currentDirectory, string[] args) { string backupPath = System.IO.Path.Combine(FolderManagement.TempFolder, "Backup"); System.IO.DirectoryInfo appdir = pluginHost.CommandRunner.PullDirectory(CommandRunner.APP_PUBLIC_PATH, backupPath); System.IO.DirectoryInfo appdir2 = pluginHost.CommandRunner.PullDirectory(CommandRunner.APP_SD_PUBLIC_PATH, backupPath); System.IO.DirectoryInfo pappdir = pluginHost.CommandRunner.PullDirectory(CommandRunner.APP_PRIVATE_PATH, backupPath); System.IO.DirectoryInfo pappdir2 = pluginHost.CommandRunner.PullDirectory(CommandRunner.APP_SD_PRIVATE_PATH, backupPath); FastZip zip = new FastZip( ); string path = Path.Combine(System.IO.Path.GetDirectoryName(this.GetType( ).Assembly.Location), "AppBackups"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } zip.CreateZip(System.IO.Path.Combine(path, string.Format(CultureInfo.InvariantCulture, "AB{0}.zip", DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture))), backupPath, true, string.Empty); }
private void PrivateNavigate(DroidExplorer.Core.IO.LinuxDirectoryInfo path) { this.CurrentPath = path; string pathName = DroidExplorer.Core.IO.Path.GetDirectoryName(path.FullName); if (string.IsNullOrEmpty(pathName)) { pathName = CommandRunner.Instance.GetSerialNumber( ); } if (this.InvokeRequired) { this.Invoke(new GenericDelegate(this.files.Items.Clear)); this.Invoke(new SetComboBoxExDisplayValueDelegate(this.SetComboBoxExDisplayValue), this.selectedPath, pathName); } else { this.files.Items.Clear( ); SetComboBoxExDisplayValue(this.selectedPath, pathName); } List <DroidExplorer.Core.IO.FileSystemInfo> fsis = CommandRunner.Instance.GetDirectoryContents(path.FullName); foreach (var item in fsis) { FileSystemInfoListViewItem lvi = new FileSystemInfoListViewItem(item); if ((item.IsDirectory && !item.IsPipe && !item.IsSocket) || (IsFilterMatch(item, SelectedFilter) && !item.IsPipe && !item.IsSocket)) { if (!item.IsDirectory && !item.IsExecutable) { string ext = System.IO.Path.GetExtension(lvi.FileSystemInfo.Name); string keyName = ext.ToLower( ); if (keyName.StartsWith("/")) { keyName = keyName.Substring(1); } keyName = keyName.Replace("/", "."); if (!string.IsNullOrEmpty(ext)) { if (string.Compare(ext, ".apk", true) == 0) { AaptBrandingCommandResult result = CommandRunner.Instance.GetApkInformation(item.FullPath); lvi = new ApkFileSystemInfoListViewItem(item, result); keyName = lvi.FileSystemInfo.FullPath; if (keyName.StartsWith("/")) { keyName = keyName.Substring(1); } keyName = keyName.Replace("/", "."); if (!SystemImageListHost.Instance.SystemIcons.ContainsKey(keyName)) { // get apk and extract the app icon Image img = CommandRunner.Instance.GetLocalApkIconImage(result.LocalApk); if (img == null) { img = DroidExplorer.Resources.Images.package32; } else { using (System.IO.MemoryStream stream = new System.IO.MemoryStream( )) { string lpath = System.IO.Path.GetDirectoryName(this.GetType( ).Assembly.Location); string fileName = System.IO.Path.Combine(System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.APK_IMAGE_CACHE), string.Format("{0}.png", keyName)); img.Save(stream, ImageFormat.Png); stream.Position = 0; using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { byte[] buffer = new byte[2048]; int readBytes = 0; while ((readBytes = stream.Read(buffer, 0, buffer.Length)) != 0) { fs.Write(buffer, 0, readBytes); } } } } SystemImageListHost.Instance.AddFileTypeImage(keyName, img, img); } if (this.InvokeRequired) { this.Invoke(new SetListViewItemImageIndexDelegate(SetListViewItemImageIndex), lvi, SystemImageListHost.Instance.SystemIcons[keyName]); } else { SetListViewItemImageIndex(lvi, SystemImageListHost.Instance.SystemIcons[keyName]); } } else { if (!SystemImageListHost.Instance.SystemIcons.ContainsKey(ext.ToLower( ))) // add index and icon { Image sico; Image lico; if (this.InvokeRequired) { int iconIndex = (int)this.Invoke(new GetSystemIconIndexDelegate(GetSystemIconIndex), new object[] { SystemImageListHost.Instance.SmallSystemImageList, item.Name }); sico = (Image)this.Invoke(new GetSystemBitmapDelegate(GetSystemBitmap), new object[] { SystemImageListHost.Instance.SmallSystemImageList, iconIndex }); lico = (Image)this.Invoke(new GetSystemBitmapDelegate(GetSystemBitmap), new object[] { SystemImageListHost.Instance.LargeSystemImageList, iconIndex }); } else { int iconIndex = SystemImageListHost.Instance.SmallSystemImageList.IconIndex(item.Name, false); sico = GetSystemBitmap(SystemImageListHost.Instance.SmallSystemImageList, iconIndex); lico = GetSystemBitmap(SystemImageListHost.Instance.LargeSystemImageList, iconIndex); } SystemImageListHost.Instance.AddFileTypeImage(ext.ToLower( ), sico, lico); } } if (this.InvokeRequired) { this.Invoke(new SetListViewItemImageIndexDelegate(this.SetListViewItemImageIndex), new object[] { lvi, SystemImageListHost.Instance.SystemIcons[keyName] }); } else { SetListViewItemImageIndex(lvi, SystemImageListHost.Instance.SystemIcons[keyName]); } } } if (this.InvokeRequired) { this.Invoke(new AddListViewItemDelegate(AddListViewItem), this.files, lvi); } else { AddListViewItem(this.files, lvi); } } } if (this.InvokeRequired) { this.Invoke(new AutoResizeColumnsDelegate(AutoResizeColumns), this.files, ColumnHeaderAutoResizeStyle.ColumnContent); } else { AutoResizeColumns(this.files, ColumnHeaderAutoResizeStyle.ColumnContent); } }
private void NavigateToPath( DroidExplorer.Core.IO.LinuxDirectoryInfo path, bool addHistory ) { if ( !navigating ) { if ( path.FullName.StartsWith ( "./" ) ) { path = new DroidExplorer.Core.IO.LinuxDirectoryInfo ( path.FullName.Substring ( 1 ) ); } //directoryTree.ExpandToPath ( path.FullName ); DirectoryTreeNode dtn = FindNodeFromPath ( path ); if ( dtn != null ) { navigating = true; PluginLoader.CurrentPath = path; if ( InvokeRequired ) { Invoke ( ( (Action)( ( ) => { directoryTree.SelectedNode = dtn; } ) ) ); } else { directoryTree.SelectedNode = dtn; } this.breadcrumbBar.ViewMode = BreadcrumbBar.ViewModes.Nodes; this.breadcrumbBar.Nodes.Clear ( ); string name = DroidExplorer.Core.IO.Path.GetDirectoryName ( path.FullName ); string device = KnownDeviceManager.Instance.GetDeviceFriendlyName ( string.IsNullOrEmpty ( CommandRunner.Instance.DefaultDevice ) ? CommandRunner.Instance.GetSerialNumber ( ) : CommandRunner.Instance.DefaultDevice ); Image itemImage = null; if ( string.IsNullOrEmpty ( name ) ) { itemImage = DroidExplorer.Resources.Images.device_16x16; name = device; } this.breadcrumbBar.Nodes.Add ( new BreadcrumbBarNode ( device, string.Empty, delegate ( object sender, EventArgs e ) { BreadcrumbBarNode item = sender as BreadcrumbBarNode; }, this.breadcrumbBar.PathSeparator ) ); StringBuilder tpath = new StringBuilder ( ); foreach ( string s in path.FullName.Split ( new string[] { this.breadcrumbBar.PathSeparator }, StringSplitOptions.RemoveEmptyEntries ) ) { tpath.AppendFormat ( "{0}{1}", s, this.breadcrumbBar.PathSeparator ); this.breadcrumbBar.Nodes.Add ( new BreadcrumbBarNode ( s, s, delegate ( object sender, EventArgs e ) { BreadcrumbBarNode item = sender as BreadcrumbBarNode; }, tpath ) ); } if ( addHistory ) { if ( !explorerNavigation.History.ContainsKey ( path.FullName ) ) { this.explorerNavigation.AddHistory ( new ExplorerNavigationHistoryItem ( name, path.FullName, itemImage, delegate ( object sender, EventArgs e ) { ExplorerNavigationHistoryItem item = ( sender as ExplorerNavigationHistoryItem ); if ( item.Tag is DroidExplorer.Core.IO.LinuxDirectoryInfo ) { NavigateToPath ( item.Tag as DroidExplorer.Core.IO.LinuxDirectoryInfo, false ); } }, path ), true ); } else { this.explorerNavigation.HistoryGo ( this.explorerNavigation.History.IndexOf ( path.FullName ) ); } } //this.breadcrumbBar.FullPath = string.Format ( "({0}){1}", device, path.FullName ); this.breadcrumbBar.Root.Image = DroidExplorer.Resources.Images.device_16x16; //dtn.EnsureVisible ( ); List<DroidExplorer.Core.IO.FileSystemInfo> fsiList = dtn.OnAfterSelect ( CommandRunner.Instance ); folderUpToolStripButton.Enabled = path.Parent != null; CurrentDirectory = new DroidExplorer.Core.IO.LinuxDirectoryInfo ( dtn.LinuxPath ); if ( filesThread != null && ( filesThread.IsAlive || filesThread.ThreadState == ThreadState.Running ) ) { filesThread.Abort ( ); } filesThread = new Thread ( new ParameterizedThreadStart ( ThreadedBuildListViewItems ) ); filesThread.Start ( fsiList ); if ( !dtn.IsExpanded ) { dtn.Expand ( ); } } else { TaskDialog.MessageBox ( "Address Bar", string.Format ( CultureInfo.InvariantCulture, Resources.Strings.AddressBarPathNotFoundMessage, path.FullName ), string.Empty, TaskDialogButtons.OK, SysIcons.Error ); this.breadcrumbBar.ViewMode = BreadcrumbBar.ViewModes.Text; } navigating = false; } }