Created
August 27, 2015 11:14
-
-
Save anonymous/acf0ec4d5c81dbc5a670 to your computer and use it in GitHub Desktop.
Unsmooth scrolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace slider | |
{ | |
public partial class Form1 : Form | |
{ | |
int _AmountLeft; | |
int _Step; | |
public Form1( ) | |
{ | |
InitializeComponent( ); | |
} | |
private void StartTest_Click( object sender, EventArgs e ) | |
{ | |
_AmountLeft = PanelToResize.Width / 2; // half of it | |
_Step = _AmountLeft / 10; | |
Ticker.Enabled = true; | |
} | |
private void Ticker_Tick( object sender, EventArgs e ) | |
{ | |
int this_bit = Math.Min( _AmountLeft, _Step ); | |
// reduce | |
PanelToResize.Bounds = new Rectangle( PanelToResize.Left + this_bit, PanelToResize.Top, PanelToResize.Width - this_bit, PanelToResize.Height ); | |
if (this_bit == _AmountLeft) | |
Ticker.Enabled = false; | |
_AmountLeft -= this_bit; | |
} | |
} | |
} | |
namespace slider | |
{ | |
partial class Form1 | |
{ | |
/// <summary> | |
/// Required designer variable. | |
/// </summary> | |
private System.ComponentModel.IContainer components = null; | |
/// <summary> | |
/// Clean up any resources being used. | |
/// </summary> | |
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | |
protected override void Dispose( bool disposing ) | |
{ | |
if (disposing && (components != null)) | |
{ | |
components.Dispose( ); | |
} | |
base.Dispose( disposing ); | |
} | |
#region Windows Form Designer generated code | |
/// <summary> | |
/// Required method for Designer support - do not modify | |
/// the contents of this method with the code editor. | |
/// </summary> | |
private void InitializeComponent( ) | |
{ | |
this.components = new System.ComponentModel.Container(); | |
this.PanelToResize = new System.Windows.Forms.Panel(); | |
this.button1 = new System.Windows.Forms.Button(); | |
this.button2 = new System.Windows.Forms.Button(); | |
this.StartTest = new System.Windows.Forms.Button(); | |
this.Ticker = new System.Windows.Forms.Timer(this.components); | |
this.PanelToResize.SuspendLayout(); | |
this.SuspendLayout(); | |
// | |
// PanelToResize | |
// | |
this.PanelToResize.BackColor = System.Drawing.Color.Red; | |
this.PanelToResize.Controls.Add(this.button2); | |
this.PanelToResize.Controls.Add(this.button1); | |
this.PanelToResize.Location = new System.Drawing.Point(49, 26); | |
this.PanelToResize.Name = "PanelToResize"; | |
this.PanelToResize.Size = new System.Drawing.Size(801, 128); | |
this.PanelToResize.TabIndex = 0; | |
// | |
// button1 | |
// | |
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); | |
this.button1.Location = new System.Drawing.Point(602, 36); | |
this.button1.Name = "button1"; | |
this.button1.Size = new System.Drawing.Size(72, 37); | |
this.button1.TabIndex = 0; | |
this.button1.Text = "button1"; | |
this.button1.UseVisualStyleBackColor = true; | |
// | |
// button2 | |
// | |
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); | |
this.button2.Location = new System.Drawing.Point(708, 37); | |
this.button2.Name = "button2"; | |
this.button2.Size = new System.Drawing.Size(66, 35); | |
this.button2.TabIndex = 1; | |
this.button2.Text = "button2"; | |
this.button2.UseVisualStyleBackColor = true; | |
// | |
// StartTest | |
// | |
this.StartTest.Location = new System.Drawing.Point(49, 170); | |
this.StartTest.Name = "StartTest"; | |
this.StartTest.Size = new System.Drawing.Size(89, 35); | |
this.StartTest.TabIndex = 1; | |
this.StartTest.Text = "Start"; | |
this.StartTest.UseVisualStyleBackColor = true; | |
this.StartTest.Click += new System.EventHandler(this.StartTest_Click); | |
// | |
// Ticker | |
// | |
this.Ticker.Interval = 50; | |
this.Ticker.Tick += new System.EventHandler(this.Ticker_Tick); | |
// | |
// Form1 | |
// | |
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | |
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
this.ClientSize = new System.Drawing.Size(901, 323); | |
this.Controls.Add(this.StartTest); | |
this.Controls.Add(this.PanelToResize); | |
this.Name = "Form1"; | |
this.Text = "Form1"; | |
this.PanelToResize.ResumeLayout(false); | |
this.ResumeLayout(false); | |
} | |
#endregion | |
private System.Windows.Forms.Panel PanelToResize; | |
private System.Windows.Forms.Button button2; | |
private System.Windows.Forms.Button button1; | |
private System.Windows.Forms.Button StartTest; | |
private System.Windows.Forms.Timer Ticker; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment