Пример #1
0
        /// <summary>
        /// Opens the path on another panel for the FileSystem provider or an item panel as a child of this panel for other providers.
        /// </summary>
        /// <param name="file">The file to open.</param>
        public override void OpenFile(FarFile file)
        {
            // base
            if (UserWants != UserAction.Enter)
            {
                base.OpenFile(file);
                return;
            }

            // get data
            TreeFile node = (TreeFile)file;
            PSObject data = node.Data as PSObject;
            ProviderInfo provider = (ProviderInfo)data.Properties["PSProvider"].Value;

            // open at the passive panel
            if (provider.Name == "FileSystem")
            {
                Far.Api.Panel2.CurrentDirectory = node.Path;
                Far.Api.Panel2.Update(false);
                Far.Api.Panel2.Redraw();
            }
            // open at the same panel as child
            else
            {
                ItemPanel panel = new ItemPanel(node.Path);
                panel.OpenChild(this);
            }
        }
Пример #2
0
        /// <include file='doc.xml' path='doc/ScriptFork/*'/>
        /// <param name="args">.</param>
        public sealed override IList <FarFile> GetFiles(GetFilesEventArgs args)
        {
            if (AsGetFiles == null)
            {
                return(DoGetFiles(args));
            }

            // nothing, use the predefined file list
            var output = A.InvokeScript(AsGetFiles, this, args);

            if (output.Count == 0)
            {
                return(Cache);
            }

            // convert the output to files
            var result = new List <FarFile>();

            foreach (var it in output)
            {
                FarFile file = (FarFile)LanguagePrimitives.ConvertTo(it, typeof(FarFile), null);
                if (file != null)
                {
                    result.Add(file);
                }
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Opens the path on another panel for the FileSystem provider or an item panel as a child of this panel for other providers.
        /// </summary>
        /// <param name="file">The file to open.</param>
        public override void OpenFile(FarFile file)
        {
            // base
            if (UserWants != UserAction.Enter)
            {
                base.OpenFile(file);
                return;
            }

            // get data
            TreeFile     node     = (TreeFile)file;
            PSObject     data     = node.Data as PSObject;
            ProviderInfo provider = (ProviderInfo)data.Properties["PSProvider"].Value;

            // open at the passive panel
            if (provider.Name == "FileSystem")
            {
                Far.Api.Panel2.CurrentDirectory = node.Path;
                Far.Api.Panel2.Update(false);
                Far.Api.Panel2.Redraw();
            }
            // open at the same panel as child
            else
            {
                ItemPanel panel = new ItemPanel(node.Path);
                panel.OpenChild(this);
            }
        }
Пример #4
0
        internal static void CompleteFileData(FarFile file, SettingsPropertyValue value)
        {
            // defaults
            var prefix = value.UsingDefaultValue ? "- " : "+ ";

            file.Owner = prefix + file.Name;
        }
Пример #5
0
        ///
        internal void UIOpenFileMembers()
        {
            FarFile file = CurrentFile;

            if (file != null)
            {
                //OpenFileMembers(file);
            }
        }
Пример #6
0
 /// <summary>
 /// New super file with its explorer.
 /// </summary>
 /// <param name="explorer">The file's explorer.</param>
 /// <param name="file">The base file.</param>
 public SuperFile(Explorer explorer, FarFile file)
     : base(file)
 {
     if (explorer == null)
     {
         throw new ArgumentNullException("explorer");
     }
     _Explorer = explorer;
 }
Пример #7
0
        static PSObject ConvertFileToItem(FarFile file)
        {
            if (file == null || file.Data == null)
            {
                return(null);
            }

            return(PSObject.AsPSObject(file.Data));
        }
Пример #8
0
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="file">The file to edit.</param>
 public sealed override void UIEditFile(FarFile file)         //_091202_073429 NB: Data can be wrapped by PSObject.
 {
     if (AsEditFile != null)
     {
         A.InvokeScriptReturnAsIs(AsEditFile, this, file);
     }
     else
     {
         DoEditFile(file);
     }
 }
Пример #9
0
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="file">The file to view.</param>
 public sealed override void UIViewFile(FarFile file)         //_091202_073429
 {
     if (AsViewFile != null)
     {
         A.InvokeScriptReturnAsIs(AsViewFile, this, file);
     }
     else
     {
         DoViewFile(file);
     }
 }
Пример #10
0
        /// <summary>
        /// Puts a value into the command line or opens a lookup panel or member panel.
        /// </summary>
        /// <param name="file">The file to process.</param>
        public override void OpenFile(FarFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            PSPropertyInfo pi = file.Data as PSPropertyInfo;

            // e.g. visible mode: sender is MemberDefinition
            if (pi == null)
            {
                return;
            }

            // lookup opener?
            if (_LookupOpeners != null)
            {
                ScriptHandler <OpenFileEventArgs> handler;
                if (_LookupOpeners.TryGetValue(file.Name, out handler))
                {
                    handler.Invoke(this, new OpenFileEventArgs(file));
                    return;
                }
            }

            // case: can show value in the command line
            string s = Converter.InfoToLine(pi);

            if (s != null)
            {
                // set command line
                ILine cl = Far.Api.CommandLine;
                cl.Text = "=" + s;
                cl.SelectText(1, s.Length + 1);
                return;
            }

            // case: enumerable
            IEnumerable ie = Cast <IEnumerable> .From(pi.Value);

            if (ie != null)
            {
                ObjectPanel op = new ObjectPanel();
                op.AddObjects(ie);
                op.OpenChild(this);
                return;
            }

            // open members
            OpenFileMembers(file);
        }
Пример #11
0
 /// <summary>
 /// Creates a panel for provider items at the given location.
 /// </summary>
 /// <param name="path">Path to start at.</param>
 public ItemPanel(string path)
     : this(new ItemExplorer(new PathInfoEx(path)))
 {
     // current location, post the current name
     if (string.IsNullOrEmpty(path))
     {
         FarFile file = Far.Api.Panel.CurrentFile;
         if (file != null)
         {
             PostName(file.Name);
         }
     }
 }
Пример #12
0
 /// <summary>
 /// New folder tree at the given location path.
 /// </summary>
 /// <param name="path">The location path.</param>
 public FolderTree(string path)
     : this(new FolderExplorer(path))
 {
     // post name
     if (string.IsNullOrEmpty(path) || path == ".")
     {
         FarFile currentFile = Far.Api.Panel.CurrentFile;
         if (currentFile != null)
         {
             PostName(currentFile.Name);
         }
     }
 }
Пример #13
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            if (!(file.Data is PSPropertyInfo pi))
            {
                return(null);
            }
            if (pi.Value == null)
            {
                return(null);
            }
            MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value));

            r.OpenChild(this);
            return(r);
        }
Пример #14
0
        /// <summary>
        /// Opens <see cref="MemberPanel"/> for a file.
        /// File <c>Data</c> must not be null.
        /// </summary>
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            // get data
            TreeFile t = (TreeFile)file;

            if (t.Data == null)
            {
                return(null);
            }

            //! use null as parent: this panel can be not open now
            MemberPanel r = new MemberPanel(new MemberExplorer(t.Data));

            r.OpenChild(null);
            return(r);
        }
Пример #15
0
        /// <summary>
        /// Puts a value into the command line or opens a lookup panel or member panel.
        /// </summary>
        /// <param name="file">The file to process.</param>
        public override void OpenFile(FarFile file)
        {
            if (file == null)
                throw new ArgumentNullException("file");

            PSPropertyInfo pi = file.Data as PSPropertyInfo;

            // e.g. visible mode: sender is MemberDefinition
            if (pi == null)
                return;

            // lookup opener?
            if (_LookupOpeners != null)
            {
                ScriptHandler<OpenFileEventArgs> handler;
                if (_LookupOpeners.TryGetValue(file.Name, out handler))
                {
                    handler.Invoke(this, new OpenFileEventArgs(file));
                    return;
                }
            }

            // case: can show value in the command line
            string s = Converter.InfoToLine(pi);
            if (s != null)
            {
                // set command line
                ILine cl = Far.Api.CommandLine;
                cl.Text = "=" + s;
                cl.SelectText(1, s.Length + 1);
                return;
            }

            // case: enumerable
            IEnumerable ie = Cast<IEnumerable>.From(pi.Value);
            if (ie != null)
            {
                ObjectPanel op = new ObjectPanel();
                op.AddObjects(ie);
                op.OpenChild(this);
                return;
            }

            // open members
            OpenFileMembers(file);
        }
Пример #16
0
        private void ExportFileEntry(FarFile file, string Dir)
        {
            var filedata = file.Data ?? GetFileData(file);

            if (file.IsDirectory)
            {
                Directory.CreateDirectory(Dir);
                if (filedata is PakExplorer index)
                {
                    index._files.ForEach(f => ExportFileEntry(f, Path.Combine(Dir, f.Name)));
                }
            }
            else if (file.Name.EndsWith(".bnk") && filedata is FPakEntry entry)
            {
                UE4.VorbisBank.BankFile bank = null;
                var data     = InspectedFile.ReadEntry(entry);
                var bankinfo = _files.Where(f => f.Name == "SoundbanksInfo.xml").SingleOrDefault();
                if (bankinfo != null)
                {
                    var bankData = InspectedFile.ReadEntry(bankinfo.Data);
                    var doc      = new XmlDocument();
                    var xml      = Encoding.UTF8.GetString(bankData);
                    doc.LoadXml(xml);
                    var info = new SoundBankInfo(doc);
                    bank = new UE4.VorbisBank.BankFile(data, info);
                }
                else
                {
                    bank = new UE4.VorbisBank.BankFile(data);
                }

                File.WriteAllBytes(Dir, data);
                var folder = Path.Combine(Path.GetDirectoryName(Dir), Path.GetFileNameWithoutExtension(Dir));
                Directory.CreateDirectory(folder);
                bank.Files.ForEach(track => File.WriteAllBytes(Path.Combine(folder, track.Name), bank.ReadTrack(track)));
            }
            else
            {
                var data = InspectedFile.ReadEntry(filedata);
                if (data != null)
                {
                    File.WriteAllBytes(Dir, data);
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Sets file name if any suitable exists.
        /// </summary>
        static void SetFileName(FarFile file)
        {
            // case: try to get display name
            PSObject       data = PSObject.AsPSObject(file.Data);
            PSPropertyInfo pi   = A.FindDisplayProperty(data);

            if (pi != null)
            {
                file.Name = pi.Value == null ? Res.NullText : pi.Value.ToString();
                return;
            }

            // other: use ToString(), but skip too verbose PSCustomObject
            if (!(data.BaseObject is PSCustomObject))
            {
                file.Name = data.ToString();
            }
        }
Пример #18
0
        ///
        public static GetContentEventArgs WorksExportExplorerFile(Explorer explorer, Panel panel, ExplorerModes mode, FarFile file, string fileName)
        {
            if (explorer == null) throw new ArgumentNullException("explorer");
            if (panel == null) throw new ArgumentNullException("panel");

            if (!explorer.CanGetContent)
                return null;

            // export file
            Log.Source.TraceInformation("ExportFile");
            var args = new GetContentEventArgs(mode, file, fileName);
            panel.UIGetContent(args);
            if (args.Result != JobResult.Done)
                return null;

            // no text or an actual file exists?
            if (args.UseText == null || !string.IsNullOrEmpty(args.UseFileName))
                return args;

            // export text
            string text = args.UseText as string;
            if (text == null)
            {
                IEnumerable collection = args.UseText as IEnumerable;
                if (collection == null)
                {
                    text = args.UseText.ToString();
                }
                else
                {
                    // write collection
                    using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.Unicode))
                        foreach (var it in collection)
                            writer.WriteLine(it);
                    return args;
                }
            }

            // write text
            File.WriteAllText(fileName, text, Encoding.Unicode);
            args.CodePage = 1200;
            return args;
        }
Пример #19
0
        internal IList <FarFile> Explore(GetFilesEventArgs args)
        {
            if (args == null)
            {
                return(null);
            }
            var Files = Explorer.Cache;

            // refill
            if (NeedsNewFiles)
            {
                if (CanClose())
                {
                    if (Adapter != null)
                    {
                        Table.Clear();
                    }
                    Fill();
                }
            }

            // no job?
            if (!ToUpdateData && !NeedsNewFiles)
            {
                return(Files);
            }

            // refresh data
            for (int iFile = Files.Count; --iFile >= 0;)
            {
                FarFile f   = Files[iFile];
                DataRow Row = f.Data as DataRow;
                if (Row == null || Row.RowState == DataRowState.Deleted || Row.RowState == DataRowState.Detached)
                {
                    Files.RemoveAt(iFile);
                    continue;
                }
            }

            // prevent next job
            ToUpdateData = false;
            return(Files);
        }
Пример #20
0
        internal override void UIAttributes()
        {
            if (Drive.Length > 0)
            {
                return;
            }

            // has property?
            if (!My.ProviderInfoEx.HasProperty(Explorer.Provider))
            {
                A.Message(Res.NotSupportedByProvider);
                return;
            }

            // open property panel
            FarFile file = CurrentFile;

            (new PropertyExplorer(file == null ? Explorer.Location : My.PathEx.Combine(Explorer.Location, file.Name))).OpenPanelChild(this);
        }
Пример #21
0
        /// <summary>
        /// Opens/closes the node.
        /// </summary>
        /// <param name="file">The node to open/close.</param>
        public override void OpenFile(FarFile file)
        {
            if (file == null)
                throw new ArgumentNullException("file");

            TreeFile node = (TreeFile)file;
            if (node._State == 0)
            {
                if (!node.IsNode)
                    return;
                node.FillNode();
                node._State = 1;
            }
            else
            {
                node._State = -node._State;
            }
            UpdateRedraw(false);
        }
Пример #22
0
        /// <inheritdoc/>
        protected override bool CanClose()
        {
            if (Child != null)
            {
                return(true);
            }

            FarFile f = CurrentFile;

            if (f == null)
            {
                _lastCurrentName = null;
            }
            else
            {
                _lastCurrentName = f.Name;
            }

            return(true);
        }
Пример #23
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            PSObject o          = PSObject.AsPSObject(file.Data);
            string   memberType = o.Properties["MemberType"].Value.ToString();

            if (!memberType.EndsWith("Property", StringComparison.Ordinal))             //??
            {
                return(null);
            }

            string name     = o.Properties[Word.Name].Value.ToString();
            object instance = Target.Properties[name].Value;

            if (instance == null)
            {
                return(null);
            }

            MemberPanel r = new MemberPanel(new MemberExplorer(instance));

            r.OpenChild(this);
            return(r);
        }
Пример #24
0
        /// <summary>
        /// Calls base or assigns a value to the current property.
        /// </summary>
        void OnInvokingCommand(object sender, CommandLineEventArgs e)
        {
            // base
            string code = e.Command.TrimStart();

            if (!code.StartsWith("=", StringComparison.Ordinal))
            {
                return;
            }

            // we do
            e.Ignore = true;

            // skip empty
            FarFile f = CurrentFile;

            if (f == null)
            {
                return;
            }
            PSPropertyInfo pi = f.Data as PSPropertyInfo;

            if (pi == null)
            {
                return;
            }

            try
            {
                SetUserValue(pi, code.Substring(1));
                UpdateRedraw(true);
            }
            catch (RuntimeException ex)
            {
                A.Message(ex.Message);
            }
        }
Пример #25
0
        /// <summary>
        /// Opens/closes the node.
        /// </summary>
        /// <param name="file">The node to open/close.</param>
        public override void OpenFile(FarFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            TreeFile node = (TreeFile)file;

            if (node._State == 0)
            {
                if (!node.IsNode)
                {
                    return;
                }
                node.FillNode();
                node._State = 1;
            }
            else
            {
                node._State = -node._State;
            }
            UpdateRedraw(false);
        }
Пример #26
0
 internal override MemberPanel OpenFileMembers(FarFile file)
 {
     PSPropertyInfo pi = file.Data as PSPropertyInfo;
     if (pi == null)
         return null;
     if (pi.Value == null)
         return null;
     MemberPanel r = new MemberPanel(new MemberExplorer(pi.Value));
     r.OpenChild(this);
     return r;
 }
Пример #27
0
        /// <summary>
        /// Opens the file member panel.
        /// </summary>
        /// <remarks>
        /// The base method propagates lookup openers.
        /// </remarks>
        internal virtual MemberPanel OpenFileMembers(FarFile file)
        {
            //??? _090610_071700, + $panel.SetOpen({ @ Test-Panel-Tree-.ps1
            object target = file.Data == null ? file : file.Data;

            MemberPanel panel = new MemberPanel(new MemberExplorer(target));
            panel._LookupOpeners = _LookupOpeners;

            var tablePanel = Far.Api.Panel as TablePanel;
            if (tablePanel != null)
            {
                if (!string.IsNullOrEmpty(tablePanel.ExcludeMemberPattern))
                    panel.Explorer.ExcludeMemberPattern = tablePanel.ExcludeMemberPattern;

                if (!string.IsNullOrEmpty(tablePanel.HideMemberPattern))
                    panel.Explorer.HideMemberPattern = tablePanel.HideMemberPattern;
            }

            //! use null as parent: this panel can be not open now
            panel.OpenChild(null);
            return panel;
        }
Пример #28
0
 void OpenFileActor(FarFile file)
 {
     var memberPanel = OpenFileMembers(file);
     memberPanel.Explorer.CanDeleteFiles = false;
 }
Пример #29
0
        static PSObject ConvertFileToItem(FarFile file)
        {
            if (file == null || file.Data == null)
                return null;

            return PSObject.AsPSObject(file.Data);
        }
Пример #30
0
        /// <summary>
        /// Opens the file using <see cref="AsOpenFile"/> or the default method.
        /// </summary>
        /// <param name="file">The file to be opened.</param>
        public override sealed void UIOpenFile(FarFile file)
        {
            if (file == null)
                return;

            // lookup closer?
            if (UserWants == UserAction.Enter && Lookup != null)
            {
                Lookup.Invoke(this, new OpenFileEventArgs(file));
                UIEscape(false);
                return;
            }

            // script
            if (AsOpenFile != null)
            {
                A.InvokeScriptReturnAsIs(AsOpenFile, this, new OpenFileEventArgs(file));
                return;
            }

            // base
            if (Explorer.CanOpenFile)
            {
                base.UIOpenFile(file);
                return;
            }

            // PSF
            OpenFile(file);
        }
Пример #31
0
 /// <summary>
 /// New super file with its explorer.
 /// </summary>
 /// <param name="explorer">The file's explorer.</param>
 /// <param name="file">The base file.</param>
 public SuperFile(Explorer explorer, FarFile file)
     : base(file)
 {
     if (explorer == null) throw new ArgumentNullException("explorer");
     _Explorer = explorer;
 }
Пример #32
0
 /// <summary>
 /// <see cref="UIEditFile"/> worker.
 /// </summary>
 /// <param name="file">The file to edit.</param>
 public void DoEditFile(FarFile file)
 {
     base.UIEditFile(file);
 }
Пример #33
0
        void OpenFileActor(FarFile file)
        {
            var memberPanel = OpenFileMembers(file);

            memberPanel.Explorer.CanDeleteFiles = false;
        }
Пример #34
0
        /// <summary>
        /// Opens a member panel to edit the record.
        /// </summary>
        /// <param name="file">The file to open.</param>
        public override void OpenFile(FarFile file)
        {
            BuildUpdateCommand();

            OpenFileActor(file);
        }
Пример #35
0
        /// <summary>
        /// Opens the file in the editor.
        /// </summary>
        /// <param name="file">The file to edit.</param>
        /// <remarks>
        /// The default method calls <see cref="FarNet.Explorer.GetContent"/>  to get a temporary file to edit
        /// and <see cref="FarNet.Explorer.SetFile"/> to save changes when the editor closes.
        /// The explorer should have at least export implemented.
        /// </remarks>
        public virtual void UIEditFile(FarFile file)
        {
            if (file == null)
                return;

            // target
            var temp = Far.Api.TempName();

            // export
            var xExportArgs = WorksExportExplorerFile(Explorer, this, ExplorerModes.Edit, file, temp);
            if (xExportArgs == null)
                return;

            // case: actual file exists
            var asExportFileEventArgs = xExportArgs as GetContentEventArgs;
            if (asExportFileEventArgs != null && !string.IsNullOrEmpty(asExportFileEventArgs.UseFileName))
            {
                var editorActual = Far.Api.CreateEditor();
                editorActual.FileName = asExportFileEventArgs.UseFileName;
                editorActual.Title = file.Name;
                if (!asExportFileEventArgs.CanSet)
                    editorActual.IsLocked = true;
                editorActual.Open();
                return;
            }

            // rename
            if (!string.IsNullOrEmpty(xExportArgs.UseFileExtension))
            {
                string temp2 = temp + xExportArgs.UseFileExtension;
                File.Move(temp, temp2);
                temp = temp2;
            }

            // editor
            var editorTemp = Far.Api.CreateEditor();
            editorTemp.DeleteSource = DeleteSource.File;
            editorTemp.DisableHistory = true;
            editorTemp.FileName = temp;
            editorTemp.Title = file.Name;
            if (asExportFileEventArgs.CodePage != 0)
                editorTemp.CodePage = asExportFileEventArgs.CodePage;

            // future
            if (xExportArgs.CanSet)
            {
                if (Explorer.CanSetText)
                {
                    editorTemp.Saving += delegate
                    {
                        var xImportTextArgs = new SetTextEventArgs(ExplorerModes.Edit, file, editorTemp.GetText());
                        Log.Source.TraceInformation("ImportText");
                        UISetText(xImportTextArgs);
                    };
                }
                else
                {
                    editorTemp.Closed += delegate //???? to use Saved (Far 3), update docs.
                    {
                        if (editorTemp.TimeOfSave == DateTime.MinValue)
                            return;

                        var xImportFileArgs = new SetFileEventArgs(ExplorerModes.Edit, file, temp);
                        Log.Source.TraceInformation("ImportFile");
                        UISetFile(xImportFileArgs);
                    };
                }
            }
            else
            {
                // to lock
                editorTemp.IsLocked = true;
            }

            // go
            editorTemp.Open();
        }
Пример #36
0
        /// <summary>
        /// Opens the file.
        /// </summary>
        /// <remarks>
        /// It is called for the current file when [Enter] is pressed.
        /// The base method just calls <see cref="FarNet.Explorer.OpenFile"/> if the explorer supports it.
        /// </remarks>
        /// <param name="file">The file to be opened.</param>
        public virtual void UIOpenFile(FarFile file)
        {
            if (file == null)
                return;

            if (!Explorer.CanOpenFile)
                return;

            var args = new OpenFileEventArgs(file);
            var explorer = UIOpenFile(args);
            if (explorer != null)
                explorer.OpenPanelChild(this);
        }
Пример #37
0
        /// <summary>
        /// Opens the file in the viewer.
        /// </summary>
        /// <param name="file">The file to view.</param>
        /// <remarks>
        /// The default method calls <see cref="FarNet.Explorer.GetContent"/> to get a temporary file to view.
        /// The explorer should have it implemented.
        /// </remarks>
        public virtual void UIViewFile(FarFile file)
        {
            if (file == null)
                return;

            // target
            var temp = Far.Api.TempName();

            // export
            var xExportArgs = WorksExportExplorerFile(Explorer, this, ExplorerModes.View, file, temp);
            if (xExportArgs == null)
                return;

            // case: actual file exists
            var asExportFileEventArgs = xExportArgs as GetContentEventArgs;
            if (asExportFileEventArgs != null && !string.IsNullOrEmpty(asExportFileEventArgs.UseFileName))
            {
                var viewerActual = Far.Api.CreateViewer();
                viewerActual.FileName = asExportFileEventArgs.UseFileName;
                viewerActual.Title = file.Name;
                viewerActual.Open();
                return;
            }

            // viewer
            var viewerTemp = Far.Api.CreateViewer();
            viewerTemp.DeleteSource = DeleteSource.File;
            viewerTemp.DisableHistory = true;
            viewerTemp.FileName = temp;
            viewerTemp.Title = file.Name;
            viewerTemp.Switching = Switching.Enabled;
            if (asExportFileEventArgs.CodePage != 0)
                viewerTemp.CodePage = asExportFileEventArgs.CodePage;

            // open
            viewerTemp.Open();
        }
Пример #38
0
        /// <summary>
        /// Opens <see cref="MemberPanel"/> for a file.
        /// File <c>Data</c> must not be null.
        /// </summary>
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            // get data
            TreeFile t = (TreeFile)file;
            if (t.Data == null)
                return null;

            //! use null as parent: this panel can be not open now
            MemberPanel r = new MemberPanel(new MemberExplorer(t.Data));
            r.OpenChild(null);
            return r;
        }
Пример #39
0
        public OperationResult DirectLocalCopyOrRename(FarFile currentFile, bool isMove)
        {
            // IsSilentOperation() || ???

            OnDeviceOperation doc = null;

            Playlist pl = (Playlist)currentFile.Data;

            string name = pl.Name;

            PlaylistSortField sortField = pl.SortField;

            if (CommonDialog.ForGetPlayListParams(ref name, ref sortField, isMove) == 0)
            {
                doc = new DirectPlaylistOperation(
                    _fs.CurrentDevice, pl, name, sortField, isMove);
            }

            return execOperation(doc, null).SetResult(name);
        }
Пример #40
0
 /// <summary>
 /// <see cref="UIViewFile"/> worker.
 /// </summary>
 /// <param name="file">The file to view.</param>
 public void DoViewFile(FarFile file)
 {
     base.UIViewFile(file);
 }
Пример #41
0
 internal static void CompleteFileData(FarFile file, SettingsPropertyValue value)
 {
     // defaults
     var prefix = value.UsingDefaultValue ? "- " : "+ ";
     file.Owner = prefix + file.Name;
 }
Пример #42
0
 //_091202_073429
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="file">The file to view.</param>
 public override sealed void UIViewFile(FarFile file)
 {
     if (AsViewFile != null)
         A.InvokeScriptReturnAsIs(AsViewFile, this, file);
     else
         DoViewFile(file);
 }
Пример #43
0
 /// <summary>
 /// Posts the file to be found and set current on redrawing.
 /// </summary>
 /// <param name="file">The file to be found on redrawing.</param>
 /// <remarks>
 /// The posted file is ignored if <see cref="PostData"/> or <see cref="PostName"/> were called.
 /// The <see cref="FarNet.Explorer.FileComparer"/> is used in order to find the file.
 /// </remarks>
 public void PostFile(FarFile file)
 {
     _Panel.PostFile(file);
 }
Пример #44
0
 internal static Explorer ExploreSuperDirectory(Explorer explorer, ExplorerModes mode, FarFile file)
 {
     try
     {
         if (explorer.CanExploreLocation)
         {
             return(explorer.ExploreLocation(new ExploreLocationEventArgs(mode, file.Name)));
         }
         else
         {
             return(explorer.ExploreDirectory(new ExploreDirectoryEventArgs(mode, file)));
         }
     }
     catch (Exception ex)
     {
         FarNet.Log.TraceException(ex);
         return(null);
     }
 }
Пример #45
0
 internal PanelMenuEventArgs(IMenu menu, FarFile currentFile, IList <FarFile> selectedList)
 {
     Menu         = menu;
     CurrentFile  = currentFile;
     SelectedList = selectedList;
 }
Пример #46
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            UserWants = UserAction.None;
            try
            {
                switch (key.VirtualKeyCode)
                {
                case KeyCode.Enter:

                    if (key.Is())
                    {
                        FarFile file = CurrentFile;
                        if (file == null)
                        {
                            break;
                        }

                        UserWants = UserAction.Enter;

                        if (file.IsDirectory && !IgnoreDirectoryFlag)
                        {
                            break;
                        }

                        UIOpenFile(file);
                        return(true);
                    }

                    if (key.IsShift())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.F1:

                    if (key.Is())
                    {
                        UIHelp();
                        return(true);
                    }

                    break;

                case KeyCode.F3:

                    if (key.Is())
                    {
                        if (CurrentFile == null)
                        {
                            UIViewAll();
                            return(true);
                        }
                        break;
                    }

                    if (key.IsShift())
                    {
                        ShowMenu();
                        return(true);
                    }

                    break;

                case KeyCode.PageDown:

                    if (key.IsCtrl())
                    {
                        UIOpenFileMembers();
                        return(true);
                    }

                    break;

                case KeyCode.A:

                    if (key.IsCtrl())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.G:

                    if (key.IsCtrl())
                    {
                        UIApply();
                        return(true);
                    }

                    break;

                case KeyCode.M:

                    if (key.IsCtrlShift())
                    {
                        UIMode();
                        return(true);
                    }

                    break;

                case KeyCode.S:

                    //! Mantis#2635 Ignore if auto-completion menu is opened
                    if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu)
                    {
                        SaveData();
                        return(true);
                    }

                    break;
                }

                // base
                return(base.UIKeyPressed(key));
            }
            finally
            {
                UserWants = UserAction.None;
            }
        }
