コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 /// <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);
     }
 }
コード例 #4
0
        /// <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);
                    }
                }
            }
        }
コード例 #5
0
ファイル: ItemExplorer.cs プロジェクト: zertyuiop/FarNet
        /// <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);
        }
コード例 #6
0
ファイル: FarPodPanel.cs プロジェクト: xeno-by/dotwindows
        public override void UIRenameFile(RenameFileEventArgs args)
        {
            if (!ensurePathExist())
            {
                return;
            }

            base.UIRenameFile(args);
        }
コード例 #7
0
ファイル: PropertyExplorer.cs プロジェクト: pezipink/FarNet
        /// <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);
                }
            }
        }
コード例 #8
0
 /// <summary>
 /// <see cref="Explorer.RenameFile"/> worker.
 /// </summary>
 /// <param name="args">.</param>
 public virtual void DoRenameFile(RenameFileEventArgs args)
 {
     base.RenameFile(args);
 }
コード例 #9
0
ファイル: PowerExplorer.cs プロジェクト: pezipink/FarNet
 /// <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);
 }
コード例 #10
0
ファイル: PowerExplorer.cs プロジェクト: pezipink/FarNet
 /// <summary>
 /// <see cref="Explorer.RenameFile"/> worker.
 /// </summary>
 /// <param name="args">.</param>
 public virtual void DoRenameFile(RenameFileEventArgs args)
 {
     base.RenameFile(args);
 }
コード例 #11
0
ファイル: Explorer.cs プロジェクト: pezipink/FarNet
 /// <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)
 {
 }
コード例 #12
0
ファイル: Panel.UI.cs プロジェクト: pezipink/FarNet
        /// <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();
        }
コード例 #13
0
ファイル: AnyPanel.cs プロジェクト: pezipink/FarNet
        /// <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);
        }
コード例 #14
0
ファイル: Panel.UIExplorer.cs プロジェクト: pezipink/FarNet
        /// <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);
        }
コード例 #15
0
ファイル: ItemExplorer.cs プロジェクト: pezipink/FarNet
        /// <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);
        }