/// <inheritdoc/> public override void DoSetText(SetTextEventArgs args) { if (args == null) { return; } try { // path string path = My.PathEx.Combine(Location, args.File.Name); // read string text = args.Text.TrimEnd(); // set if (!A.SetContentUI(path, text)) { return; } } catch (RuntimeException ex) { if (args.UI) { A.Message(ex.Message); } } }
public override void UISetText(SetTextEventArgs args) { base.UISetText(args); Update(true); Redraw(); _isDirty = true; }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="args">.</param> public sealed override void SetText(SetTextEventArgs args) { if (AsSetText == null) { DoSetText(args); } else { A.InvokeScriptReturnAsIs(AsSetText, this, args); } }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) { return; } PSPropertyInfo pi = Cast <PSPropertyInfo> .From(args.File.Data); if (pi == null) { args.Result = JobResult.Ignore; } else { A.SetPropertyFromTextUI(Value, pi, args.Text.TrimEnd()); } }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) { return; } PSPropertyInfo pi = args.File.Data as PSPropertyInfo; if (pi == null) { args.Result = JobResult.Ignore; return; } try { object value; string text = args.Text.TrimEnd(); if (pi.TypeNameOfValue.EndsWith("]", StringComparison.Ordinal)) { ArrayList lines = new ArrayList(); foreach (var line in FarNet.Works.Kit.SplitLines(text)) { lines.Add(line); } value = lines; } else { value = text; } A.SetPropertyValue(ItemPath, pi.Name, Converter.Parse(pi, value)); PropertyPanel.WhenPropertyChanged(ItemPath); } catch (RuntimeException ex) { if (args.UI) { A.Msg(ex); } } }
/// <inheritdoc/> public override void UISetText(SetTextEventArgs args) { if (args == null) { return; } // call base.UISetText(args); if (args.Result != JobResult.Done) { return; } // update after edit if (0 != (args.Mode & ExplorerModes.Edit)) //????? in many cases it is not needed, think to avoid/do effectively { UpdateRedraw(true); } }
public override void SetText(SetTextEventArgs args) { if (args == null) { return; } var value = (SettingsPropertyValue)args.File.Data; var ex = ValidatePropertyText(value.Property, args.Text); if (ex != null) { args.Result = JobResult.Ignore; Far.Api.ShowError("Settings", ex); return; } args.File.Description = SetPropertyValueText(value, args.Text); CompleteFileData(args.File, value); }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) { return; } // call var xfile = (SuperFile)args.File; if (!xfile.Explorer.CanSetText) { args.Result = JobResult.Default; return; } var argsImport = new SetTextEventArgs(args.Mode, xfile.File, args.Text); xfile.Explorer.SetText(argsImport); // result args.Result = argsImport.Result; }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) return; // call var xfile = (SuperFile)args.File; if (!xfile.Explorer.CanSetText) { args.Result = JobResult.Default; return; } var argsImport = new SetTextEventArgs(args.Mode, xfile.File, args.Text); xfile.Explorer.SetText(argsImport); // result args.Result = argsImport.Result; }
public override void UISetText(SetTextEventArgs args) { base.UISetText(args); Update(true); Redraw(); _isDirty = true; }
/// <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(); }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) return; PSPropertyInfo pi = Cast<PSPropertyInfo>.From(args.File.Data); if (pi == null) args.Result = JobResult.Ignore; else A.SetPropertyFromTextUI(Value, pi, args.Text.TrimEnd()); }
/// <summary> /// Calls <see cref="FarNet.Explorer.SetText"/> and <see cref="OnThisFileChanged"/>. /// </summary> /// <param name="args">.</param> public virtual void UISetText(SetTextEventArgs args) { if (args == null) return; Explorer.SetText(args); if (args.Result != JobResult.Ignore) OnThisFileChanged(args); }
public override void SetText(SetTextEventArgs args) { if (args == null) return; var value = (SettingsPropertyValue)args.File.Data; var ex = ValidatePropertyText(value.Property, args.Text); if (ex != null) { args.Result = JobResult.Ignore; Far.Api.ShowError("Settings", ex); return; } args.File.Description = SetPropertyValueText(value, args.Text); CompleteFileData(args.File, value); }
/// <inheritdoc/> public override void UISetText(SetTextEventArgs args) { if (args == null) return; // call base.UISetText(args); if (args.Result != JobResult.Done) return; // update after edit if (0 != (args.Mode & ExplorerModes.Edit)) //????? in many cases it is not needed, think to avoid/do effectively UpdateRedraw(true); }
/// <summary> /// <see cref="Explorer.SetText"/> worker. /// </summary> /// <param name="args">.</param> public virtual void DoSetText(SetTextEventArgs args) { base.SetText(args); }
/// <include file='doc.xml' path='doc/ScriptFork/*'/> /// <param name="args">.</param> public override sealed void SetText(SetTextEventArgs args) { if (AsSetText == null) DoSetText(args); else A.InvokeScriptReturnAsIs(AsSetText, this, args); }
/// <summary> /// <see cref="Explorer.SetText"/> worker. /// </summary> /// <param name="args">.</param> public virtual void DoSetText(SetTextEventArgs args) { base.SetText(args); }
/// <summary> /// Sets the file content given the text string. /// </summary> /// <param name="args">.</param> /// <remarks> /// If this method is used then <see cref="Functions"/> should contain the <see cref="ExplorerFunctions.SetText"/> flag. /// </remarks> public virtual void SetText(SetTextEventArgs args) { if (args != null) args.Result = JobResult.Default; }
/// <inheritdoc/> public override void SetText(SetTextEventArgs args) { if (args == null) return; PSPropertyInfo pi = args.File.Data as PSPropertyInfo; if (pi == null) { args.Result = JobResult.Ignore; return; } try { object value; string text = args.Text.TrimEnd(); if (pi.TypeNameOfValue.EndsWith("]", StringComparison.Ordinal)) { ArrayList lines = new ArrayList(); foreach (var line in FarNet.Works.Kit.SplitLines(text)) lines.Add(line); value = lines; } else { value = text; } A.SetPropertyValue(ItemPath, pi.Name, Converter.Parse(pi, value)); PropertyPanel.WhenPropertyChanged(ItemPath); } catch (RuntimeException ex) { if (args.UI) A.Msg(ex); } }
/// <inheritdoc/> public override void DoSetText(SetTextEventArgs args) { if (args == null) return; try { // path string path = My.PathEx.Combine(Location, args.File.Name); // read string text = args.Text.TrimEnd(); // set if (!A.SetContentUI(path, text)) return; } catch (RuntimeException ex) { if (args.UI) A.Message(ex.Message); } }