Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Avalonia v11 #141

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avalonia v11 - Upgraded Clipboard support
  • Loading branch information
DamianSuess committed Aug 16, 2023

Verified

This commit was signed with the committer’s verified signature.
limbonaut Serhii Snitsaruk
commit bc99baf3382e34a59608f72f88d03d2112ec6139
5 changes: 4 additions & 1 deletion ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
Original file line number Diff line number Diff line change
@@ -67,7 +67,10 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
{
sb.AppendLine(item.ToString());
}
App.Current.Clipboard.SetTextAsync(sb.ToString());

//// App.Current.Clipboard.SetTextAsync(sb.ToString());
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard.SetTextAsync(sb.ToString());
}

void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
5 changes: 4 additions & 1 deletion ILSpy.Core/Controls/ResourceStringTable.xaml.cs
Original file line number Diff line number Diff line change
@@ -69,7 +69,10 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
{
sb.AppendLine(item.ToString());
}
App.Current.Clipboard.SetTextAsync(sb.ToString());

////App.Current.Clipboard.SetTextAsync(sb.ToString());
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard.SetTextAsync(sb.ToString());
}

void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
14 changes: 7 additions & 7 deletions ILSpy.Core/TreeNodes/CopyFullyQualifiedNameContextMenuEntry.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Windows;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using Avalonia.Controls;
using ICSharpCode.ILSpy.Properties;

namespace ICSharpCode.ILSpy.TreeNodes
@@ -20,8 +16,12 @@ public bool IsVisible(TextViewContext context)
public void Execute(TextViewContext context)
{
var member = GetMemberNodeFromContext(context)?.Member;
if (member == null) return;
App.Current.Clipboard.SetTextAsync(member.ReflectionName);
if (member == null)
return;

//// App.Current.Clipboard.SetTextAsync(member.ReflectionName);
var clipboard = App.Current.GetMainWindow()?.Clipboard;
clipboard.SetTextAsync(member.ReflectionName);
}

private IMemberTreeNode GetMemberNodeFromContext(TextViewContext context)
12 changes: 8 additions & 4 deletions ILSpy.Core/TreeNodes/ThreadingSupport.cs
Original file line number Diff line number Diff line change
@@ -22,10 +22,8 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Avalonia.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Analyzers;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.TreeView;

@@ -79,8 +77,10 @@ public void LoadChildren(SharpTreeNode node, Func<CancellationToken, IEnumerable
}
return result;
}, ct);

loadChildrenTask = thisTask;
thisTask.Start();

thisTask.ContinueWith(
delegate (Task continuation) {
Dispatcher.UIThread.InvokeAsync(new Action(
@@ -97,7 +97,7 @@ public void LoadChildren(SharpTreeNode node, Func<CancellationToken, IEnumerable
}
}
}), DispatcherPriority.Normal);
});
});

// Give the task a bit time to complete before we return to WPF - this keeps "Loading..."
// from showing up for very short waits.
@@ -180,7 +180,11 @@ public void Execute(TextViewContext context)
builder.AppendLine(node.Text.ToString());
}
}
App.Current.Clipboard.SetTextAsync(builder.ToString());

//// App.Current.Clipboard.SetTextAsync(builder.ToString());
var clipboard = App.Current.GetMainWindow()?.Clipboard;
clipboard.SetTextAsync(builder.ToString());

}
}
}