feature<WorkingCopy>: supports open selected file with default editor in working copy changes

This commit is contained in:
leo 2023-12-26 17:47:18 +08:00
parent de75f5010b
commit f04ab92efc
3 changed files with 52 additions and 4 deletions

View file

@ -16,6 +16,7 @@
<sys:String x:Key="Text.Optional">Optional.</sys:String>
<sys:String x:Key="Text.OpenFolder">SELECT FOLDER</sys:String>
<sys:String x:Key="Text.Notice">NOTICE</sys:String>
<sys:String x:Key="Text.OpenWith">Open With ...</sys:String>
<sys:String x:Key="Text.URL">URL :</sys:String>
<sys:String x:Key="Text.RepositoryURL">Git Repository URL</sys:String>

View file

@ -15,6 +15,7 @@
<sys:String x:Key="Text.Optional">选填</sys:String>
<sys:String x:Key="Text.OpenFolder">选择文件夹</sys:String>
<sys:String x:Key="Text.Notice">系统提示</sys:String>
<sys:String x:Key="Text.OpenWith">打开文件...</sys:String>
<sys:String x:Key="Text.URL">仓库地址 </sys:String>
<sys:String x:Key="Text.RepositoryURL">远程仓库地址</sys:String>

View file

@ -3,12 +3,14 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Linq;
namespace SourceGit.Views.Widgets {
/// <summary>
@ -430,6 +432,18 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
if (!node.IsFolder && File.Exists(path)) {
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
openWith.Click += (o, e) => {
Process.Start($"\"{path}\"");
e.Handled = true;
};
menu.Items.Add(openWith);
}
var stage = new MenuItem();
stage.Header = App.Text("FileCM.Stage");
stage.Click += (o, e) => {
@ -481,7 +495,6 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
menu.Items.Add(new Separator());
menu.Items.Add(stage);
menu.Items.Add(discard);
@ -576,6 +589,18 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
if (File.Exists(path)) {
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
openWith.Click += (o, e) => {
Process.Start($"\"{path}\"");
e.Handled = true;
};
menu.Items.Add(openWith);
}
var stage = new MenuItem();
stage.Header = App.Text("FileCM.Stage");
stage.Click += (o, e) => {
@ -642,7 +667,6 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
menu.Items.Add(new Separator());
menu.Items.Add(stage);
menu.Items.Add(discard);
@ -738,6 +762,18 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
if (!node.IsFolder && File.Exists(path)) {
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
openWith.Click += (o, e) => {
Process.Start($"\"{path}\"");
e.Handled = true;
};
menu.Items.Add(openWith);
}
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.Unstage");
unstage.Click += (o, e) => {
@ -752,7 +788,6 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
menu.Items.Add(unstage);
menu.Items.Add(copyPath);
} else {
@ -782,6 +817,18 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
if (File.Exists(path)) {
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
openWith.Click += (o, e) => {
Process.Start($"\"{path}\"");
e.Handled = true;
};
menu.Items.Add(openWith);
}
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.Unstage");
unstage.Click += (o, e) => {
@ -796,7 +843,6 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
};
menu.Items.Add(explore);
menu.Items.Add(new Separator());
menu.Items.Add(unstage);
menu.Items.Add(new Separator());