/* ----------------------------------------------------------------- */ /// /// Invoke /// /// <summary> /// Invokes the user action and sets the result message. /// </summary> /// /* ----------------------------------------------------------------- */ private void Invoke(Action action, string format, params object[] args) => Bindable.Invoke(() => { if (_core == null) { return; } action(); Bindable.SetMessage(format, args); });
/* ----------------------------------------------------------------- */ /// /// Save /// /// <summary> /// Saves the PDF document to the specified file path. /// </summary> /// /// <param name="dest">File path.</param> /// <param name="reopen"> /// Value indicating whether restructuring some inner fields /// after saving. /// </param> /// /* ----------------------------------------------------------------- */ public void Save(string dest, bool reopen) => Invoke(() => { Bindable.SetMessage(Properties.Resources.MessageSaving, dest); this.Save(Settings.IO.Get(dest), () => _core.Clear()); if (reopen) { this.Restruct(_core.GetOrAdd(dest, Bindable.Encryption.OwnerPassword)); } }, "");
/* ----------------------------------------------------------------- */ /// /// Open /// /// <summary> /// Opens a PDF document with the specified file path. /// </summary> /// /// <param name="src">File path.</param> /// /* ----------------------------------------------------------------- */ public void Open(string src) { if (!src.HasValue()) { return; } if (Bindable.IsOpen()) { this.StartProcess(src.Quote()); } else { Invoke(() => { Bindable.SetMessage(Properties.Resources.MessageLoading, src); Bindable.Open(_core.GetOrAdd(src)); }, ""); } }
/* ----------------------------------------------------------------- */ /// /// Insert /// /// <summary> /// Inserts the specified files at the specified index. /// </summary> /// /// <param name="index">Insertion index.</param> /// <param name="src">Inserting files.</param> /// /* ----------------------------------------------------------------- */ public void Insert(int index, IEnumerable <string> src) => Invoke(() => Bindable.Images.InsertAt( Math.Min(Math.Max(index, 0), Bindable.Images.Count), src.SelectMany(e => { Bindable.SetMessage(Properties.Resources.MessageLoading, e); if (!this.IsInsertable(e)) { return(new Page[0]); } else if (e.IsPdf()) { return(_core.GetOrAdd(e).Pages); } else { return(Settings.IO.GetImagePages(e)); } }) ), "");