//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// void btnSlider_Move(object sender, MoveEventArgs e) { if (orientation == Orientation.Horizontal) { int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX; btnSlider.SetPosition(e.Left, 0); if (btnSlider.Left < size) btnSlider.SetPosition(size, 0); if (btnSlider.Left + btnSlider.Width + size > Width) btnSlider.SetPosition(Width - size - btnSlider.Width, 0); } else { int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY; btnSlider.SetPosition(0, e.Top); if (btnSlider.Top < size) btnSlider.SetPosition(0, size); if (btnSlider.Top + btnSlider.Height + size > Height) btnSlider.SetPosition(0, Height - size - btnSlider.Height); } if (orientation == Orientation.Horizontal) { int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX; int w = (Width - 2 * size) - btnSlider.Width; float px = (float)(Range - PageSize) / (float)w; Value = (int)(Math.Ceiling((btnSlider.Left - size) * px)); } else { int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY; int h = (Height - 2 * size) - btnSlider.Height; float px = (float)(Range - PageSize) / (float)h; Value = (int)(Math.Ceiling((btnSlider.Top - size) * px)); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// void btnSlider_Move(object sender, MoveEventArgs e) { SkinLayer p = Skin.Layers["Control"]; int size = btnSlider.Width; int w = Width - p.ContentMargins.Horizontal - size; int pos = e.Left; if (pos < p.ContentMargins.Left) pos = p.ContentMargins.Left; if (pos > w + p.ContentMargins.Left) pos = w + p.ContentMargins.Left; btnSlider.SetPosition(pos, 0); float px = (float)range / (float)w; Value = (int)(Math.Ceiling((pos - p.ContentMargins.Left) * px)); }
/// <summary> /// Handles movement of the slider button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnSlider_Move(object sender, MoveEventArgs e) { // Update the slider button's position. if (orientation == Orientation.Horizontal) { // Slider moves horizontally. Set new position and clamp it to the rail. int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX; btnSlider.SetPosition(e.Left, 0); if (btnSlider.Left < size) btnSlider.SetPosition(size, 0); if (btnSlider.Left + btnSlider.Width + size > Width) btnSlider.SetPosition(Width - size - btnSlider.Width, 0); } else { // Slider moves vertically. Set new position and clamp it to the rail. int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY; btnSlider.SetPosition(0, e.Top); if (btnSlider.Top < size) btnSlider.SetPosition(0, size); if (btnSlider.Top + btnSlider.Height + size > Height) btnSlider.SetPosition(0, Height - size - btnSlider.Height); } // Update the scroll bar's value based on slider button's position. if (orientation == Orientation.Horizontal) { int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX; int w = (Width - 2 * size) - btnSlider.Width; float px = (float)(Range - PageSize) / (float)w; Value = (int)(Math.Ceiling((btnSlider.Left - size) * px)); } else { int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY; int h = (Height - 2 * size) - btnSlider.Height; float px = (float)(Range - PageSize) / (float)h; Value = (int)(Math.Ceiling((btnSlider.Top - size) * px)); } }