Пример #47
0
 internal PanelMenuEventArgs(IMenu menu, FarFile currentFile, IList<FarFile> selectedList)
 {
     Menu = menu;
     CurrentFile = currentFile;
     SelectedList = selectedList;
 }
Пример #48
0
        /// <summary>
        /// Opens a member panel to edit the record.
        /// </summary>
        /// <param name="file">The file to open.</param>
        public override void OpenFile(FarFile file)
        {
            BuildUpdateCommand();

            OpenFileActor(file);
        }
Пример #49
0
 /// <summary>
 /// <see cref="UIEditFile"/> worker.
 /// </summary>
 /// <param name="file">The file to edit.</param>
 public void DoEditFile(FarFile file)
 {
     base.UIEditFile(file);
 }
Пример #50
0
 internal static Explorer ExploreSuperDirectory(Explorer explorer, ExplorerModes mode, FarFile file)
 {
     try
     {
         if (explorer.CanExploreLocation)
             return explorer.ExploreLocation(new ExploreLocationEventArgs(mode, file.Name));
         else
             return explorer.ExploreDirectory(new ExploreDirectoryEventArgs(mode, file));
     }
     catch (Exception ex)
     {
         FarNet.Log.TraceException(ex);
         return null;
     }
 }
Пример #51
0
        /// <summary>
        /// Opens a file.
        /// </summary>
        /// <param name="file">The file to open.</param>
        /// <remarks>
        /// The base method calls Invoke-Item for <see cref="FileSystemInfo"/> files.
        /// </remarks>
        public virtual void OpenFile(FarFile file)
        {
            if (file == null)
                throw new ArgumentNullException("file");

            if (file.Data == null)
                return;

            //! use try, e.g. Invoke-Item throws exception with any error action (PS bug?)
            try
            {
                // case: file system
                FileSystemInfo fi = Cast<FileSystemInfo>.From(file.Data);
                if (fi != null)
                {
                    A.InvokeCode("Invoke-Item -LiteralPath $args[0] -ErrorAction Stop", fi.FullName);
                    return;
                }
            }
            catch (RuntimeException ex)
            {
                A.Msg(ex);
            }
        }
Пример #52
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            UserWants = UserAction.None;
            try
            {
                switch (key.VirtualKeyCode)
                {
                case KeyCode.Enter:

                    if (key.Is())
                    {
                        //Far.Api.ShowError("Not implemented", new NotImplementedException("Not implemented: "+ CurrentFile.Name));

                        FarFile file = CurrentFile;
                        if (file == null)
                        {
                            break;
                        }

                        UserWants = UserAction.Enter;

                        if (file.IsDirectory && !IgnoreDirectoryFlag)
                        {
                            break;
                        }

                        var cancellation = new CancellationTokenSource();
                        var _cancel      = cancellation.Token;

                        //var ptask = new ProgressTask("test", "test-title", _cancel);
                        //var form = ptask.ShowDialog();
                        //Thread.Sleep(3000);
                        //cancellation.Cancel();
                        //form.Complete();

                        UIOpenFile(file);

                        return(true);
                    }

                    if (key.IsShift())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.F1:

                    if (key.Is())
                    {
                        UIHelp();
                        return(true);
                    }

                    break;

                case KeyCode.F3:

                    if (key.Is())
                    {
                        if (CurrentFile == null)
                        {
                            UIExploreLocation(null);
                            //UIViewAll();
                            return(true);
                        }

                        /*
                         * if (CurrentFile.IsDirectory)
                         * {
                         *  Explorer.CanExploreLocation = true;
                         *  break;
                         * }
                         *
                         * Explorer.CanExploreLocation = false;
                         */
                        break;
                    }

                    if (key.IsShift())
                    {
                        //ShowMenu();
                        return(true);
                    }

                    break;

                /*
                 * case KeyCode.F5:
                 *
                 *  if (key.Is())
                 *  {
                 *      if (CurrentFile == null)
                 *      {
                 *          //UIViewAll();
                 *          return true;
                 *      }
                 *
                 *      Log.Source.TraceInformation("Tried to copy this file: {0}\\{1}", CurrentLocation, CurrentFile.Name);
                 *
                 *      Log.Source.TraceInformation("Far.Api.Panel2.IsPlugin = {0}", Far.Api.Panel2.IsPlugin ? "true" : "false");
                 *      Log.Source.TraceInformation("Far.Api.Panel2.CurrentFile = {0}", Far.Api.Panel2.CurrentFile);
                 *      Log.Source.TraceInformation("Far.Api.Panel2.CurrentDirectory = {0}", Far.Api.Panel2.CurrentDirectory);
                 *
                 *      if (Far.Api.Panel2.IsPlugin)
                 *      {
                 *          // How to copy files to plugins??
                 *          return true;
                 *      }
                 *
                 *      if (Far.Api.Panel2.CurrentDirectory == null)
                 *      {
                 *          // how can it be?
                 *          return true;
                 *      }
                 *
                 *      var item = ((CurrentFile.Data as Hashtable)["fsitem"] as FSItem);
                 *      var path = Path.Combine(Far.Api.Panel2.CurrentDirectory, item.Name);
                 *
                 *      var form = new Tools.ProgressForm();
                 *      form.Activity = "Downloading...";
                 *      form.Title = "Amazon Cloud Drive - File Download Progress";
                 *      form.CanCancel = true;
                 *      form.SetProgressValue(0, item.Length);
                 *      form.Canceled += (object sender, EventArgs e) =>
                 *      {
                 *          form.Close();
                 *      };
                 *
                 *      Task task = (Explorer as ACDExplorer).Client.DownloadFile(item, path, form);
                 *      var cs = new CancellationTokenSource();
                 *      var token = cs.Token;
                 *      / *
                 *      token.Register(() =>
                 *      {
                 *          form.Close();
                 *      });* /
                 *      var _task = Task.Factory.StartNew(() =>
                 *      {
                 *          form.Show();
                 *      }, token);
                 *      task.Wait();
                 *
                 *      break;
                 *  }
                 *
                 *  if (key.IsShift())
                 *  {
                 *      //ShowMenu();
                 *      return true;
                 *  }
                 *
                 *  break;
                 */
                case KeyCode.PageDown:

                    if (key.IsCtrl())
                    {
                        UIOpenFileMembers();
                        return(true);
                    }

                    break;

                case KeyCode.A:

                    if (key.IsCtrl())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.G:

                    if (key.IsCtrl())
                    {
                        UIApply();
                        return(true);
                    }

                    break;

                case KeyCode.M:

                    if (key.IsCtrlShift())
                    {
                        UIMode();
                        return(true);
                    }

                    break;

                case KeyCode.S:

                    //! Mantis#2635 Ignore if auto-completion menu is opened
                    if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu)
                    {
                        SaveData();
                        return(true);
                    }

                    break;

                case KeyCode.R:

                    if (key.IsCtrl())
                    {
                        CacheStorage.RemoveItems(Far.Api.Panel.CurrentDirectory);
                    }

                    break;
                }

                // base
                return(base.UIKeyPressed(key));
            }
            finally
            {
                UserWants = UserAction.None;
            }
        }
Пример #53
0
 /// <summary>
 /// <see cref="UIViewFile"/> worker.
 /// </summary>
 /// <param name="file">The file to view.</param>
 public void DoViewFile(FarFile file)
 {
     base.UIViewFile(file);
 }
Пример #54
0
        /// <inheritdoc/>
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            switch (key.VirtualKeyCode)
            {
            case KeyCode.LeftArrow:
            {
                if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0)
                {
                    break;
                }

                FarFile file = CurrentFile;
                if (file == null)
                {
                    break;
                }

                TreeFile node = (TreeFile)file;
                if (node._State == 1)
                {
                    // reset
                    if (key.IsAlt())
                    {
                        node.ChildFiles.Clear();
                        node._State = 0;
                        UpdateRedraw(false);
                        return(true);
                    }

                    // collapse
                    OpenFile(file);
                }
                else if (node.Parent != null)
                {
                    PostFile(node.Parent);
                    Redraw();
                }

                return(true);
            }

            case KeyCode.RightArrow:
            {
                if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0)
                {
                    break;
                }

                FarFile file = CurrentFile;
                if (file == null)
                {
                    break;
                }

                TreeFile node = (TreeFile)file;
                if (node != null && node._State != 1 && node.IsNode)
                {
                    // reset
                    if (key.IsAlt())
                    {
                        node.ChildFiles.Clear();
                        node._State = 0;
                    }

                    // open
                    OpenFile(file);
                }
                else
                {
                    // go to next
                    Redraw(CurrentIndex + 1, -1);
                }

                return(true);
            }
            }

            // base
            return(base.UIKeyPressed(key));
        }
Пример #55
0
        internal override MemberPanel OpenFileMembers(FarFile file)
        {
            PSObject o = PSObject.AsPSObject(file.Data);
            string memberType = o.Properties["MemberType"].Value.ToString();
            if (!memberType.EndsWith("Property", StringComparison.Ordinal)) //??
                return null;

            string name = o.Properties[Word.Name].Value.ToString();
            object instance = Target.Properties[name].Value;
            if (instance == null)
                return null;

            MemberPanel r = new MemberPanel(new MemberExplorer(instance));
            r.OpenChild(this);
            return r;
        }