private BaseItem GetTileForModule(Module m)
 {
     BaseItem tile = null;
     ModuleParameter widget = m.GetProperty("Widget.DisplayModule");
     if (widget != null && !String.IsNullOrEmpty(widget.Value))
     {
         switch (widget.Value)
         {
             case "homegenie/generic/sensor":
             case "homegenie/generic/temperature":
                 tile = new SensorItem();
                 break;
             case "homegenie/generic/doorwindow":
                 tile = new DoorWindowItem();
                 break;
             default:
                 tile = new GenericItem();
                 break;
         }
     }
     else
     {
         switch (m.DeviceType)
         {
             case "Sensor":
             case "Temperature":
                 tile = new SensorItem();
                 break;
             case "DoorWindow":
                 tile = new DoorWindowItem();
                 break;
             default:
                 tile = new GenericItem();
                 break;
         }
     }
     return tile;
 }
 void ShowModuleScreen(Module m)
 {
     BaseWidget widget = null;
     //
     ModuleParameter widgetProperty = m.GetProperty("Widget.DisplayModule");
     if (widgetProperty != null && !String.IsNullOrEmpty(widgetProperty.Value))
     {
         switch (widgetProperty.Value)
         {
             case "homegenie/generic/light":
             case "homegenie/generic/switch":
                 widget = new Switch();
                 break;
             case "homegenie/generic/dimmer":
                 widget = new Dimmer();
                 break;
             case "homegenie/generic/colorlight":
                 widget = new ColorLight();
                 break;
             case "weather/wunderground/conditions":
                 widget = new Weather();
                 break;
             default:
                 break;
         }
     }
     //
     if (widget == null)
     {
         if (m.DeviceType == "Dimmer" || m.DeviceType == "Light" || m.DeviceType == "Shutter" || m.DeviceType == "Siren")
         {
             widget = new Dimmer();
         }
         else if (m.DeviceType == "Switch")
         {
             widget = new Switch();
         }
     }
     //
     if (widget != null)
     {
         widget.CloseButtonClicked += (sender, args) =>
         {
             this.Controls.Remove(widget);
             this.Controls.Add(currentWidget);
             widgetCycle.Start();
         };
         widget.Module = m;
         widget.Dock = DockStyle.Fill;
         //
         widgetCycle.Stop();
         this.Controls.Remove(currentWidget);
         this.Controls.Add(widget);
     }
 }
 private bool IsValidControlModule(Module m)
 {
     bool isValid = false;
     ModuleParameter widget = m.GetProperty("Widget.DisplayModule");
     if (m.DeviceType != "Program" || (widget != null && !String.IsNullOrEmpty(widget.Value) && widget.Value != "homegenie/generic/program"))
     {
         isValid = true;
     }
     return isValid;
 }