Skip to content

Commit

Permalink
Avalonia v11 - Upgraded Clipboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSuess committed Aug 16, 2023
1 parent 5ddf1f7 commit bc99baf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
5 changes: 4 additions & 1 deletion ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion ILSpy.Core/Controls/ResourceStringTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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
Expand All @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions ILSpy.Core/TreeNodes/ThreadingSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand All @@ -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.
Expand Down Expand Up @@ -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());

}
}
}
Expand Down

0 comments on commit bc99baf

Please sign in to comment.