mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
optimize<ContextMenu>: do NOT show popup animation
This commit is contained in:
parent
ee8efa5c47
commit
50ad4a0278
4 changed files with 28 additions and 30 deletions
|
@ -104,4 +104,6 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<PopupAnimation x:Key="{x:Static SystemParameters.MenuPopupAnimationKey}">None</PopupAnimation>
|
||||
</ResourceDictionary>
|
|
@ -80,10 +80,10 @@ namespace SourceGit.Views.Widgets {
|
|||
return;
|
||||
}
|
||||
|
||||
Diff(repo, opt, false);
|
||||
Diff(repo, opt);
|
||||
}
|
||||
|
||||
public void Diff(string repo, Option opt, bool clearEditor = true) {
|
||||
public void Diff(string repo, Option opt) {
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
noChange.Visibility = Visibility.Collapsed;
|
||||
sizeChange.Visibility = Visibility.Collapsed;
|
||||
|
@ -92,7 +92,6 @@ namespace SourceGit.Views.Widgets {
|
|||
loading.IsAnimating = true;
|
||||
|
||||
SetTitle(opt.Path, opt.OrgPath);
|
||||
if (clearEditor) ClearEditor();
|
||||
ClearCache();
|
||||
|
||||
this.repo = repo;
|
||||
|
@ -390,6 +389,8 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
private DataGrid CreateTextEditor(string[] lineNumbers) {
|
||||
var grid = new DataGrid();
|
||||
grid.EnableRowVirtualization = true;
|
||||
grid.EnableColumnVirtualization = true;
|
||||
grid.RowHeight = 16.0;
|
||||
grid.FrozenColumnCount = lineNumbers.Length;
|
||||
grid.ContextMenuOpening += OnTextDiffContextMenuOpening;
|
||||
|
|
|
@ -99,6 +99,12 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
if (e.Target == null) {
|
||||
if (e.HasOthers) {
|
||||
if (container.IsUnstaged) {
|
||||
stagedContainer.UnselectAll();
|
||||
} else {
|
||||
unstagedContainer.UnselectAll();
|
||||
}
|
||||
|
||||
mergePanel.Visibility = Visibility.Collapsed;
|
||||
diffViewer.Reset();
|
||||
}
|
||||
|
@ -106,15 +112,14 @@ namespace SourceGit.Views.Widgets {
|
|||
return;
|
||||
}
|
||||
|
||||
mergePanel.Visibility = Visibility.Collapsed;
|
||||
diffViewer.Reset();
|
||||
|
||||
var change = e.Target;
|
||||
if (change.IsConflit) {
|
||||
mergePanel.Visibility = Visibility.Visible;
|
||||
return;
|
||||
}
|
||||
|
||||
mergePanel.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (change.IsAddedToIndex) {
|
||||
unstagedContainer.UnselectAll();
|
||||
|
||||
|
|
|
@ -319,11 +319,10 @@ namespace SourceGit.Views.Widgets {
|
|||
stream.Close();
|
||||
}
|
||||
|
||||
private void OpenUnstagedContextMenuByNodes(List<ChangeNode> nodes, List<Models.Change> changes) {
|
||||
private void OpenUnstagedContextMenuByNodes(ContextMenu menu, List<ChangeNode> nodes, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (nodes.Count == 1) {
|
||||
var node = nodes[0];
|
||||
var path = Path.GetFullPath(Path.Combine(repo, node.Path));
|
||||
|
@ -441,15 +440,12 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(stash);
|
||||
menu.Items.Add(patch);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
}
|
||||
|
||||
private void OpenUnstagedContextMenuByChanges(List<Models.Change> changes) {
|
||||
private void OpenUnstagedContextMenuByChanges(ContextMenu menu, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (changes.Count == 1) {
|
||||
var change = changes[0];
|
||||
var path = Path.GetFullPath(Path.Combine(repo, change.Path));
|
||||
|
@ -566,8 +562,6 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(stash);
|
||||
menu.Items.Add(patch);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -587,11 +581,10 @@ namespace SourceGit.Views.Widgets {
|
|||
Models.Watcher.Get(repo)?.RefreshWC();
|
||||
}
|
||||
|
||||
private void OpenStagedContextMenuByNodes(List<ChangeNode> nodes, List<Models.Change> changes) {
|
||||
private void OpenStagedContextMenuByNodes(ContextMenu menu, List<ChangeNode> nodes, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (nodes.Count == 1) {
|
||||
var node = nodes[0];
|
||||
var path = Path.GetFullPath(Path.Combine(repo, node.Path));
|
||||
|
@ -628,15 +621,12 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
menu.Items.Add(unstage);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
}
|
||||
|
||||
private void OpenStagedContextMenuByChanges(List<Models.Change> changes) {
|
||||
private void OpenStagedContextMenuByChanges(ContextMenu menu, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (changes.Count == 1) {
|
||||
var change = changes[0];
|
||||
var path = Path.GetFullPath(Path.Combine(repo, change.Path));
|
||||
|
@ -678,7 +668,6 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
menu.Items.Add(unstage);
|
||||
}
|
||||
menu.IsOpen = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -696,7 +685,6 @@ namespace SourceGit.Views.Widgets {
|
|||
} else if (modeTree.Selected.Count == 1) {
|
||||
var node = modeTree.Selected[0] as ChangeNode;
|
||||
if (node.IsFolder) {
|
||||
if (DiffTarget == null) return;
|
||||
DiffTarget = null;
|
||||
hasOthers = true;
|
||||
} else {
|
||||
|
@ -760,12 +748,14 @@ namespace SourceGit.Views.Widgets {
|
|||
GetChangesFromNode(o as ChangeNode, changes);
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (IsUnstaged) {
|
||||
OpenUnstagedContextMenuByNodes(nodes, changes);
|
||||
OpenUnstagedContextMenuByNodes(menu, nodes, changes);
|
||||
} else {
|
||||
OpenStagedContextMenuByNodes(nodes, changes);
|
||||
OpenStagedContextMenuByNodes(menu, nodes, changes);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
ev.Handled = true;
|
||||
}
|
||||
|
||||
|
@ -776,28 +766,28 @@ namespace SourceGit.Views.Widgets {
|
|||
var changes = new List<Models.Change>();
|
||||
if (Mode == Models.Change.DisplayMode.List) {
|
||||
if (!row.IsSelected) {
|
||||
modeList.SelectedItems.Clear();
|
||||
modeList.SelectedItems.Add(row.DataContext);
|
||||
modeList.SelectedItem = row.DataContext;
|
||||
changes.Add(row.DataContext as Models.Change);
|
||||
} else {
|
||||
foreach (var c in modeList.SelectedItems) changes.Add(c as Models.Change);
|
||||
}
|
||||
} else {
|
||||
if (!row.IsSelected) {
|
||||
modeGrid.SelectedItems.Clear();
|
||||
modeGrid.SelectedItems.Add(row.DataContext);
|
||||
modeGrid.SelectedItem = row.DataContext;
|
||||
changes.Add(row.DataContext as Models.Change);
|
||||
} else {
|
||||
foreach (var c in modeGrid.SelectedItems) changes.Add(c as Models.Change);
|
||||
}
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
if (IsUnstaged) {
|
||||
OpenUnstagedContextMenuByChanges(changes);
|
||||
OpenUnstagedContextMenuByChanges(menu, changes);
|
||||
} else {
|
||||
OpenStagedContextMenuByChanges(changes);
|
||||
OpenStagedContextMenuByChanges(menu, changes);
|
||||
}
|
||||
|
||||
menu.IsOpen = true;
|
||||
ev.Handled = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue