public WemosScheduledSwitchController(WemosController controller)
     : base (controller)
 {
     if (string.IsNullOrEmpty(controller.Configuration))
     {
         configuration = ControllerConfiguration.Default;
         controller.SerializeConfiguration(configuration);
     }
     else
         configuration = controller.DeserializeConfiguration<ControllerConfiguration>();
 }
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            int id = (int) ((sender as Button).Tag);
            SelectedController = Controllers.FirstOrDefault(m => m.ID == id);

            pnlControllersList.Visibility = Visibility.Collapsed;
            pnlControllerConfiguration.Visibility = Visibility.Visible;

            var ctrl = WemosControllerBase.FromController(SelectedController);
            switch (SelectedController.Type)
            {
                case WemosControllerType.ScheduledSwitch:
                    ctrlPresenter.Content = new ucControllerScheduledSwitch();
                    break;


            }
        }
        private void ButtonCancel_Click(object sender, RoutedEventArgs e)
        {
            SelectedController = null;
            ctrlPresenter.Content = null;

            pnlControllersList.Visibility = Visibility.Visible;
            pnlControllerConfiguration.Visibility = Visibility.Collapsed;
        }
        public static WemosControllerBase FromController(WemosController controller)
        {
            if (controller == null)
                return null;

            switch (controller.Type)
            {
                //case WemosControllerType.Heater: return new HeaterController(controller);
                case WemosControllerType.ScheduledSwitch: return new WemosScheduledSwitchController(controller);
                //case WemosControllerType.WaterLevel: return new WaterLevelController(controller);

                default: return null;
            }
        }
 public WemosControllerBase(WemosController controller)
 {
     this.controller = controller;
 }