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

Port WinForms TransferForm to WPF #15912

Merged
merged 15 commits into from
May 27, 2024
Merged

Port WinForms TransferForm to WPF #15912

merged 15 commits into from
May 27, 2024

Conversation

AliveDevil
Copy link
Contributor

Resolves #15885

@AliveDevil AliveDevil self-assigned this May 6, 2024
@AliveDevil AliveDevil requested a review from a team as a code owner May 6, 2024 14:01
@@ -106,5 +121,24 @@ public bool TryGetIcon<T>(object Key, int size, out T image, string classifier =
public ReaderWriterLockSlimExtensions.UpgradeableReadLock UpgradeableReadLock() => writer.UseUpgradeableReadLock();

public ReaderWriterLockSlimExtensions.WriteLock WriteLock() => writer.UseWriteLock();

private static void OnCacheEvict(CacheEntryRemovedArguments arguments)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to temporarily store extracted file icons (which will be garbage collected once not used in cache anymore).

{
public partial class IconProvider<T>
{
public T GetPath(Path path, int size)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from WinFormsIconProvider to base - previously used in ProgressController.

@@ -105,17 +105,21 @@ public T GetApplication(Application application, int size)
public T GetFileIcon(string filename, bool isFolder, bool large, bool isExecutable)
{
string key = string.Empty;
string fileInfo = filename;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed logic here to be able to extract local file icons correctly, and not pollute the cache with wrong information.
e.g. calling GetFileIcon("C:\A\B.exe") would pollute cache key "ext:exe" to forever use that icon.

protected override BitmapSource Overlay(BitmapSource baseImage, BitmapSource overlay, int size)
{
DrawingVisual visual = new();
using (var context = visual.RenderOpen())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately required.

{
public delegate TResult ObservableTransform<TSource, TResult>(TSource obj, TResult? cached);

public static IObservable<IChangeSet<TResult>> ToObservableChangeSet<TSource, TResult>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create Observable from ch.cyberduck.core.Collection
Basically allows watching for collectionX-notifications

@@ -848,7 +856,7 @@ private void InitializeTransfers()
_bc.Invoke(() =>
{
transfersSemaphore.Wait();
TransferController.Instance.View.Show();
TransferController.Instance.ShowWindow();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View is lazily created if required. Use instance method which handles everything (including dispatching to WPF secondary thread).

throw new LoginCanceledException();
}
});
var result = UiUtils.Show(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IWindowController doesn't have CommandBox.
Use readily available Utils-helper methods.

_preferences.setProperty("queue.transcript.size.height", View.TranscriptHeight);
if (wait)
{
MainController.Application.SynchronizationContext.Send(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to not get bitten by not-supported UI display scaling when opening prompts from the Transfer-window thread which has DPI display scaling enabled, schedule everything from background actions to WinForms main thread.

@ylangisc ylangisc merged commit fdefaec into master May 27, 2024
6 checks passed
@ylangisc ylangisc deleted the feature/GH-15885 branch May 27, 2024 05:51
@ylangisc ylangisc added this to the 8.9.1 milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modernize Transfers-window
2 participants