예제 #1
0
        private int Recalculate()
        {
            int value   = 0;
            var buttons = EditGrid.FindChildren <ToggleButton>();

            foreach (var button in buttons)
            {
                if (button.IsChecked == true)
                {
                    value |= button.TabIndex;
                }
            }
            return(value);
        }
예제 #2
0
        private void Set(int value)
        {
            if (value > 255)
            {
                value = 255;
            }
            if (value < 0)
            {
                value = 0;
            }

            var buttons = EditGrid.FindChildren <ToggleButton>();

            foreach (var button in buttons)
            {
                button.IsChecked = false;
                if (value - button.TabIndex >= 0)
                {
                    value           -= button.TabIndex;
                    button.IsChecked = true;
                }
            }
        }