123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace LYFZ.OtherExpansion.SkinControl
- {
- public class ChatListVScroll
- {
- private Rectangle bounds;
- private Rectangle upBounds;
- private Rectangle downBounds;
- private Rectangle sliderBounds;
- private Color backColor;
- private Color sliderDefaultColor;
- private Color sliderDownColor;
- private Color arrowBackColor;
- private Color arrowColor;
- private Control ctrl;
- private int virtualHeight;
- private int value;
- private bool shouldBeDraw;
- private bool isMouseDown;
- private bool isMouseOnSlider;
- private bool isMouseOnUp;
- private bool isMouseOnDown;
- private int mouseDownY;
- private int m_nLastSliderY;
- public Rectangle Bounds
- {
- get
- {
- return this.bounds;
- }
- }
- public Rectangle UpBounds
- {
- get
- {
- return this.upBounds;
- }
- }
- public Rectangle DownBounds
- {
- get
- {
- return this.downBounds;
- }
- }
- public Rectangle SliderBounds
- {
- get
- {
- return this.sliderBounds;
- }
- }
- public Color BackColor
- {
- get
- {
- return this.backColor;
- }
- set
- {
- this.backColor = value;
- }
- }
- public Color SliderDefaultColor
- {
- get
- {
- return this.sliderDefaultColor;
- }
- set
- {
- if (this.sliderDefaultColor == value)
- {
- return;
- }
- this.sliderDefaultColor = value;
- this.ctrl.Invalidate(this.sliderBounds);
- }
- }
- public Color SliderDownColor
- {
- get
- {
- return this.sliderDownColor;
- }
- set
- {
- if (this.sliderDownColor == value)
- {
- return;
- }
- this.sliderDownColor = value;
- this.ctrl.Invalidate(this.sliderBounds);
- }
- }
- public Color ArrowBackColor
- {
- get
- {
- return this.arrowBackColor;
- }
- set
- {
- if (this.arrowBackColor == value)
- {
- return;
- }
- this.arrowBackColor = value;
- this.ctrl.Invalidate(this.bounds);
- }
- }
- public Color ArrowColor
- {
- get
- {
- return this.arrowColor;
- }
- set
- {
- if (this.arrowColor == value)
- {
- return;
- }
- this.arrowColor = value;
- this.ctrl.Invalidate(this.bounds);
- }
- }
- public Control Ctrl
- {
- get
- {
- return this.ctrl;
- }
- set
- {
- this.ctrl = value;
- }
- }
- public int VirtualHeight
- {
- get
- {
- return this.virtualHeight;
- }
- set
- {
- if (value <= this.ctrl.Height)
- {
- if (!this.shouldBeDraw)
- {
- return;
- }
- this.shouldBeDraw = false;
- if (this.value != 0)
- {
- this.value = 0;
- this.ctrl.Invalidate();
- }
- }
- else
- {
- this.shouldBeDraw = true;
- if (value - this.value < this.ctrl.Height)
- {
- this.value -= this.ctrl.Height - value + this.value;
- this.ctrl.Invalidate();
- }
- }
- this.virtualHeight = value;
- }
- }
- public int Value
- {
- get
- {
- return this.value;
- }
- set
- {
- if (!this.shouldBeDraw)
- {
- return;
- }
- if (value < 0)
- {
- if (this.value == 0)
- {
- return;
- }
- this.value = 0;
- this.ctrl.Invalidate();
- return;
- }
- else
- {
- if (value <= this.virtualHeight - this.ctrl.Height)
- {
- this.value = value;
- this.ctrl.Invalidate();
- return;
- }
- if (this.value == this.virtualHeight - this.ctrl.Height)
- {
- return;
- }
- this.value = this.virtualHeight - this.ctrl.Height;
- this.ctrl.Invalidate();
- return;
- }
- }
- }
- public bool ShouldBeDraw
- {
- get
- {
- return this.shouldBeDraw;
- }
- }
- public bool IsMouseDown
- {
- get
- {
- return this.isMouseDown;
- }
- set
- {
- if (value)
- {
- this.m_nLastSliderY = this.sliderBounds.Y;
- }
- this.isMouseDown = value;
- }
- }
- public bool IsMouseOnSlider
- {
- get
- {
- return this.isMouseOnSlider;
- }
- set
- {
- if (this.isMouseOnSlider == value)
- {
- return;
- }
- this.isMouseOnSlider = value;
- this.ctrl.Invalidate(this.SliderBounds);
- }
- }
- public bool IsMouseOnUp
- {
- get
- {
- return this.isMouseOnUp;
- }
- set
- {
- if (this.isMouseOnUp == value)
- {
- return;
- }
- this.isMouseOnUp = value;
- this.ctrl.Invalidate(this.UpBounds);
- }
- }
- public bool IsMouseOnDown
- {
- get
- {
- return this.isMouseOnDown;
- }
- set
- {
- if (this.isMouseOnDown == value)
- {
- return;
- }
- this.isMouseOnDown = value;
- this.ctrl.Invalidate(this.DownBounds);
- }
- }
- public int MouseDownY
- {
- get
- {
- return this.mouseDownY;
- }
- set
- {
- this.mouseDownY = value;
- }
- }
- public ChatListVScroll(Control c)
- {
- this.ctrl = c;
- this.virtualHeight = 400;
- this.bounds = new Rectangle(0, 0, 5, 5);
- this.upBounds = new Rectangle(0, 0, 5, 5);
- this.downBounds = new Rectangle(0, 0, 5, 5);
- this.sliderBounds = new Rectangle(0, 0, 5, 5);
- this.backColor = Color.FromArgb(50, 224, 239, 235);
- this.sliderDefaultColor = Color.FromArgb(100, 110, 111, 112);
- this.sliderDownColor = Color.FromArgb(200, 110, 111, 112);
- this.arrowBackColor = Color.Transparent;
- this.arrowColor = Color.FromArgb(200, 148, 150, 151);
- }
- public void ClearAllMouseOn()
- {
- if (!this.isMouseOnDown && !this.isMouseOnSlider && !this.isMouseOnUp)
- {
- return;
- }
- this.isMouseOnSlider = (this.isMouseOnDown = (this.isMouseOnUp = false));
- this.ctrl.Invalidate(this.bounds);
- }
- public void MoveSliderToLocation(int nCurrentMouseY)
- {
- if (nCurrentMouseY - this.sliderBounds.Height / 2 < 11)
- {
- this.sliderBounds.Y = 11;
- }
- else
- {
- if (nCurrentMouseY + this.sliderBounds.Height / 2 > this.ctrl.Height - 11)
- {
- this.sliderBounds.Y = this.ctrl.Height - this.sliderBounds.Height - 11;
- }
- else
- {
- this.sliderBounds.Y = nCurrentMouseY - this.sliderBounds.Height / 2;
- }
- }
- this.value = (int)((double)(this.sliderBounds.Y - 11) / (double)(this.ctrl.Height - 22 - this.SliderBounds.Height) * (double)(this.virtualHeight - this.ctrl.Height));
- this.ctrl.Invalidate();
- }
- public void MoveSliderFromLocation(int nCurrentMouseY)
- {
- if (this.m_nLastSliderY + nCurrentMouseY - this.mouseDownY < 11)
- {
- if (this.sliderBounds.Y == 11)
- {
- return;
- }
- this.sliderBounds.Y = 11;
- }
- else
- {
- if (this.m_nLastSliderY + nCurrentMouseY - this.mouseDownY > this.ctrl.Height - 11 - this.SliderBounds.Height)
- {
- if (this.sliderBounds.Y == this.ctrl.Height - 11 - this.sliderBounds.Height)
- {
- return;
- }
- this.sliderBounds.Y = this.ctrl.Height - 11 - this.sliderBounds.Height;
- }
- else
- {
- this.sliderBounds.Y = this.m_nLastSliderY + nCurrentMouseY - this.mouseDownY;
- }
- }
- this.value = (int)((double)(this.sliderBounds.Y - 11) / (double)(this.ctrl.Height - 22 - this.SliderBounds.Height) * (double)(this.virtualHeight - this.ctrl.Height));
- this.ctrl.Invalidate();
- }
- public void ReDrawScroll(Graphics g)
- {
- if (!this.shouldBeDraw)
- {
- return;
- }
- this.bounds.X = this.ctrl.Width - 7;
- this.bounds.Height = this.ctrl.Height;
- this.upBounds.X = (this.downBounds.X = this.bounds.X);
- this.downBounds.Y = this.ctrl.Height - 5;
- this.sliderBounds.X = this.bounds.X;
- this.sliderBounds.Height = (int)((double)this.ctrl.Height / (double)this.virtualHeight * (double)(this.ctrl.Height - 22));
- if (this.sliderBounds.Height < 3)
- {
- this.sliderBounds.Height = 3;
- }
- this.sliderBounds.Y = 11 + (int)((double)this.value / (double)(this.virtualHeight - this.ctrl.Height) * (double)(this.ctrl.Height - 22 - this.sliderBounds.Height));
- SolidBrush sb = new SolidBrush(this.backColor);
- try
- {
- g.FillRectangle(sb, this.bounds);
- sb.Color = this.arrowBackColor;
- g.FillRectangle(sb, this.upBounds);
- g.FillRectangle(sb, this.downBounds);
- if (this.isMouseDown || this.isMouseOnSlider)
- {
- sb.Color = this.sliderDownColor;
- }
- else
- {
- sb.Color = this.sliderDefaultColor;
- }
- g.FillRectangle(sb, this.sliderBounds);
- sb.Color = this.arrowColor;
- bool arg_1A1_0 = this.isMouseOnUp;
- bool arg_1A8_0 = this.isMouseOnDown;
- }
- finally
- {
- sb.Dispose();
- }
- }
- }
- }
|