コード例 #1
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
 protected ScrollBar(ScrollBarOrientation orientation)
 {
     this._scrollBarOrientation = orientation;
     this._mouseTimer = new Timer();
     this._mouseTimer.Tick += new EventHandler(this.MouseTimerTick);
     this._mouseTimer.Interval = 100;
     this._mouseTimer.Enabled = false;
     this._clickAction = ScrollBarHitRegion.None;
     this._minimum = 0;
     this._maximum = 100;
     this._largeChange = 10;
     this._smallChange = 1;
     this._value = 0;
     this._arrowButtonsLayout = ScrollBarArrowButtonsLayout.Edges;
     this._leftUpButton = null;
     this._leftUpButtonHighlight = null;
     this._leftUpButtonDisabled = null;
     this._leftUpButtonSize = 0x13;
     this._rightDownButton = null;
     this._rightDownButtonHighlight = null;
     this._rightDownButtonDisabled = null;
     this._rightDownButtonSize = 0x13;
     this._lowTrack = null;
     this._lowTrackHighlight = null;
     this._lowTrackDisabled = null;
     this._highTrack = null;
     this._highTrackHighlight = null;
     this._highTrackDisabled = null;
     this._trackClickBehavior = ScrollBarTrackClickBehavior.Scroll;
     this._thumb = null;
     this._thumbHighlight = null;
     this._thumbDisabled = null;
     this._minimumThumbSize = 11;
     this._maximumThumbSize = 0;
     this._thumbMargins = new MarginPadding();
     this._extension = null;
     this._extensionSize = 13;
     this._extensionLocation = ScrollBarExtensionLocation.LeftTop;
     this._extensionVisible = true;
     this._backgroundBufferBitmap = null;
     this._backgroundBufferGraphics = null;
     this._backgroundValid = BackgroundValid.Invalid;
     this._backBufferBitmap = null;
     this._backBufferGraphics = null;
     this.DrawTrack = null;
     this.DrawArrowButton = null;
     this.DrawThumb = null;
     this.ValueChanged = null;
     this.MinimumReached = null;
     this.MaximumReached = null;
 }
コード例 #2
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
 private Graphics GetBackgroundBuffer()
 {
     Size reqSize = base.Size;
     if ((this._extension != null) && this._extensionVisible)
     {
         if (this._scrollBarOrientation == ScrollBarOrientation.Horizontal)
         {
             reqSize.Height -= this.ExtensionSize;
         }
         else
         {
             reqSize.Width -= this.ExtensionSize;
         }
     }
     if (!CreateBackBuffer(ref this._backgroundBufferGraphics, ref this._backgroundBufferBitmap, reqSize))
     {
         this._backgroundValid = BackgroundValid.Invalid;
     }
     return this._backgroundBufferGraphics;
 }
コード例 #3
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
 private void DoDrawArrowsAndTrack(PaintEventArgs e, Rectangle leftUpArrow, Rectangle rightDownArrow, Rectangle track, Rectangle lowTrack, Rectangle lowTrackVisible, Rectangle highTrack, Rectangle highTrackVisible, Rectangle thumb)
 {
     PaintEventArgs args = null;
     Graphics backgroundBuffer = this.GetBackgroundBuffer();
     BackgroundValid valid = this._backgroundValid;
     if (backgroundBuffer != null)
     {
         if (this._backgroundValid != BackgroundValid.Valid)
         {
             args = new PaintEventArgs(backgroundBuffer, new Rectangle(0, 0, this._backgroundBufferBitmap.Width, this._backgroundBufferBitmap.Height));
             if (((this._extension != null) && this._extensionVisible) && (this._extensionLocation == ScrollBarExtensionLocation.LeftTop))
             {
                 int extensionSize = this.ExtensionSize;
                 if (this._scrollBarOrientation == ScrollBarOrientation.Horizontal)
                 {
                     leftUpArrow.Y -= extensionSize;
                     rightDownArrow.Y -= extensionSize;
                     track.Y -= extensionSize;
                     lowTrack.Y -= extensionSize;
                     lowTrackVisible.Y -= extensionSize;
                     highTrack.Y -= extensionSize;
                     highTrackVisible.Y -= extensionSize;
                 }
                 else
                 {
                     leftUpArrow.X -= extensionSize;
                     rightDownArrow.X -= extensionSize;
                     track.X -= extensionSize;
                     lowTrack.X -= extensionSize;
                     lowTrackVisible.X -= extensionSize;
                     highTrack.X -= extensionSize;
                     highTrackVisible.X -= extensionSize;
                 }
             }
         }
     }
     else
     {
         args = e;
     }
     if (valid != BackgroundValid.Valid)
     {
         if ((((valid & BackgroundValid.LeftUpArrowInvalid) == BackgroundValid.LeftUpArrowInvalid) && (leftUpArrow.Width > 0)) && (leftUpArrow.Height > 0))
         {
             this.OnDrawArrowButton(new DrawArrowButtonEventArgs(args.Graphics, leftUpArrow, base.Enabled ? ((this._clickAction == ScrollBarHitRegion.LeftUpArrow) ? ScrollBarElementState.Pressed : ScrollBarElementState.Normal) : ScrollBarElementState.Disabled, (this._scrollBarOrientation == ScrollBarOrientation.Horizontal) ? ScrollBarArrow.Left : ScrollBarArrow.Up));
         }
         if ((((valid & BackgroundValid.RightDownArrowInvalid) == BackgroundValid.RightDownArrowInvalid) && (rightDownArrow.Width > 0)) && (rightDownArrow.Height > 0))
         {
             this.OnDrawArrowButton(new DrawArrowButtonEventArgs(args.Graphics, rightDownArrow, base.Enabled ? ((this._clickAction == ScrollBarHitRegion.RightDownArrow) ? ScrollBarElementState.Pressed : ScrollBarElementState.Normal) : ScrollBarElementState.Disabled, (this._scrollBarOrientation == ScrollBarOrientation.Horizontal) ? ScrollBarArrow.Right : ScrollBarArrow.Down));
         }
         if ((valid & BackgroundValid.LowTrackInvalid) == BackgroundValid.LowTrackInvalid)
         {
             this.OnDrawTrack(new DrawTrackEventArgs(args.Graphics, lowTrack, base.Enabled ? ((this._clickAction == ScrollBarHitRegion.TrackLow) ? ScrollBarElementState.Pressed : ScrollBarElementState.Normal) : ScrollBarElementState.Disabled, lowTrackVisible, track, ScrollBarTrackType.Low));
         }
         if ((valid & BackgroundValid.HighTrackInvalid) == BackgroundValid.HighTrackInvalid)
         {
             this.OnDrawTrack(new DrawTrackEventArgs(args.Graphics, highTrack, base.Enabled ? ((this._clickAction == ScrollBarHitRegion.TrackHigh) ? ScrollBarElementState.Pressed : ScrollBarElementState.Normal) : ScrollBarElementState.Disabled, highTrackVisible, track, ScrollBarTrackType.High));
         }
         this._backgroundValid = (args != e) ? BackgroundValid.Valid : BackgroundValid.Invalid;
     }
     if (args != e)
     {
         int x = 0;
         int y = 0;
         if (((this._extension != null) && this._extensionVisible) && (this._extensionLocation == ScrollBarExtensionLocation.LeftTop))
         {
             if (this._scrollBarOrientation == ScrollBarOrientation.Horizontal)
             {
                 y += this.ExtensionSize;
             }
             else if (this._scrollBarOrientation == ScrollBarOrientation.Vertical)
             {
                 x += this.ExtensionSize;
             }
         }
         e.Graphics.DrawImage(this._backgroundBufferBitmap, x, y);
     }
 }
コード例 #4
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
        protected override void OnMouseUp(MouseEventArgs e)
        {
            this._mouseTimer.Enabled = false;
            switch (this._clickAction)
            {
                case ScrollBarHitRegion.LeftUpArrow:
                    this._backgroundValid |= BackgroundValid.LeftUpArrowInvalid;
                    break;

                case ScrollBarHitRegion.RightDownArrow:
                    this._backgroundValid |= BackgroundValid.RightDownArrowInvalid;
                    break;

                case ScrollBarHitRegion.TrackLow:
                    this._backgroundValid |= BackgroundValid.LowTrackInvalid;
                    break;

                case ScrollBarHitRegion.TrackHigh:
                    this._backgroundValid |= BackgroundValid.HighTrackInvalid;
                    break;

                case ScrollBarHitRegion.Extension:
                    if (this._extension != null)
                    {
                        this._extension.Mouse(ScrollBarExtensionBase.MouseAction.Up, e);
                    }
                    break;
            }
            this._clickAction = ScrollBarHitRegion.None;
            base.OnMouseUp(e);
            base.Invalidate();
        }
コード例 #5
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
        protected override void OnMouseDown(MouseEventArgs e)
        {
            this._clickAction = this.HitTest(e.X, e.Y, out this._thumbPos);
            if (((this._clickAction == ScrollBarHitRegion.TrackLow) || (this._clickAction == ScrollBarHitRegion.TrackHigh)) && (this._trackClickBehavior == ScrollBarTrackClickBehavior.Jump))
            {
                this._mouseX = base.Left - 1;
                this._mouseY = base.Top - 1;
                this._clickAction = ScrollBarHitRegion.Thumb;
                this.SetValueToMousePosition(e.X, e.Y);
                this._backgroundValid |= BackgroundValid.HighTrackInvalid | BackgroundValid.LowTrackInvalid;
                this._mouseX = e.X;
                this._mouseY = e.Y;
            }
            else
            {
                switch (this._clickAction)
                {
                    case ScrollBarHitRegion.LeftUpArrow:
                        this.Value -= this.SmallChange;
                        this._mouseTimer.Enabled = true;
                        this._backgroundValid |= BackgroundValid.LeftUpArrowInvalid;
                        goto Label_01B7;

                    case ScrollBarHitRegion.RightDownArrow:
                        this.Value += this.SmallChange;
                        this._mouseTimer.Enabled = true;
                        this._backgroundValid |= BackgroundValid.RightDownArrowInvalid;
                        goto Label_01B7;

                    case ScrollBarHitRegion.TrackLow:
                        this.Value -= this.LargeChange;
                        this._mouseTimer.Enabled = true;
                        this._backgroundValid |= BackgroundValid.LowTrackInvalid;
                        goto Label_01B7;

                    case ScrollBarHitRegion.TrackHigh:
                        this.Value += this.LargeChange;
                        this._mouseTimer.Enabled = true;
                        this._backgroundValid |= BackgroundValid.HighTrackInvalid;
                        goto Label_01B7;

                    case ScrollBarHitRegion.Thumb:
                        this._mouseX = e.X;
                        this._mouseY = e.Y;
                        goto Label_01B7;

                    case ScrollBarHitRegion.Extension:
                        if (this._extension != null)
                        {
                            this._extension.Mouse(ScrollBarExtensionBase.MouseAction.Down, e);
                        }
                        goto Label_01B7;
                }
            }
            Label_01B7:
            base.OnMouseDown(e);
            base.Invalidate();
        }
コード例 #6
0
ファイル: ScrollBar.cs プロジェクト: north0808/haina
        protected void HandleChange(ScrollBarChangeType type)
        {
            switch (type)
            {
                case ScrollBarChangeType.LowTrackPropertyChanged:
                    this._backgroundValid |= BackgroundValid.LowTrackInvalid;
                    break;

                case ScrollBarChangeType.HighTrackPropertyChanged:
                    this._backgroundValid |= BackgroundValid.HighTrackInvalid;
                    break;

                case ScrollBarChangeType.NeedFullRedraw:
                    this._backgroundValid |= BackgroundValid.Invalid;
                    break;

                case ScrollBarChangeType.ScrollBarPropertyChanged:
                    this._backgroundValid |= BackgroundValid.HighTrackInvalid | BackgroundValid.LowTrackInvalid;
                    break;

                case ScrollBarChangeType.LeftUpArrowPropertyChanged:
                    this._backgroundValid |= BackgroundValid.LeftUpArrowInvalid;
                    break;

                case ScrollBarChangeType.RightDownArrowPropertyChanged:
                    this._backgroundValid |= BackgroundValid.RightDownArrowInvalid;
                    break;
            }
            base.Invalidate();
        }