Esempio n. 1
0
        public static Switch CreateSwitch(this ISwitchViewModel switchViewModel, Func <string, object> findResource)
        {
            var @switch = new Switch
            {
                Position = switchViewModel.Position,
                State    = switchViewModel.State,
                Style    = (Style)findResource("SwitchStyle")
            };

            @switch.SetValue(Grid.RowProperty, switchViewModel.Position.Row);
            @switch.SetValue(Grid.ColumnProperty, switchViewModel.Position.Column);
            @switch.ViewModel = switchViewModel;
            return(@switch);
        }
Esempio n. 2
0
        public void Execute(ISwitchViewModel parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            switch (parameter.State)
            {
            case SwitchState.On:
                parameter.State = SwitchState.OnPressed;
                break;

            case SwitchState.Off:
                parameter.State = SwitchState.OffPressed;
                break;
            }
        }
Esempio n. 3
0
        public static void Switch8Position(this ISwitchViewModel viewModel)
        {
            var currentState = viewModel.State;

            switch (currentState)
            {
            case SwitchState.OnPressed:
            case SwitchState.Off:
                viewModel.State = SwitchState.On;
                return;

            case SwitchState.OffPressed:
            case SwitchState.On:
                viewModel.State = SwitchState.Off;
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }