Skip to content

Commit

Permalink
Smoother and much faster scrolling. Fix #6036.
Browse files Browse the repository at this point in the history
Former-commit-id: c81bfc65f0affdbb556eb145e95b63dcb306331b
  • Loading branch information
ylangisc committed Dec 27, 2012
1 parent 70fe8f2 commit c34dfaa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 51 deletions.
26 changes: 14 additions & 12 deletions source/ch/cyberduck/ui/winforms/BrowserForm.cs
Expand Up @@ -670,17 +670,14 @@ public void AddTranscriptEntry(bool request, string entry)
else
{
transcriptBox.SelectionColor = Color.DarkGray;
transcriptBox.SelectionColor = Color.DarkGray;
}
if (transcriptBox.TextLength > 0)
{
entry = Environment.NewLine + entry;
}
transcriptBox.SelectedText = entry;
// todo improve performance
// Select seems to be an expensive operation
// see http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx
transcriptBox.Select(transcriptBox.TextLength, transcriptBox.TextLength);
transcriptBox.ScrollToCaret();
ScrollToBottom(transcriptBox);
}

public void ClearTranscript()
Expand Down Expand Up @@ -955,6 +952,11 @@ public bool SecureConnection
set { securityToolStripStatusLabel.Image = IconCache.Instance.IconForName(value ? "locked" : "unlocked"); }
}

public static void ScrollToBottom(RichTextBox richTextBox)
{
NativeMethods.SendMessage(richTextBox.Handle, NativeConstants.WM_VSCROLL, NativeConstants.SB_BOTTOM, 0);
}

private void AddDonateButton()
{
IActiveMenu menu = ActiveMenu.GetInstance(this);
Expand Down Expand Up @@ -2433,7 +2435,7 @@ public void collectionItemAdded(object obj)
{
int pos =
BookmarkCollection.defaultCollection().
indexOf(obj);
indexOf(obj);
Host h = (Host) obj;
MenuItem i = new MenuItem(h.getNickname());
i.Tag = h;
Expand All @@ -2447,8 +2449,8 @@ public void collectionItemAdded(object obj)
_form.vistaMenu1.SetImage(i,
_icons[
h.getProtocol()
.
getProvider
.
getProvider
()]);
}));
}
Expand All @@ -2459,7 +2461,7 @@ public void collectionItemRemoved(object obj)
{
int pos =
BookmarkCollection.defaultCollection().
indexOf(obj);
indexOf(obj);
Host h = (Host) obj;
MenuItem i = new MenuItem(h.getNickname());
i.Tag = h;
Expand All @@ -2473,7 +2475,7 @@ public void collectionItemRemoved(object obj)
_form.vistaMenu1.SetImage(i,
_icons[
h.getProtocol().
getProvider()
getProvider()
]);


Expand Down Expand Up @@ -2970,8 +2972,8 @@ public void collectionItemAdded(object obj)
_form.vistaMenu1.SetImage(i,
_icons[
h.getProtocol()
.
getProvider
.
getProvider
()]);
}
}));
Expand Down
81 changes: 42 additions & 39 deletions source/ch/cyberduck/ui/winforms/TransferForm.cs
@@ -1,5 +1,5 @@
//
// Copyright (c) 2010 Yves Langisch. All rights reserved.
// Copyright (c) 2010-2012 Yves Langisch. All rights reserved.
// http://cyberduck.ch/
//
// This program is free software; you can redistribute it and/or modify
Expand All @@ -15,18 +15,19 @@
// Bug fixes, suggestions and comments should be sent to:
// yves@cyberduck.ch
//

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using ch.cyberduck.core;
using Ch.Cyberduck.Core;
using ch.cyberduck.core.io;
using Ch.Cyberduck.Ui.Controller;
using Ch.Cyberduck.Ui.Winforms.Controls;
using Windows7.DesktopIntegration;
using Windows7.DesktopIntegration.WindowsForms;
using ch.cyberduck.core;
using ch.cyberduck.core.io;

namespace Ch.Cyberduck.Ui.Winforms
{
Expand Down Expand Up @@ -65,19 +66,19 @@ public TransferForm()
dummyColumn.Width = 0;
transferColumn.FillsFreeSpace = true;
transferListView.ItemSelectionChanged += delegate(object sender, ListViewItemSelectionChangedEventArgs e)
{
TransferControl uc =
((TransferControl)
transferListView.GetEmbeddedControl(1, e.ItemIndex));
if (null != uc)
{
uc.Selected = e.IsSelected;
if (e.IsSelected && uc.FocusRemoveAllowed)
{
transferListView.Select();
}
}
};
{
TransferControl uc =
((TransferControl)
transferListView.GetEmbeddedControl(1, e.ItemIndex));
if (null != uc)
{
uc.Selected = e.IsSelected;
if (e.IsSelected && uc.FocusRemoveAllowed)
{
transferListView.Select();
}
}
};
transferListView.ItemSelectionChanged += (sender, e) => SelectionChangedEvent();
transferListView.ItemsChanged +=
delegate { transferListView.GridLines = transferListView.GetItemCount() > 0; };
Expand Down Expand Up @@ -145,7 +146,7 @@ public float Bandwidth
m.Checked = value.Equals(m.Tag);
if (m.Checked)
{
if (m.Tag.Equals((float) BandwidthThrottle.UNLIMITED))
if (m.Tag.Equals(BandwidthThrottle.UNLIMITED))
{
if (!_currentImage.Equals("bandwidth"))
{
Expand Down Expand Up @@ -231,11 +232,8 @@ public void AddTranscriptEntry(bool request, string entry)
transcriptBox.SelectionColor = Color.DarkGray;
}
transcriptBox.SelectedText = entry + Environment.NewLine;
// todo improve performance
// Select seems to be an expensive operation
// see http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx
transcriptBox.Select(transcriptBox.TextLength, transcriptBox.TextLength);
transcriptBox.ScrollToCaret();
ScrollToBottom(transcriptBox);
}

public IList<IProgressView> SelectedTransfers
Expand Down Expand Up @@ -279,17 +277,17 @@ public void PopulateBandwidthList(IList<KeyValuePair<float, string>> throttles)
ToolStripMenuItem item = new ToolStripMenuItem(throttle.Value);
item.Tag = throttle.Key;
item.Click += delegate(object sender, EventArgs args)
{
foreach (ToolStripItem i in bandwidthMenuStrip.Items)
{
if (i is ToolStripMenuItem)
{
((ToolStripMenuItem) i).Checked = false;
}
((ToolStripMenuItem) sender).Checked = true;
}
BandwidthChangedEvent();
};
{
foreach (ToolStripItem i in bandwidthMenuStrip.Items)
{
if (i is ToolStripMenuItem)
{
((ToolStripMenuItem) i).Checked = false;
}
((ToolStripMenuItem) sender).Checked = true;
}
BandwidthChangedEvent();
};

bandwidthMenuStrip.Items.Add(item);

Expand Down Expand Up @@ -346,17 +344,22 @@ public void UpdateOverallProgressState(double progress, double maximum)
}
}

public static void ScrollToBottom(RichTextBox richTextBox)
{
NativeMethods.SendMessage(richTextBox.Handle, NativeConstants.WM_VSCROLL, NativeConstants.SB_BOTTOM, 0);
}

private void ConfigureToolbarMenu(ToolStripMenuItem menuItem, ToolStripButton button, String property)
{
menuItem.CheckOnClick = true;
menuItem.Click += delegate
{
button.Visible =
!button.Visible;
Preferences.instance().setProperty(
property,
button.Visible);
};
{
button.Visible =
!button.Visible;
Preferences.instance().setProperty(
property,
button.Visible);
};

button.Visible = menuItem.Checked = Preferences.instance().getBoolean(property);
}
Expand Down

0 comments on commit c34dfaa

Please sign in to comment.