文件打开功能。未实现文件类型保存
This commit is contained in:
parent
19d498cdd5
commit
c0f2a1ab6e
|
@ -13,5 +13,9 @@
|
||||||
/// 文件内容
|
/// 文件内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[]? FileContent { get; set; }
|
public byte[]? FileContent { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文件类型 .jpj .txt等
|
||||||
|
/// </summary>
|
||||||
|
public string? FileType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
CalendarNotepad/WorkMain.Designer.cs
generated
21
CalendarNotepad/WorkMain.Designer.cs
generated
|
@ -77,6 +77,7 @@
|
||||||
panel2 = new Panel();
|
panel2 = new Panel();
|
||||||
panel3 = new Panel();
|
panel3 = new Panel();
|
||||||
OpenFileDlg = new OpenFileDialog();
|
OpenFileDlg = new OpenFileDialog();
|
||||||
|
打开ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
tabControl1.SuspendLayout();
|
tabControl1.SuspendLayout();
|
||||||
tpWorkManage.SuspendLayout();
|
tpWorkManage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||||
|
@ -419,35 +420,35 @@
|
||||||
//
|
//
|
||||||
// cms_FileList
|
// cms_FileList
|
||||||
//
|
//
|
||||||
cms_FileList.Items.AddRange(new ToolStripItem[] { 删除ToolStripMenuItem,导入ToolStripMenuItem,下载ToolStripMenuItem,更名ToolStripMenuItem });
|
cms_FileList.Items.AddRange(new ToolStripItem[] { 删除ToolStripMenuItem,导入ToolStripMenuItem,下载ToolStripMenuItem,更名ToolStripMenuItem,打开ToolStripMenuItem });
|
||||||
cms_FileList.Name = "contextMenuStrip1";
|
cms_FileList.Name = "contextMenuStrip1";
|
||||||
cms_FileList.Size = new Size(101,92);
|
cms_FileList.Size = new Size(181,136);
|
||||||
//
|
//
|
||||||
// 删除ToolStripMenuItem
|
// 删除ToolStripMenuItem
|
||||||
//
|
//
|
||||||
删除ToolStripMenuItem.Name = "删除ToolStripMenuItem";
|
删除ToolStripMenuItem.Name = "删除ToolStripMenuItem";
|
||||||
删除ToolStripMenuItem.Size = new Size(100,22);
|
删除ToolStripMenuItem.Size = new Size(180,22);
|
||||||
删除ToolStripMenuItem.Text = "删除";
|
删除ToolStripMenuItem.Text = "删除";
|
||||||
删除ToolStripMenuItem.Click += 删除ToolStripMenuItem_Click;
|
删除ToolStripMenuItem.Click += 删除ToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// 导入ToolStripMenuItem
|
// 导入ToolStripMenuItem
|
||||||
//
|
//
|
||||||
导入ToolStripMenuItem.Name = "导入ToolStripMenuItem";
|
导入ToolStripMenuItem.Name = "导入ToolStripMenuItem";
|
||||||
导入ToolStripMenuItem.Size = new Size(100,22);
|
导入ToolStripMenuItem.Size = new Size(180,22);
|
||||||
导入ToolStripMenuItem.Text = "导入";
|
导入ToolStripMenuItem.Text = "导入";
|
||||||
导入ToolStripMenuItem.Click += 导入ToolStripMenuItem_Click;
|
导入ToolStripMenuItem.Click += 导入ToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// 下载ToolStripMenuItem
|
// 下载ToolStripMenuItem
|
||||||
//
|
//
|
||||||
下载ToolStripMenuItem.Name = "下载ToolStripMenuItem";
|
下载ToolStripMenuItem.Name = "下载ToolStripMenuItem";
|
||||||
下载ToolStripMenuItem.Size = new Size(100,22);
|
下载ToolStripMenuItem.Size = new Size(180,22);
|
||||||
下载ToolStripMenuItem.Text = "下载";
|
下载ToolStripMenuItem.Text = "下载";
|
||||||
下载ToolStripMenuItem.Click += 下载ToolStripMenuItem_Click;
|
下载ToolStripMenuItem.Click += 下载ToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// 更名ToolStripMenuItem
|
// 更名ToolStripMenuItem
|
||||||
//
|
//
|
||||||
更名ToolStripMenuItem.Name = "更名ToolStripMenuItem";
|
更名ToolStripMenuItem.Name = "更名ToolStripMenuItem";
|
||||||
更名ToolStripMenuItem.Size = new Size(100,22);
|
更名ToolStripMenuItem.Size = new Size(180,22);
|
||||||
更名ToolStripMenuItem.Text = "更名";
|
更名ToolStripMenuItem.Text = "更名";
|
||||||
更名ToolStripMenuItem.Click += 更名ToolStripMenuItem_Click;
|
更名ToolStripMenuItem.Click += 更名ToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
@ -629,6 +630,13 @@
|
||||||
//
|
//
|
||||||
OpenFileDlg.Multiselect = true;
|
OpenFileDlg.Multiselect = true;
|
||||||
//
|
//
|
||||||
|
// 打开ToolStripMenuItem
|
||||||
|
//
|
||||||
|
打开ToolStripMenuItem.Name = "打开ToolStripMenuItem";
|
||||||
|
打开ToolStripMenuItem.Size = new Size(180,22);
|
||||||
|
打开ToolStripMenuItem.Text = "打开";
|
||||||
|
打开ToolStripMenuItem.Click += 打开ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// WorkMain
|
// WorkMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F,17F);
|
AutoScaleDimensions = new SizeF(7F,17F);
|
||||||
|
@ -727,5 +735,6 @@
|
||||||
private Button bt_m_dbshc;
|
private Button bt_m_dbshc;
|
||||||
private Label label5;
|
private Label label5;
|
||||||
private ToolStripMenuItem 更名ToolStripMenuItem;
|
private ToolStripMenuItem 更名ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem 打开ToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -390,6 +390,52 @@ namespace CalendarNotepad
|
||||||
MessageBox.Show("文件名修改完成");
|
MessageBox.Show("文件名修改完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void 打开ToolStripMenuItem_Click(object sender,EventArgs e) {
|
||||||
|
var items = this.FileListView.SelectedItems;
|
||||||
|
if(items.Count == 0) {
|
||||||
|
MessageBox.Show("必须要选择打开的文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(items.Count > 1) {
|
||||||
|
MessageBox.Show("不能同时打开对多个文件,只能选择一个");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var item = items[0];
|
||||||
|
var fk = item.SubItems[2].Text;
|
||||||
|
var fileNam = item.Text;
|
||||||
|
var qu = this.Db.Queryable<PlusFileUnit>()
|
||||||
|
.Where(a => a.FileId == fk)
|
||||||
|
.Select(a => a.FileContent)
|
||||||
|
.ToList();
|
||||||
|
if(!qu.Any() || qu.First() == null) {
|
||||||
|
MessageBox.Show("打开文件错误,没有找到文件,需要重新导入文件!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var fc = qu.First();
|
||||||
|
var tempPath = Path.GetTempPath();
|
||||||
|
var ran = new Random();
|
||||||
|
var fn = ran.NextInt64(10000,99999).ToString();
|
||||||
|
var path = Path.Combine(tempPath,"CalendarNotepadFile");
|
||||||
|
if(!Directory.Exists(path)) {
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
var fullPath = Path.Combine(path,fn + ".txt");
|
||||||
|
using(var fs = File.Create(fullPath,fc.Length)) {
|
||||||
|
fs.Write(fc,0,fc.Length);
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
Process process = new Process();
|
||||||
|
process.StartInfo.FileName = fullPath;
|
||||||
|
process.StartInfo.UseShellExecute = true;
|
||||||
|
process.EnableRaisingEvents = true;
|
||||||
|
process.Exited += new EventHandler((s,e) => {
|
||||||
|
File.Delete(fullPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 启动进程
|
||||||
|
process.Start();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前记录日志的键
|
/// 当前记录日志的键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user