/// <summary> /// Makes a new directory at the specifed <paramref name="url"/> /// </summary> /// <param name="url"></param> public void MkDir(string url) { FileProcessDialog fpd = new FileProcessDialog(); fpd.lblStatus.Text = string.Format(Locale.GetString("DoingMkdir"), "\n" + url, null); fpd.Show(); Thread MkDirThread = new Thread(delegate() { ActivePanel.FS.CreateDirectory(url); }); MkDirThread.Start(); do /*Application.DoEvents();*/ Xwt {
/// <summary>Load the file in the VE</summary> /// <param name="URL">The URL of the file</param> /// <param name="FS">The filesystem of the file</param> /// <param name="plugin">The VE plugin, which will be used to load this file</param> /// <param name="AllowEdit">Allow editing the file</param> public void LoadFile(string URL, pluginner.IFSPlugin FS, pluginner.IVEPlugin plugin, bool AllowEdit) { //check for external editor try{ if (fcmd.Properties.Settings.Default.UseExternalEditor && AllowEdit || fcmd.Properties.Settings.Default.UseExternalViewer && !AllowEdit && URL.StartsWith("file:")) { CanBeShowed = false; if (AllowEdit) { ExecuteProgram(fcmd.Properties.Settings.Default.ExternalEditor.Replace("$", "\"" + URL)); } else { ExecuteProgram(fcmd.Properties.Settings.Default.ExternalViewer.Replace("$", "\"" + URL)); } return; } } catch (Exception ex) { Xwt.MessageDialog.ShowError(Locale.GetString("CantRunEXE"), ex.Message); CanBeShowed = false; return; } string FiNa4Title = URL.Substring(URL.LastIndexOf(FS.DirSeparator) + 1); IsEditor = AllowEdit; if (AllowEdit) { this.Title = string.Format(Locale.GetString("FCETitle"), FiNa4Title); } else { this.Title = string.Format(Locale.GetString("FCVTitle"), FiNa4Title); } FileProcessDialog ProgressDialog = new FileProcessDialog(); string ProgressInitialText = String.Format(Locale.GetString("FCVELoadingMsg"), URL); ProgressDialog.lblStatus.Text = ProgressInitialText; FS.ProgressChanged += (d) => { ProgressDialog.pbrProgress.Fraction = (d >= 0 && d <= 1) ? d : ProgressDialog.pbrProgress.Fraction; Xwt.Application.MainLoop.DispatchPendingEvents(); }; FS.StatusChanged += (d) => { ProgressDialog.lblStatus.Text = ProgressInitialText + "\n" + d; Xwt.Application.MainLoop.DispatchPendingEvents(); }; ProgressDialog.cmdCancel.Clicked += (o, ea) => { CanBeShowed = false; ProgressDialog.Hide(); return; }; ProgressDialog.Show(); Xwt.Application.MainLoop.DispatchPendingEvents(); if (!CanBeShowed) { return; } Plugin = plugin; Plugin.ReadOnly = !AllowEdit; Plugin.OpenFile(URL, FS); Plugin.ShowToolbar = fcmd.Properties.Settings.Default.VE_ShowToolbar; Plugin.Stylist = s; mnuFormat.SubMenu = Plugin.FormatMenu; bool Mode = AllowEdit; if (!Plugin.CanEdit && AllowEdit) { Xwt.MessageDialog.ShowWarning(String.Format(Locale.GetString("FCVEpluginro1"), Plugin.Name + " " + Plugin.Version), Locale.GetString("FCVEpluginro2")); Mode = false; } FSPlugin = FS; PluginBody = Plugin.Body; SetVEMode(Mode); BuildLayout(); ProgressDialog.Hide(); PluginBody.KeyReleased += (sender, e) => { if (e.Key == Xwt.Key.Escape) { CommandBox.SetFocus(); } if (e.Key == Xwt.Key.q) { this.OnCloseRequested(); } }; }
/// <summary>Load the file in the VE</summary> /// <param name="URL">The URL of the file</param> /// <param name="FS">The filesystem of the file</param> /// <param name="plugin">The VE plugin, which will be used to load this file</param> /// <param name="AllowEdit">Allow editing the file</param> public void LoadFile(string URL, IFSPlugin FS, IVEPlugin plugin, bool AllowEdit) { //check for external editor try{ if (Settings.Default.UseExternalEditor && AllowEdit || Settings.Default.UseExternalViewer && !AllowEdit && URL.StartsWith("file:")){ CanBeShowed = false; if (AllowEdit){ ExecuteProgram(Settings.Default.ExternalEditor.Replace("$", "\"" + URL)); } else{ ExecuteProgram(Settings.Default.ExternalViewer.Replace("$", "\"" + URL)); } return; } } catch (Exception ex) { MessageDialog.ShowError(Localizator.GetString("CantRunEXE"), ex.Message); CanBeShowed = false; return; } FileNameForTitle = URL.Substring(URL.LastIndexOf(FS.DirSeparator, StringComparison.Ordinal) + 1); IsEditor = AllowEdit; if(AllowEdit) Title = string.Format(Localizator.GetString("FCETitle"), FileNameForTitle); else Title = string.Format(Localizator.GetString("FCVTitle"), FileNameForTitle); FileProcessDialog ProgressDialog = new FileProcessDialog(); string ProgressInitialText = String.Format(Localizator.GetString("FCVELoadingMsg"),URL); ProgressDialog.lblStatus.Text = ProgressInitialText; FS.ProgressChanged += d => { ProgressDialog.pbrProgress.Fraction = (d >= 0 && d <= 1) ? d : ProgressDialog.pbrProgress.Fraction; Xwt.Application.MainLoop.DispatchPendingEvents(); }; FS.StatusChanged += d => { ProgressDialog.lblStatus.Text = ProgressInitialText + "\n" + d; Xwt.Application.MainLoop.DispatchPendingEvents(); }; ProgressDialog.cmdCancel.Clicked += (o, ea) => { CanBeShowed = false; ProgressDialog.Close(); }; ProgressDialog.Show(); Xwt.Application.MainLoop.DispatchPendingEvents(); if (!CanBeShowed) return; try { Plugin = plugin; Plugin.ReadOnly = !AllowEdit; Plugin.OpenFile(URL, FS); Plugin.ShowToolbar = Settings.Default.VE_ShowToolbar; Plugin.Stylist = s; mnuFormat.SubMenu = Plugin.FormatMenu; bool Mode = AllowEdit; if (!Plugin.CanEdit && AllowEdit) { MessageDialog.ShowWarning(String.Format(Localizator.GetString("FCVEpluginro1"), Plugin.Name + " " + Plugin.Version), Localizator.GetString("FCVEpluginro2")); Mode = false; } FSPlugin = FS; PluginBody = Plugin.Body; SetVEMode(Mode); } catch (Exception ex) { MessageDialog.ShowWarning(ex.Message); if(PluginBody.GetType() == typeof(Spinner)) { ProgressDialog.Close(); CanBeShowed = false; return;} } BuildLayout(); ProgressDialog.Close(); }
public void Cp() { if (ActivePanel.GetValue<string>(ActivePanel.dfDisplayName) == "..") { return; } foreach (pluginner.ListView2Item selitem in ActivePanel.ListingView.ChoosedRows) { int Progress = 0; string SourceURL = selitem.Data[ActivePanel.dfURL].ToString(); pluginner.IFSPlugin SourceFS = ActivePanel.FS; pluginner.File SourceFile = SourceFS.GetFile(SourceURL, Progress); //check for file existing if (SourceFS.FileExists(SourceURL)) { InputBox ibx = new InputBox(String.Format(Locale.GetString("CopyTo"), SourceFile.Name), PassivePanel.FS.CurrentDirectory + PassivePanel.FS.DirSeparator + SourceFile.Name); if (ibx.ShowDialog(this)) { String DestinationFilePath = ibx.Result; string StatusMask = Locale.GetString("DoingCopy"); ReplaceQuestionDialog.ClickedButton dummy = ReplaceQuestionDialog.ClickedButton.Cancel; AsyncCopy AC = new AsyncCopy(); Thread CpThread = new Thread(delegate() { DoCp(ActivePanel.FS, PassivePanel.FS, SourceFile, DestinationFilePath, ref dummy, AC); }); CpThread.TrySetApartmentState(ApartmentState.STA); FileProcessDialog fpd = new FileProcessDialog(); fpd.InitialLocation = Xwt.WindowLocation.CenterParent; fpd.lblStatus.Text = String.Format(StatusMask, ActivePanel.GetValue<string>(ActivePanel.dfURL), ibx.Result, null); fpd.cmdCancel.Clicked += (object s, EventArgs e) => { CpThread.Abort(); new MsgBox(Locale.GetString("Canceled"), ActivePanel.GetValue<string>(ActivePanel.dfURL), MsgBox.MsgBoxType.Warning); }; AC.ReportMessage = Locale.GetString("CopyStatus"); AC.OnProgress += (msg, proc) => { Xwt.Application.Invoke( delegate { try { fpd.pbrProgress.Fraction = (double)((double)proc / (double)100); fpd.lblStatus.Text = String.Format(StatusMask, ActivePanel.GetValue<string>(ActivePanel.dfURL), ibx.Result, msg); } catch { } } ); }; fpd.Show(); CpThread.Start(); do { Xwt.Application.MainLoop.DispatchPendingEvents(); } while (CpThread.ThreadState == ThreadState.Running); //todo: замер и показ скорости, пауза, запрос отмены, вывод в фоновый поток (кнопка "в фоне"). fpd.Hide(); } continue; } //not a file...maybe directory? if (SourceFS.DirectoryExists(SourceURL))//а вдруг есть такой каталог? { InputBox ibxd = new InputBox(String.Format(Locale.GetString("CopyTo"), SourceFile.Name), PassivePanel.FS.CurrentDirectory + "/" + SourceFile.Name); if (ibxd.ShowDialog()) { String DestinationDirPath = ibxd.Result; //копирование каталога Thread CpDirThread = new Thread(delegate() { DoCpDir(SourceURL, DestinationDirPath, ActivePanel.FS, PassivePanel.FS); }); CpDirThread.TrySetApartmentState(ApartmentState.STA); FileProcessDialog CpDirProgressDialog = new FileProcessDialog(); CpDirProgressDialog.InitialLocation = Xwt.WindowLocation.CenterParent; CpDirProgressDialog.lblStatus.Text = String.Format(Locale.GetString("DoingCopy"), "\n" + ActivePanel.GetValue<string>(ActivePanel.dfURL) + " [" + Locale.GetString("Directory") + "]\n", ibxd.Result, null); CpDirProgressDialog.cmdCancel.Clicked += (object s, EventArgs e) => { CpDirThread.Abort(); new MsgBox(Locale.GetString("Canceled"), ActivePanel.GetValue<string>(ActivePanel.dfURL), MsgBox.MsgBoxType.Warning); }; CpDirProgressDialog.Show(); CpDirThread.Start(); do { Xwt.Application.MainLoop.DispatchPendingEvents(); } while (CpDirThread.ThreadState == ThreadState.Running); //LoadDir(PassivePanel.FSProvider.CurrentDirectory, PassivePanel); //обновление пассивной панели PassivePanel.LoadDir(); CpDirProgressDialog.Hide(); } continue; } //and, if none of those IF blocks has been entered, say that this isn't a real file nor a directory Xwt.MessageDialog.ShowWarning( Locale.GetString("FileNotFound"), ActivePanel.GetValue<string>( ActivePanel.dfURL ) ); continue; } }
/// <summary> /// Removes the specifed file /// </summary> public string Rm(string url) { if (ActivePanel.GetValue<string>(ActivePanel.dfDisplayName) == "..") { return "Cannot remove .."; } if (!Xwt.MessageDialog.Confirm( String.Format(Locale.GetString("FCDelAsk"), url, null), Xwt.Command.Remove, true)) { return Locale.GetString("Canceled"); }; FileProcessDialog fpd = new FileProcessDialog(); fpd.lblStatus.Text = String.Format(Locale.GetString("DoingRemove"), "\n" + url, null); fpd.cmdCancel.Sensitive = false; fpd.Show(); string curItemDel = ActivePanel.GetValue<string>(ActivePanel.dfURL); pluginner.IFSPlugin fsdel = ActivePanel.FS; if (fsdel.FileExists(curItemDel)) { fpd.pbrProgress.Fraction = 0.5; Thread RmFileThread = new Thread(delegate() { DoRmFile(curItemDel, fsdel); }); RmFileThread.Start(); do { Xwt.Application.MainLoop.DispatchPendingEvents(); } while (RmFileThread.ThreadState == ThreadState.Running); fpd.pbrProgress.Fraction = 1; fpd.Hide(); return "Файл удалён.\n"; } if (fsdel.DirectoryExists(curItemDel)) { fpd.lblStatus.Text = String.Format(Locale.GetString("DoingRemove"), "\n" + url, "\n[" + Locale.GetString("Directory").ToUpper() + "]"); fpd.pbrProgress.Fraction = 0.5; Thread RmDirThread = new Thread(delegate() { DoRmDir(curItemDel, fsdel); }); RmDirThread.Start(); do { Xwt.Application.MainLoop.DispatchPendingEvents(); } while (RmDirThread.ThreadState == ThreadState.Running); fpd.pbrProgress.Fraction = 1; fpd.Hide(); return "Каталог удалён.\n"; } return "Файл не найден"; }
/// <summary> /// Makes a new directory at the specifed <paramref name="url"/> /// </summary> /// <param name="url"></param> public void MkDir(string url) { FileProcessDialog fpd = new FileProcessDialog(); fpd.lblStatus.Text = string.Format(Locale.GetString("DoingMkdir"), "\n" + url, null); fpd.Show(); Thread MkDirThread = new Thread(delegate() { ActivePanel.FS.CreateDirectory(url); }); MkDirThread.Start(); do { /*Application.DoEvents();*/ Xwt.Application.MainLoop.DispatchPendingEvents(); } while (MkDirThread.ThreadState == ThreadState.Running); fpd.pbrProgress.Fraction = 1; ActivePanel.LoadDir(ActivePanel.FS.CurrentDirectory); fpd.Hide(); }
/// <summary>Load the file in the VE</summary> /// <param name="URL">The URL of the file</param> /// <param name="FS">The filesystem of the file</param> /// <param name="plugin">The VE plugin, which will be used to load this file</param> /// <param name="AllowEdit">Allow editing the file</param> public void LoadFile(string URL, pluginner.IFSPlugin FS, pluginner.IVEPlugin plugin, bool AllowEdit) { //check for external editor try{ if (fcmd.Properties.Settings.Default.UseExternalEditor && AllowEdit || fcmd.Properties.Settings.Default.UseExternalViewer && !AllowEdit && URL.StartsWith("file:")){ CanBeShowed = false; if (AllowEdit){ ExecuteProgram(fcmd.Properties.Settings.Default.ExternalEditor.Replace("$", "\"" + URL)); } else{ ExecuteProgram(fcmd.Properties.Settings.Default.ExternalViewer.Replace("$", "\"" + URL)); } return; } } catch (Exception ex) { Xwt.MessageDialog.ShowError(Locale.GetString("CantRunEXE"), ex.Message); CanBeShowed = false; return; } string FiNa4Title = URL.Substring(URL.LastIndexOf(FS.DirSeparator) + 1); IsEditor = AllowEdit; if(AllowEdit) this.Title = string.Format(Locale.GetString("FCETitle"), FiNa4Title); else this.Title = string.Format(Locale.GetString("FCVTitle"), FiNa4Title); FileProcessDialog ProgressDialog = new FileProcessDialog(); string ProgressInitialText = String.Format(Locale.GetString("FCVELoadingMsg"),URL); ProgressDialog.lblStatus.Text = ProgressInitialText; FS.ProgressChanged += (d) => { ProgressDialog.pbrProgress.Fraction = (d >= 0 && d <= 1) ? d : ProgressDialog.pbrProgress.Fraction; Xwt.Application.MainLoop.DispatchPendingEvents(); }; FS.StatusChanged += (d) => { ProgressDialog.lblStatus.Text = ProgressInitialText + "\n" + d; Xwt.Application.MainLoop.DispatchPendingEvents(); }; ProgressDialog.cmdCancel.Clicked += (o, ea) => { CanBeShowed = false; ProgressDialog.Hide(); return; }; ProgressDialog.Show(); Xwt.Application.MainLoop.DispatchPendingEvents(); if (!CanBeShowed) return; Plugin = plugin; Plugin.ReadOnly = !AllowEdit; Plugin.OpenFile(URL, FS); Plugin.ShowToolbar = fcmd.Properties.Settings.Default.VE_ShowToolbar; Plugin.Stylist = s; mnuFormat.SubMenu = Plugin.FormatMenu; bool Mode = AllowEdit; if (!Plugin.CanEdit && AllowEdit) { Xwt.MessageDialog.ShowWarning(String.Format(Locale.GetString("FCVEpluginro1"), Plugin.Name + " " + Plugin.Version), Locale.GetString("FCVEpluginro2")); Mode = false; } FSPlugin = FS; PluginBody = Plugin.Body; SetVEMode(Mode); BuildLayout(); ProgressDialog.Hide(); PluginBody.KeyReleased += (sender, e) => { if(e.Key == Xwt.Key.Escape) CommandBox.SetFocus(); if(e.Key == Xwt.Key.q) this.OnCloseRequested(); }; }