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)); }
private void RecalcParams() { if (btnMinus != null && btnPlus != null && btnSlider != null) { if (orientation == EOrientation.Horizontal) { btnMinus.Width = Height; btnMinus.Height = Height; btnPlus.Width = Height; btnPlus.Height = Height; btnPlus.Left = Width - Height; btnPlus.Top = 0; btnSlider.Movable = true; int size = btnMinus.Width + Skin.Layers[strSlider].OffsetX; btnSlider.MinimumWidth = Height; int w = (Width - 2 * size); btnSlider.Width = (int)Math.Ceiling((pageSize * w) / (float)range); btnSlider.Height = Height; float px = (float)(Range - PageSize) / (float)(w - btnSlider.Width); int pos = (int)(Math.Ceiling(Value / (float)px)); btnSlider.SetPosition(size + pos, 0); if (btnSlider.Left < size) { btnSlider.SetPosition(size, 0); } if (btnSlider.Left + btnSlider.Width + size > Width) { btnSlider.SetPosition(Width - size - btnSlider.Width, 0); } } else { btnMinus.Width = Width; btnMinus.Height = Width; btnPlus.Width = Width; btnPlus.Height = Width; btnPlus.Top = Height - Width; btnSlider.Movable = true; int size = btnMinus.Height + Skin.Layers[strSlider].OffsetY; btnSlider.MinimumHeight = Width; int h = (Height - 2 * size); btnSlider.Height = (int)Math.Ceiling((pageSize * h) / (float)range); btnSlider.Width = Width; float px = (float)(Range - PageSize) / (float)(h - btnSlider.Height); int pos = (int)(Math.Ceiling(Value / (float)px)); btnSlider.SetPosition(0, size + pos); if (btnSlider.Top < size) { btnSlider.SetPosition(0, size); } if (btnSlider.Top + btnSlider.Height + size > Height) { btnSlider.SetPosition(0, Height - size - btnSlider.Height); } } } }