Ejemplo n.º 1
0
        public void Clamp()
        {
            const int minValue            = 0;
            const int maxValue            = 10;
            const int lessThanMinValue    = -5;
            const int greaterThanMaxValue = 20;

            const int value1 = 5;

            Assert.AreEqual(value1, SledUtil.Clamp(value1, minValue, maxValue));
            Assert.AreEqual(value1, SledUtil.Clamp(value1, lessThanMinValue, greaterThanMaxValue));
            Assert.AreEqual(minValue, SledUtil.Clamp(lessThanMinValue, minValue, maxValue));
            Assert.AreEqual(maxValue, SledUtil.Clamp(greaterThanMaxValue, minValue, maxValue));
        }
Ejemplo n.º 2
0
        private void BtnRemove_Click(object sender, EventArgs e)
        {
            if (m_lstFolders.SelectedItems.Count <= 0)
            {
                return;
            }

            var iIndex = m_lstFolders.SelectedItems[0].Index;

            foreach (ListViewItem item in m_lstFolders.SelectedItems)
            {
                m_lstFolders.Items.Remove(item);
            }

            iIndex = SledUtil.Clamp(iIndex, 0, m_lstFolders.Items.Count - 1);

            if (m_lstFolders.Items.Count <= 0)
            {
                return;
            }

            m_lstFolders.Items[iIndex].Selected = true;
            m_lstFolders.Focus();
        }