diff --git a/PasteEx/Data.cs b/PasteEx/Data.cs index 0b8c464..9a5eebe 100644 --- a/PasteEx/Data.cs +++ b/PasteEx/Data.cs @@ -89,6 +89,21 @@ public string[] Analyze() extensions.Add(defaultExt); } } + if (IData.GetDataPresent(DataFormats.FileDrop, false)) + { + if (IData.GetData(DataFormats.FileDrop) is string[] filePaths) + { + if (filePaths.Length == 1) + { + if (!String.IsNullOrEmpty(filePaths[0])) + { + DataStorage.SetData(DataFormats.FileDrop, IData.GetData(DataFormats.FileDrop)); + extensions.Clear(); + extensions.Add(Path.GetExtension(filePaths[0]).Remove(0, 1)); + } + } + } + } extensions.Reverse(); return extensions.ToArray(); @@ -112,7 +127,7 @@ public string GetImageExtension(IDataObject data) { string ext = url.Substring(i + 1); - // a case of "*.png?SomeParameters" + // a case of "*.png?SomeParameters" if (ext.Length > 3) { ext = ext.Substring(0, 3); } if (imageExt.Contains(ext)) { return ext; } else { return null; } @@ -199,6 +214,18 @@ public void SaveAs(string location, string fileName, string extension) try { + // copy file priority + if (DataStorage.GetDataPresent(DataFormats.FileDrop, false)) + { + string[] filePaths = DataStorage.GetData(DataFormats.FileDrop) as string[]; + if (filePaths.Length > 0 && !String.IsNullOrEmpty(filePaths[0])) + { + File.Copy(filePaths[0], path); + } + return; + } + + // html/text/image if (extension == "htmlformat") { File.WriteAllText(path, DataStorage.GetData(DataFormats.Html) as string, Encoding.UTF8); diff --git a/PasteEx/FormMain.cs b/PasteEx/FormMain.cs index 16b54a3..1cef29d 100644 --- a/PasteEx/FormMain.cs +++ b/PasteEx/FormMain.cs @@ -47,13 +47,6 @@ public FormMain(string location) private void FormMain_Load(object sender, EventArgs e) { - if(Properties.Settings.Default.callUpgrade) - { - Properties.Settings.Default.Upgrade(); - Properties.Settings.Default.callUpgrade = false; - Properties.Settings.Default.Save(); - } - data = new Data(Clipboard.GetDataObject()); string[] extensions = data.Analyze(); cboExtension.Items.AddRange(extensions); diff --git a/PasteEx/Resources/Resource-zh-CN.Designer.cs b/PasteEx/Resources/Resource-zh-CN.Designer.cs index 7366b0d..35313cc 100644 --- a/PasteEx/Resources/Resource-zh-CN.Designer.cs +++ b/PasteEx/Resources/Resource-zh-CN.Designer.cs @@ -97,7 +97,7 @@ internal static string LblFileNameText { } /// - /// 查找类似 剪贴板为空,仍旧进入软件主界面? 的本地化字符串。 + /// 查找类似 剪贴板内容为空或不被支持,仍旧进入软件主界面? 的本地化字符串。 /// internal static string TipAnalyzeFailed { get { @@ -187,7 +187,7 @@ internal static string TipRunAsAdmin { } /// - /// 查找类似 保存失败,请选择正确的扩展名 的本地化字符串。 + /// 查找类似 保存失败,可能是选择的扩展名不正确 的本地化字符串。 /// internal static string TipSaveFailed { get { diff --git a/PasteEx/Resources/Resource-zh-CN.resx b/PasteEx/Resources/Resource-zh-CN.resx index e3b6f63..c48b131 100644 --- a/PasteEx/Resources/Resource-zh-CN.resx +++ b/PasteEx/Resources/Resource-zh-CN.resx @@ -130,7 +130,7 @@ 文件名: - 剪贴板为空,仍旧进入软件主界面? + 剪贴板内容为空或不被支持,仍旧进入软件主界面? 存在相同的文件名,是否覆盖? @@ -151,7 +151,7 @@ 添加右键菜单时,请以管理员的身份运行本软件! - 保存失败,请选择正确的扩展名 + 保存失败,可能是选择的扩展名不正确 右键菜单移除成功!