/// <inheritdoc/> public override void UIRenameFile(RenameFileEventArgs args) { if (args == null) { return; } // prompt IInputBox input = Far.Api.CreateInputBox(); input.EmptyEnabled = true; input.Title = "Rename"; input.Prompt = "New name"; input.History = "Copy"; input.Text = args.File.Name; if (!input.Show() || input.Text == args.File.Name) { args.Result = JobResult.Ignore; return; } // set new name and post it args.Parameter = input.Text; args.PostName = input.Text; // base base.UIRenameFile(args); }
public override void RenameFile(RenameFileEventArgs args) { OperationResult or = get(args).DirectLocalCopyOrRename(args.File, true); args.PostName = (string)or.ResultData ?? string.Empty; args.Result = processResult(or, args.Mode.HasFlag(ExplorerModes.Silent)); }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="args">.</param> public sealed override void RenameFile(RenameFileEventArgs args) { if (AsRenameFile == null) { DoRenameFile(args); } else { A.InvokeScriptReturnAsIs(AsRenameFile, this, args); } }
/// <inheritdoc/> public override void RenameFile(RenameFileEventArgs args) { if (args == null) { return; } var newName = args.Parameter as string; if (newName == null) { throw new InvalidOperationException(Res.ParameterString); } //! Registry: workaround: (default) if (Kit.Equals(args.File.Name, "(default)") && Provider.ImplementingType == typeof(RegistryProvider)) { args.Result = JobResult.Ignore; if (args.UI) { A.Message("Cannot rename this property."); } return; } using (var ps = A.Psf.NewPowerShell()) { ps.AddCommand("Rename-ItemProperty") .AddParameter("LiteralPath", ItemPath) .AddParameter(Word.Name, args.File.Name) .AddParameter("NewName", newName) .AddParameter(Prm.Force) .AddParameter(Prm.ErrorAction, ActionPreference.Continue); ps.Invoke(); if (ps.Streams.Error.Count > 0) { args.Result = JobResult.Ignore; if (args.UI) { A.ShowError(ps); } } } }
/// <inheritdoc/> public override void DoRenameFile(RenameFileEventArgs args) { if (args == null) { return; } if (!(args.Parameter is string newName)) { throw new InvalidOperationException(Res.ParameterString); } // workaround; Rename-Item has no -LiteralPath; e.g. z`z[z.txt is a big problem string src = Kit.EscapeWildcard(My.PathEx.Combine(Location, args.File.Name)); A.Psf.Engine.InvokeProvider.Item.Rename(src, newName); }
public override void UIRenameFile(RenameFileEventArgs args) { if (!ensurePathExist()) { return; } base.UIRenameFile(args); }
/// <inheritdoc/> public override void RenameFile(RenameFileEventArgs args) { if (args == null) return; var newName = args.Parameter as string; if (newName == null) throw new InvalidOperationException(Res.ParameterString); //! Registry: workaround: (default) if (Kit.Equals(args.File.Name, "(default)") && Provider.ImplementingType == typeof(RegistryProvider)) { args.Result = JobResult.Ignore; if (args.UI) A.Message("Cannot rename this property."); return; } using (var ps = A.Psf.NewPowerShell()) { ps.AddCommand("Rename-ItemProperty") .AddParameter("LiteralPath", ItemPath) .AddParameter(Word.Name, args.File.Name) .AddParameter("NewName", newName) .AddParameter(Prm.Force) .AddParameter(Prm.ErrorAction, ActionPreference.Continue); ps.Invoke(); if (ps.Streams.Error.Count > 0) { args.Result = JobResult.Ignore; if (args.UI) A.ShowError(ps); } } }
/// <summary> /// <see cref="Explorer.RenameFile"/> worker. /// </summary> /// <param name="args">.</param> public virtual void DoRenameFile(RenameFileEventArgs args) { base.RenameFile(args); }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="args">.</param> public override sealed void RenameFile(RenameFileEventArgs args) { if (AsRenameFile == null) DoRenameFile(args); else A.InvokeScriptReturnAsIs(AsRenameFile, this, args); }
/// <summary> /// Renames the file. /// </summary> /// <param name="args">.</param> /// <remarks> /// It is normally called for the current item in a panel on [ShiftF6]. /// If renaming is done then the core updates and redraws the panel /// so that an item with the new name remains current. /// If names are not unique then this is not always possible to do correctly. /// In this case set one of the <c>Post*</c>. /// </remarks> public virtual void RenameFile(RenameFileEventArgs args) { }
/// <summary> /// Rename action. /// </summary> /// <remarks> /// It is called for the current item when [ShiftF6] is pressed. /// It calls <see cref="UIRenameFile"/> if the explorer supports it. /// <para> /// Current file after the operation is defined by <c>Post*</c> in the arguments. /// </para> /// </remarks> public void UIRename() { // can? if (!Explorer.CanRenameFile) return; // file var file = CurrentFile; if (file == null) return; // call var args = new RenameFileEventArgs(ExplorerModes.None, file); UIRenameFile(args); if (args.Result != JobResult.Done) return; // post Post(args); // show Update(true); Redraw(); }
/// <inheritdoc/> public override void UIRenameFile(RenameFileEventArgs args) { if (args == null) return; // prompt IInputBox input = Far.Api.CreateInputBox(); input.EmptyEnabled = true; input.Title = "Rename"; input.Prompt = "New name"; input.History = "Copy"; input.Text = args.File.Name; if (!input.Show() || input.Text == args.File.Name) { args.Result = JobResult.Ignore; return; } // set new name and post it args.Parameter = input.Text; args.PostName = input.Text; // base base.UIRenameFile(args); }
/// <summary> /// Calls <see cref="FarNet.Explorer.RenameFile"/> and <see cref="OnThisFileChanged"/>. /// </summary> /// <param name="args">.</param> public virtual void UIRenameFile(RenameFileEventArgs args) { if (args == null) return; Explorer.RenameFile(args); if (args.Result != JobResult.Ignore) OnThisFileChanged(args); }
/// <inheritdoc/> public override void DoRenameFile(RenameFileEventArgs args) { if (args == null) return; var newName = args.Parameter as string; if (newName == null) throw new InvalidOperationException(Res.ParameterString); // workaround; Rename-Item has no -LiteralPath; e.g. z`z[z.txt is a big problem string src = Kit.EscapeWildcard(My.PathEx.Combine(Location, args.File.Name)); A.Psf.Engine.InvokeProvider.Item.Rename(src, newName); }