private void ExportMemoFile(StringBuilder buf, IEditor editor) { if (_isForClipboard) { return; } var file = editor.Model as MemoFile; if (file == null) { return; } var sfilepath = MemoFileEditorHelper.GetFullPath(file); if (!File.Exists(sfilepath)) { return; } var filedir = "File_" + _fileIndex.ToString(); var filename = Path.GetFileName(sfilepath); var rfilepath = Path.Combine(filedir, filename); var tfilepath = Path.Combine(_outputDir.FullName, rfilepath); PathUtil.EnsureDirectoryExists(Path.GetDirectoryName(tfilepath)); File.Copy(sfilepath, tfilepath, true); ++_fileIndex; buf.AppendLine(string.Format("<p><a href=\"{0}\">{1}</a></p>", rfilepath, filename)); }
private void InitItems() { _open = new ToolStripMenuItem(); _open.Text = "開く(&O)"; _open.Click += (sender, e) => { var memoFile = _owner.Model; var path = MemoFileEditorHelper.GetFullPath(memoFile); try { Process.Start(path); } catch (Exception ex) { Logger.Warn("Cannot open: path=" + path, ex); MessageBox.Show( memoFile.Path + "を開けませんでした", "ファイルオープンエラー", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }; _openParentFolder = new ToolStripMenuItem(); _openParentFolder.Text = "親フォルダを開く(&P)"; _openParentFolder.Click += (sender, e) => { var memoFile = _owner.Model; var path = MemoFileEditorHelper.GetFullPath(memoFile); var parent = Path.GetDirectoryName(path); try { Process.Start(parent); } catch (Exception ex) { Logger.Warn("Cannot open: path=" + path, ex); MessageBox.Show( parent + "を開けませんでした", "ファイルオープンエラー", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }; _export = new ToolStripMenuItem("取り出す(&E)"); var exportFile = new ToolStripMenuItem("ファイル(&F)..."); exportFile.Click += (sender, e) => { var memoFile = _owner.Model; var dialog = new SaveFileDialog(); dialog.RestoreDirectory = true; dialog.ShowHelp = true; dialog.FileName = Path.GetFileName(memoFile.Path); dialog.Filter = "All Files(*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { var outputPath = dialog.FileName; _owner.Host.RequestExport("File", outputPath); } }; _export.DropDownItems.Add(exportFile); }
//public override void DisposeModel(object model) { // /// .embededのファイルを削除予約 // var filePath = MemoFileEditorHelper.GetEmbeddedFileDirectoryPath(Model); // var trashPath = MemoFileEditorHelper.GetEmbeddedTrashDirectoryPath(Model); // if (Directory.Exists(trashPath)) { // Directory.Delete(trashPath, true); // } // Directory.Move(filePath, trashPath); // base.DisposeModel(model); //} //public override void RestoreModel(object model) { // base.RestoreModel(model); // /// .embeddedのファイルの削除予約解除 // var filePath = MemoFileEditorHelper.GetEmbeddedFileDirectoryPath(Model); // var trashPath = MemoFileEditorHelper.GetEmbeddedTrashDirectoryPath(Model); // if (Directory.Exists(filePath)) { // Directory.Delete(filePath, true); // } // Directory.Move(trashPath, filePath); //} private void ExportFile(IEditor editor, string outputPath) { var memoFile = Model; var path = MemoFileEditorHelper.GetFullPath(memoFile); if (File.Exists(path)) { File.Copy(path, outputPath, true); } }
public override object GetTranserInitArgs() { if (Model.IsEmbedded) { return(MemoFileEditorHelper.GetFullPath(Model)); } else { return(null); } }
private void UpdateItemEnabled() { var memoFile = _owner.Model; if (memoFile == null || memoFile.IsEmbedded) { _openParentFolder.Enabled = false; } else { var path = MemoFileEditorHelper.GetFullPath(memoFile); var parent = Path.GetDirectoryName(path); _openParentFolder.Enabled = parent != null; _export.Enabled = File.Exists(path) && !Directory.Exists(path); } }
// ======================================== // field // ======================================== // ======================================== // constructor // ======================================== // ======================================== // property // ======================================== // ======================================== // method // ======================================== protected override void OnFigureMouseDoubleClick(MouseEventArgs e) { base.OnFigureMouseDoubleClick(e); var memoFile = Host.Model as MemoFile; if (memoFile != null) { var path = MemoFileEditorHelper.GetFullPath(memoFile); try { Process.Start(path); } catch (Exception ex) { Logger.Warn("Cannot open: path=" + path, ex); MessageBox.Show( memoFile.Path + "を開けませんでした", "ファイルオープンエラー", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }