Skip to content

Commit 501aae9

Browse files
committed
project: upgrade dependencies
Signed-off-by: leo <longshuang@msn.cn>
1 parent 050e058 commit 501aae9

11 files changed

+155
-138
lines changed

THIRD-PARTY-LICENSES.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The project uses the following third-party libraries or assets
77
### AvaloniaUI
88

99
- **Source**: https://github.com/AvaloniaUI/Avalonia
10-
- **Version**: 11.3.6
10+
- **Version**: 11.3.7
1111
- **License**: MIT License
1212
- **License Link**: https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md
1313

@@ -35,14 +35,14 @@ The project uses the following third-party libraries or assets
3535
### OpenAI .NET SDK
3636

3737
- **Source**: https://github.com/openai/openai-dotnet
38-
- **Version**: 2.4.0
38+
- **Version**: 2.5.0
3939
- **License**: MIT License
4040
- **License Link**: https://github.com/openai/openai-dotnet/blob/main/LICENSE
4141

4242
### Azure.AI.OpenAI
4343

4444
- **Source**: https://github.com/Azure/azure-sdk-for-net
45-
- **Version**: 2.3.0-beta.2
45+
- **Version**: 2.5.0-beta.1
4646
- **License**: MIT License
4747
- **License Link**: https://github.com/Azure/azure-sdk-for-net/blob/main/LICENSE.txt
4848

src/App.axaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Avalonia.Controls;
1515
using Avalonia.Controls.ApplicationLifetimes;
1616
using Avalonia.Data.Core.Plugins;
17+
using Avalonia.Input.Platform;
1718
using Avalonia.Markup.Xaml;
1819
using Avalonia.Media;
1920
using Avalonia.Media.Fonts;
@@ -324,7 +325,7 @@ public static async Task CopyTextAsync(string data)
324325
public static async Task<string> GetClipboardTextAsync()
325326
{
326327
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow.Clipboard: { } clipboard })
327-
return await clipboard.GetTextAsync();
328+
return await clipboard.TryGetTextAsync();
328329
return null;
329330
}
330331

src/SourceGit.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939
</ItemGroup>
4040

4141
<ItemGroup>
42-
<PackageReference Include="Avalonia" Version="11.3.6" />
43-
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.6" />
44-
<PackageReference Include="Avalonia.Desktop" Version="11.3.6" />
45-
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.6" />
46-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.6" />
47-
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.6" Condition="'$(Configuration)' == 'Debug'" />
42+
<PackageReference Include="Avalonia" Version="11.3.7" />
43+
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.7" />
44+
<PackageReference Include="Avalonia.Desktop" Version="11.3.7" />
45+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.7" />
46+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.7" />
47+
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.7" Condition="'$(Configuration)' == 'Debug'" />
4848
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0" />
4949
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.3.0" />
50-
<PackageReference Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
50+
<PackageReference Include="Azure.AI.OpenAI" Version="2.5.0-beta.1" />
5151
<PackageReference Include="BitMiracle.LibTiff.NET" Version="2.4.660" />
5252
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
5353
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-rc6.1" />
54-
<PackageReference Include="OpenAI" Version="2.4.0" />
54+
<PackageReference Include="OpenAI" Version="2.5.0" />
5555
<PackageReference Include="Pfim" Version="0.11.3" />
5656
<PackageReference Include="TextMateSharp" Version="1.0.70" />
5757
<PackageReference Include="TextMateSharp.Grammars" Version="1.0.70" />

src/ViewModels/Welcome.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ public void AddRootNode()
176176
activePage.Popup = new CreateGroup(null);
177177
}
178178

179+
public RepositoryNode FindNodeById(string id, RepositoryNode root = null)
180+
{
181+
var collection = (root == null) ? Preferences.Instance.RepositoryNodes : root.SubNodes;
182+
foreach (var node in collection)
183+
{
184+
if (node.Id.Equals(id, StringComparison.Ordinal))
185+
return node;
186+
187+
var sub = FindNodeById(id, node);
188+
if (sub != null)
189+
return sub;
190+
}
191+
192+
return null;
193+
}
194+
179195
public RepositoryNode FindParentGroup(RepositoryNode node, RepositoryNode group = null)
180196
{
181197
var collection = (group == null) ? Preferences.Instance.RepositoryNodes : group.SubNodes;

src/Views/BranchOrTagNameTextBox.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Avalonia.Controls;
55
using Avalonia.Input;
6+
using Avalonia.Input.Platform;
67
using Avalonia.Interactivity;
78

89
namespace SourceGit.Views
@@ -51,7 +52,7 @@ private async void OnPastingFromClipboard(object sender, RoutedEventArgs e)
5152
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
5253
if (clipboard != null)
5354
{
54-
var text = await clipboard.GetTextAsync();
55+
var text = await clipboard.TryGetTextAsync();
5556
if (!string.IsNullOrEmpty(text))
5657
OnTextInput(new TextInputEventArgs() { Text = text });
5758
}

src/Views/InteractiveRebase.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@
9494

9595
<!-- Drag & Drop Anchor -->
9696
<Border Grid.Column="0" Background="Transparent"
97-
Loaded="OnSetupRowHeaderDragDrop"
98-
PointerPressed="OnRowHeaderPointerPressed">
97+
PointerPressed="OnRowHeaderPointerPressed"
98+
DragDrop.AllowDrop="True"
99+
DragDrop.DragOver="OnRowHeaderDragOver">
99100
<ToolTip.Tip>
100101
<TextBlock>
101102
<Run Text="{DynamicResource Text.InteractiveRebase.ReorderTip}"/>

src/Views/InteractiveRebase.axaml.cs

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -136,54 +136,62 @@ private void OnRowsSelectionChanged(object _, SelectionChangedEventArgs e)
136136
OpenCommitMessageEditor(items[0]);
137137
}
138138

139-
private void OnSetupRowHeaderDragDrop(object sender, RoutedEventArgs e)
140-
{
141-
if (sender is Border border)
142-
{
143-
DragDrop.SetAllowDrop(border, true);
144-
border.AddHandler(DragDrop.DragOverEvent, OnRowHeaderDragOver);
145-
}
146-
}
147-
148-
private void OnRowHeaderPointerPressed(object sender, PointerPressedEventArgs e)
139+
private async void OnRowHeaderPointerPressed(object sender, PointerPressedEventArgs e)
149140
{
150141
if (sender is Border { DataContext: ViewModels.InteractiveRebaseItem item })
151142
{
152-
var data = new DataObject();
153-
data.Set("InteractiveRebaseItem", item);
154-
DragDrop.DoDragDrop(e, data, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Link);
143+
var data = new DataTransfer();
144+
data.Add(DataTransferItem.Create(_dndItemFormat, item.Commit.SHA));
145+
await DragDrop.DoDragDropAsync(e, data, DragDropEffects.Move);
155146
}
156147
}
157148

158149
private void OnRowHeaderDragOver(object sender, DragEventArgs e)
159150
{
160-
if (DataContext is ViewModels.InteractiveRebase vm &&
161-
e.Data.Contains("InteractiveRebaseItem") &&
162-
e.Data.Get("InteractiveRebaseItem") is ViewModels.InteractiveRebaseItem src &&
163-
sender is Border { DataContext: ViewModels.InteractiveRebaseItem dst } border &&
164-
src != dst)
165-
{
166-
e.DragEffects = DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Link;
151+
if (DataContext is not ViewModels.InteractiveRebase vm)
152+
return;
167153

168-
var p = e.GetPosition(border);
169-
if (p.Y > border.Bounds.Height * 0.33 && p.Y < border.Bounds.Height * 0.67)
154+
if (e.DataTransfer.TryGetValue(_dndItemFormat) is not { Length: > 6 } sha)
155+
return;
156+
157+
ViewModels.InteractiveRebaseItem src = null;
158+
foreach (var item in vm.Items)
159+
{
160+
if (item.Commit.SHA.Equals(sha, StringComparison.Ordinal))
170161
{
171-
var srcIdx = vm.Items.IndexOf(src);
172-
var dstIdx = vm.Items.IndexOf(dst);
173-
if (srcIdx < dstIdx)
174-
{
175-
for (var i = srcIdx; i < dstIdx; i++)
176-
vm.MoveItemDown(src);
177-
}
178-
else
179-
{
180-
for (var i = srcIdx; i > dstIdx; i--)
181-
vm.MoveItemUp(src);
182-
}
162+
src = item;
163+
break;
183164
}
165+
}
184166

185-
e.Handled = true;
167+
if (src == null)
168+
return;
169+
170+
if (sender is not Border { DataContext: ViewModels.InteractiveRebaseItem dst } border)
171+
return;
172+
173+
if (src == dst)
174+
return;
175+
176+
var p = e.GetPosition(border);
177+
if (p.Y > border.Bounds.Height * 0.33 && p.Y < border.Bounds.Height * 0.67)
178+
{
179+
var srcIdx = vm.Items.IndexOf(src);
180+
var dstIdx = vm.Items.IndexOf(dst);
181+
if (srcIdx < dstIdx)
182+
{
183+
for (var i = srcIdx; i < dstIdx; i++)
184+
vm.MoveItemDown(src);
185+
}
186+
else
187+
{
188+
for (var i = srcIdx; i > dstIdx; i--)
189+
vm.MoveItemUp(src);
190+
}
186191
}
192+
193+
e.DragEffects = DragDropEffects.Move;
194+
e.Handled = true;
187195
}
188196

189197
private void OnButtonActionClicked(object sender, RoutedEventArgs e)
@@ -293,5 +301,6 @@ private void ChangeItemsAction(ViewModels.InteractiveRebaseItem target, Models.I
293301
}
294302

295303
private bool _firstSelectionChangedHandled = false;
304+
private readonly DataFormat<string> _dndItemFormat = DataFormat.CreateStringApplicationFormat("sourcegit-dnd-ir-item");
296305
}
297306
}

src/Views/LauncherTabBar.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
PointerPressed="OnPointerPressedTab"
4848
PointerMoved="OnPointerMovedOverTab"
4949
PointerReleased="OnPointerReleasedTab"
50-
Loaded="SetupDragAndDrop"
51-
ContextRequested="OnTabContextRequested">
50+
ContextRequested="OnTabContextRequested"
51+
DragDrop.AllowDrop="True"
52+
DragDrop.Drop="DropTab">
5253
<ToolTip.Tip>
5354
<Grid>
5455
<TextBlock Text="{DynamicResource Text.Welcome}" IsVisible="{Binding !Node.IsRepository}"/>

src/Views/LauncherTabBar.axaml.cs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,6 @@ private void OnTabsSelectionChanged(object _1, SelectionChangedEventArgs _2)
161161
InvalidateVisual();
162162
}
163163

164-
private void SetupDragAndDrop(object sender, RoutedEventArgs e)
165-
{
166-
if (sender is Border border)
167-
{
168-
DragDrop.SetAllowDrop(border, true);
169-
border.AddHandler(DragDrop.DropEvent, DropTab);
170-
}
171-
e.Handled = true;
172-
}
173-
174164
private void OnPointerPressedTab(object sender, PointerPressedEventArgs e)
175165
{
176166
if (sender is Border border)
@@ -196,7 +186,7 @@ private void OnPointerReleasedTab(object _1, PointerReleasedEventArgs _2)
196186
_startDragTab = false;
197187
}
198188

199-
private void OnPointerMovedOverTab(object sender, PointerEventArgs e)
189+
private async void OnPointerMovedOverTab(object sender, PointerEventArgs e)
200190
{
201191
if (_pressedTab && !_startDragTab && sender is Border { DataContext: ViewModels.LauncherPage page } border)
202192
{
@@ -207,23 +197,42 @@ private void OnPointerMovedOverTab(object sender, PointerEventArgs e)
207197

208198
_startDragTab = true;
209199

210-
var data = new DataObject();
211-
data.Set("MovedTab", page);
212-
DragDrop.DoDragDrop(e, data, DragDropEffects.Move);
200+
var data = new DataTransfer();
201+
data.Add(DataTransferItem.Create(_dndMainTabFormat, page.Node.Id));
202+
await DragDrop.DoDragDropAsync(e, data, DragDropEffects.Move);
213203
}
214204
e.Handled = true;
215205
}
216206

217207
private void DropTab(object sender, DragEventArgs e)
218208
{
219-
if (e.Data.Contains("MovedTab") &&
220-
e.Data.Get("MovedTab") is ViewModels.LauncherPage moved &&
221-
sender is Border { DataContext: ViewModels.LauncherPage to } &&
222-
to != moved)
209+
if (e.DataTransfer.TryGetValue(_dndMainTabFormat) is not { Length: > 0 } id)
210+
return;
211+
212+
if (DataContext is not ViewModels.Launcher launcher)
213+
return;
214+
215+
ViewModels.LauncherPage target = null;
216+
foreach (var page in launcher.Pages)
223217
{
224-
(DataContext as ViewModels.Launcher)?.MoveTab(moved, to);
218+
if (page.Node.Id.Equals(id, StringComparison.Ordinal))
219+
{
220+
target = page;
221+
break;
222+
}
225223
}
226224

225+
if (target == null)
226+
return;
227+
228+
if (sender is not Border { DataContext: ViewModels.LauncherPage to })
229+
return;
230+
231+
if (target == to)
232+
return;
233+
234+
launcher.MoveTab(target, to);
235+
227236
_pressedTab = false;
228237
_startDragTab = false;
229238
e.Handled = true;
@@ -317,5 +326,6 @@ private void OnCloseTab(object sender, RoutedEventArgs e)
317326
private bool _pressedTab = false;
318327
private Point _pressedTabPosition = new();
319328
private bool _startDragTab = false;
329+
private readonly DataFormat<string> _dndMainTabFormat = DataFormat.CreateStringApplicationFormat("sourcegit-dnd-main-tab");
320330
}
321331
}

src/Views/Welcome.axaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@
6060
ScrollViewer.VerticalScrollBarVisibility="Auto"
6161
ItemsSource="{Binding Rows}"
6262
SelectionMode="Single"
63-
Loaded="SetupTreeViewDragAndDrop"
64-
LostFocus="OnTreeViewLostFocus">
63+
LostFocus="OnTreeViewLostFocus"
64+
DragDrop.AllowDrop="True"
65+
DragDrop.DragOver="DragOverTreeView"
66+
DragDrop.Drop="DropOnTreeView">
6567
<ListBox.Styles>
6668
<Style Selector="ListBox">
6769
<Setter Property="FocusAdorner">
@@ -106,13 +108,15 @@
106108
Height="30"
107109
ColumnDefinitions="16,18,Auto,*"
108110
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
109-
Loaded="SetupTreeNodeDragAndDrop"
111+
ClipToBounds="True"
110112
ContextRequested="OnTreeNodeContextRequested"
111113
PointerPressed="OnPointerPressedTreeNode"
112114
PointerMoved="OnPointerMovedOverTreeNode"
113115
PointerReleased="OnPointerReleasedOnTreeNode"
114116
DoubleTapped="OnDoubleTappedTreeNode"
115-
ClipToBounds="True">
117+
DragDrop.AllowDrop="True"
118+
DragDrop.DragOver="DragOverTreeNode"
119+
DragDrop.Drop="DropOnTreeNode">
116120
<v:RepositoryTreeNodeToggleButton Grid.Column="0"
117121
Classes="tree_expander"
118122
Focusable="False"

0 commit comments

Comments
 (0)