mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<FolderDailog>: use Ookii.Dialog.Wpf instead of Views.Controls.FolderDailog
This commit is contained in:
parent
8c8109dc60
commit
598f940cf3
11 changed files with 15 additions and 148 deletions
|
@ -6,7 +6,7 @@ cd src
|
||||||
rmdir /s /q bin
|
rmdir /s /q bin
|
||||||
rmdir /s /q obj
|
rmdir /s /q obj
|
||||||
dotnet publish SourceGit_48.csproj --nologo -c Release -r win-x86 -o ..\publish\net48
|
dotnet publish SourceGit_48.csproj --nologo -c Release -r win-x86 -o ..\publish\net48
|
||||||
ilrepack /ndebug /out:..\publish\SourceGit.exe ..\publish\net48\SourceGit.exe ..\publish\net48\Newtonsoft.Json.dll
|
ilrepack /ndebug /out:..\publish\SourceGit.exe ..\publish\net48\SourceGit.exe ..\publish\net48\Newtonsoft.Json.dll ..\publish\net48\Ookii.Dialogs.Wpf.dll
|
||||||
cd ..\publish
|
cd ..\publish
|
||||||
ren SourceGit.exe SourceGit_48.exe
|
ren SourceGit.exe SourceGit_48.exe
|
||||||
rmdir /s /q net48
|
rmdir /s /q net48
|
||||||
|
|
|
@ -305,7 +305,6 @@
|
||||||
<sys:String x:Key="Text.Welcome.Clone">Clone Remote Repository</sys:String>
|
<sys:String x:Key="Text.Welcome.Clone">Clone Remote Repository</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.Repositories">REPOSITORIES</sys:String>
|
<sys:String x:Key="Text.Welcome.Repositories">REPOSITORIES</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.DragDrop">DRAG-DROP YOUR FOLDER</sys:String>
|
<sys:String x:Key="Text.Welcome.DragDrop">DRAG-DROP YOUR FOLDER</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.OpenOrInitDialog">Open or init local repository</sys:String>
|
|
||||||
<sys:String x:Key="Text.Welcome.NewFolder">Add Folder</sys:String>
|
<sys:String x:Key="Text.Welcome.NewFolder">Add Folder</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.NewSubFolder">Add Sub-Folder</sys:String>
|
<sys:String x:Key="Text.Welcome.NewSubFolder">Add Sub-Folder</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.Rename">Rename</sys:String>
|
<sys:String x:Key="Text.Welcome.Rename">Rename</sys:String>
|
||||||
|
@ -381,7 +380,6 @@
|
||||||
<sys:String x:Key="Text.Preference.Merger.Path.Placeholder">Input path for merge tool</sys:String>
|
<sys:String x:Key="Text.Preference.Merger.Path.Placeholder">Input path for merge tool</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Merger.Cmd">Command :</sys:String>
|
<sys:String x:Key="Text.Preference.Merger.Cmd">Command :</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Dialog.GitExe">Select Git Executable File</sys:String>
|
<sys:String x:Key="Text.Preference.Dialog.GitExe">Select Git Executable File</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Dialog.GitDir">Select default clone path</sys:String>
|
|
||||||
<sys:String x:Key="Text.Preference.Dialog.Merger">Select {0} Install Path</sys:String>
|
<sys:String x:Key="Text.Preference.Dialog.Merger">Select {0} Install Path</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Stash">Stash</sys:String>
|
<sys:String x:Key="Text.Stash">Stash</sys:String>
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
<sys:String x:Key="Text.Goto">点击前往</sys:String>
|
<sys:String x:Key="Text.Goto">点击前往</sys:String>
|
||||||
<sys:String x:Key="Text.RevealFile">在文件浏览器中查看</sys:String>
|
<sys:String x:Key="Text.RevealFile">在文件浏览器中查看</sys:String>
|
||||||
<sys:String x:Key="Text.SaveAs">另存为...</sys:String>
|
<sys:String x:Key="Text.SaveAs">另存为...</sys:String>
|
||||||
<sys:String x:Key="Text.SaveFileTo">另存文件到...</sys:String>
|
|
||||||
<sys:String x:Key="Text.CopyPath">复制路径</sys:String>
|
<sys:String x:Key="Text.CopyPath">复制路径</sys:String>
|
||||||
<sys:String x:Key="Text.Bytes">{0} 字节</sys:String>
|
<sys:String x:Key="Text.Bytes">{0} 字节</sys:String>
|
||||||
<sys:String x:Key="Text.Filter">过滤</sys:String>
|
<sys:String x:Key="Text.Filter">过滤</sys:String>
|
||||||
|
@ -305,7 +304,6 @@
|
||||||
<sys:String x:Key="Text.Welcome.Clone">克隆远程仓库</sys:String>
|
<sys:String x:Key="Text.Welcome.Clone">克隆远程仓库</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.Repositories">仓库列表</sys:String>
|
<sys:String x:Key="Text.Welcome.Repositories">仓库列表</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.DragDrop">支持拖放操作</sys:String>
|
<sys:String x:Key="Text.Welcome.DragDrop">支持拖放操作</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.OpenOrInitDialog">打开/初始化本地仓库</sys:String>
|
|
||||||
<sys:String x:Key="Text.Welcome.NewFolder">新建分组</sys:String>
|
<sys:String x:Key="Text.Welcome.NewFolder">新建分组</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.NewSubFolder">新建子分组</sys:String>
|
<sys:String x:Key="Text.Welcome.NewSubFolder">新建子分组</sys:String>
|
||||||
<sys:String x:Key="Text.Welcome.Rename">重命名</sys:String>
|
<sys:String x:Key="Text.Welcome.Rename">重命名</sys:String>
|
||||||
|
@ -381,7 +379,6 @@
|
||||||
<sys:String x:Key="Text.Preference.Merger.Path.Placeholder">填写工具可执行文件所在位置</sys:String>
|
<sys:String x:Key="Text.Preference.Merger.Path.Placeholder">填写工具可执行文件所在位置</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Merger.Cmd">命令行参数 :</sys:String>
|
<sys:String x:Key="Text.Preference.Merger.Cmd">命令行参数 :</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Dialog.GitExe">选择git.exe所在位置</sys:String>
|
<sys:String x:Key="Text.Preference.Dialog.GitExe">选择git.exe所在位置</sys:String>
|
||||||
<sys:String x:Key="Text.Preference.Dialog.GitDir">选择仓库本地存放位置</sys:String>
|
|
||||||
<sys:String x:Key="Text.Preference.Dialog.Merger">选择{0}所在位置</sys:String>
|
<sys:String x:Key="Text.Preference.Dialog.Merger">选择{0}所在位置</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Stash">贮藏</sys:String>
|
<sys:String x:Key="Text.Stash">贮藏</sys:String>
|
||||||
|
|
|
@ -17,4 +17,7 @@
|
||||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Ookii.Dialogs.Wpf" Version="3.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -21,5 +21,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
<PackageReference Include="Ookii.Dialogs.Wpf" Version="3.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,137 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
namespace SourceGit.Views.Controls {
|
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
|
||||||
internal delegate Int32 BrowseCallbackProc(IntPtr hwnd, Int32 msg, IntPtr lParam, IntPtr lpData);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
|
||||||
internal class BrowseInfo {
|
|
||||||
public IntPtr hwndOwner;
|
|
||||||
public IntPtr pidlRoot;
|
|
||||||
public IntPtr pszDisplayName;
|
|
||||||
public String lpszTitle;
|
|
||||||
public Int32 ulFlags;
|
|
||||||
public BrowseCallbackProc lpfn;
|
|
||||||
public IntPtr lParam;
|
|
||||||
public Int32 iImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Win32 API封装(user32.dll)
|
|
||||||
/// </summary>
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
|
||||||
internal static class User32 {
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern IntPtr SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, String lParam);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern IntPtr SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Win32 API封装(ole32.dll)
|
|
||||||
/// </summary>
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
|
||||||
internal static class Ole32 {
|
|
||||||
[DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
|
|
||||||
internal static extern void CoTaskMemFree(IntPtr pv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Win32 API封装(shell32.dll)
|
|
||||||
/// </summary>
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
|
||||||
internal static class Shell32 {
|
|
||||||
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern Boolean SHGetPathFromIDList(IntPtr pidl, IntPtr pszPath);
|
|
||||||
|
|
||||||
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern IntPtr SHBrowseForFolder([In] BrowseInfo lpbi);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 调用WindowsAPI打开对话目录对话框
|
|
||||||
/// </summary>
|
|
||||||
public class FolderDialog : Microsoft.Win32.CommonDialog {
|
|
||||||
/// <summary>
|
|
||||||
/// 描述信息
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 选中的目录
|
|
||||||
/// </summary>
|
|
||||||
public string SelectedPath { get; private set; }
|
|
||||||
|
|
||||||
public FolderDialog(string descKey) {
|
|
||||||
Description = App.Text(descKey);
|
|
||||||
SelectedPath = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Reset() {
|
|
||||||
Description = string.Empty;
|
|
||||||
SelectedPath = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool RunDialog(IntPtr hwndOwner) {
|
|
||||||
BrowseCallbackProc callback = new BrowseCallbackProc(BrowseCallbackHandler);
|
|
||||||
IntPtr displayName = Marshal.AllocHGlobal(260 * Marshal.SystemDefaultCharSize);
|
|
||||||
bool ok = false;
|
|
||||||
try {
|
|
||||||
var info = new BrowseInfo();
|
|
||||||
info.pidlRoot = IntPtr.Zero;
|
|
||||||
info.hwndOwner = hwndOwner;
|
|
||||||
info.pszDisplayName = displayName;
|
|
||||||
info.lpszTitle = Description;
|
|
||||||
info.ulFlags = 0x0040;
|
|
||||||
info.lpfn = callback;
|
|
||||||
info.lParam = IntPtr.Zero;
|
|
||||||
info.iImage = 0;
|
|
||||||
|
|
||||||
IntPtr result = Shell32.SHBrowseForFolder(info);
|
|
||||||
if (result != IntPtr.Zero) {
|
|
||||||
IntPtr pathPtr = Marshal.AllocHGlobal(260 * Marshal.SystemDefaultCharSize);
|
|
||||||
Shell32.SHGetPathFromIDList(result, pathPtr);
|
|
||||||
|
|
||||||
if (pathPtr != IntPtr.Zero) {
|
|
||||||
SelectedPath = Marshal.PtrToStringAuto(pathPtr);
|
|
||||||
ok = true;
|
|
||||||
Marshal.FreeHGlobal(pathPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ole32.CoTaskMemFree(result);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (displayName != IntPtr.Zero) Marshal.FreeHGlobal(displayName);
|
|
||||||
callback = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Int32 BrowseCallbackHandler(IntPtr hwnd, Int32 msg, IntPtr lParam, IntPtr lpData) {
|
|
||||||
switch (msg) {
|
|
||||||
case 1:
|
|
||||||
if (!string.IsNullOrEmpty(SelectedPath)) {
|
|
||||||
Int32 flag = Marshal.SystemDefaultCharSize == 1 ? 1126 : 1127;
|
|
||||||
User32.SendMessage(new HandleRef(null, hwnd), flag, 1, SelectedPath);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (lParam != IntPtr.Zero) {
|
|
||||||
IntPtr pathPtr = Marshal.AllocHGlobal(260 * Marshal.SystemDefaultCharSize);
|
|
||||||
bool flag = Shell32.SHGetPathFromIDList(lParam, pathPtr);
|
|
||||||
Marshal.FreeHGlobal(pathPtr);
|
|
||||||
User32.SendMessage(new HandleRef(null, hwnd), 1125, 0, flag ? 1 : 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ namespace SourceGit.Views.Popups {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFolderSelectorClick(object sender, System.Windows.RoutedEventArgs e) {
|
private void OnFolderSelectorClick(object sender, System.Windows.RoutedEventArgs e) {
|
||||||
var dialog = new Controls.FolderDialog("Clone.Folder.Placeholder");
|
var dialog = new VistaFolderBrowserDialog();
|
||||||
if (dialog.ShowDialog() == true) {
|
if (dialog.ShowDialog() == true) {
|
||||||
Folder = dialog.SelectedPath;
|
Folder = dialog.SelectedPath;
|
||||||
txtFolder.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
txtFolder.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -61,7 +62,7 @@ namespace SourceGit.Views {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectGitCloneDir(object sender, RoutedEventArgs e) {
|
private void SelectGitCloneDir(object sender, RoutedEventArgs e) {
|
||||||
var dialog = new Controls.FolderDialog("Preference.Dialog.GitDir");
|
var dialog = new VistaFolderBrowserDialog();
|
||||||
if (dialog.ShowDialog() == true) {
|
if (dialog.ShowDialog() == true) {
|
||||||
Models.Preference.Instance.Git.DefaultCloneDir = dialog.SelectedPath;
|
Models.Preference.Instance.Git.DefaultCloneDir = dialog.SelectedPath;
|
||||||
txtGitCloneDir?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
txtGitCloneDir?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -348,7 +349,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
var saveToPatch = new MenuItem();
|
var saveToPatch = new MenuItem();
|
||||||
saveToPatch.Header = App.Text("CommitCM.SaveAsPatch");
|
saveToPatch.Header = App.Text("CommitCM.SaveAsPatch");
|
||||||
saveToPatch.Click += (o, e) => {
|
saveToPatch.Click += (o, e) => {
|
||||||
var dialog = new Controls.FolderDialog("SaveFileTo");
|
var dialog = new VistaFolderBrowserDialog();
|
||||||
if (dialog.ShowDialog() == true) {
|
if (dialog.ShowDialog() == true) {
|
||||||
new Commands.FormatPatch(repo.Path, commit.SHA, dialog.SelectedPath).Exec();
|
new Commands.FormatPatch(repo.Path, commit.SHA, dialog.SelectedPath).Exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -295,7 +296,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
saveAs.Header = App.Text("SaveAs");
|
saveAs.Header = App.Text("SaveAs");
|
||||||
saveAs.IsEnabled = node.Type == Models.ObjectType.Blob;
|
saveAs.IsEnabled = node.Type == Models.ObjectType.Blob;
|
||||||
saveAs.Click += (obj, ev) => {
|
saveAs.Click += (obj, ev) => {
|
||||||
var dialog = new Controls.FolderDialog("SaveFileTo");
|
var dialog = new VistaFolderBrowserDialog();
|
||||||
if (dialog.ShowDialog() == true) {
|
if (dialog.ShowDialog() == true) {
|
||||||
var full = Path.Combine(dialog.SelectedPath, Path.GetFileName(node.Path));
|
var full = Path.Combine(dialog.SelectedPath, Path.GetFileName(node.Path));
|
||||||
new Commands.SaveRevisionFile(repo, node.Path, sha, full).Exec();
|
new Commands.SaveRevisionFile(repo, node.Path, sha, full).Exec();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -47,7 +48,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
#region FUNC_EVENTS
|
#region FUNC_EVENTS
|
||||||
private void OnOpenClicked(object sender, RoutedEventArgs e) {
|
private void OnOpenClicked(object sender, RoutedEventArgs e) {
|
||||||
var dialog = new Controls.FolderDialog("Welcome.OpenOrInitDialog");
|
var dialog = new VistaFolderBrowserDialog();
|
||||||
if (dialog.ShowDialog() == true) CheckAndOpen(dialog.SelectedPath);
|
if (dialog.ShowDialog() == true) CheckAndOpen(dialog.SelectedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue