Ejemplo n.º 1
0
        /// <summary>
        /// Remove a virtual module from the system.
        /// </summary>
        /// <returns>ProgramHelper.</returns>
        /// <param name="domain">Domain.</param>
        /// <param name="address">Address.</param>
        public ProgramHelper RemoveVirtualModule(string domain, string address)
        {
            VirtualModule oldModule = null;

            try
            {
                oldModule = homegenie.VirtualModules.Find(rm => rm.ParentId == myProgramId.ToString() && rm.Domain == domain && rm.Address == address);
            }
            catch
            {
            }
            if (oldModule != null)
            {
                homegenie.VirtualModules.Remove(oldModule);
            }
            //
            homegenie.modules_RefreshVirtualModules();
            homegenie.modules_Sort();
            return(this);
        }
Ejemplo n.º 2
0
        public ProgramHelper AddControlWidget(string widget)
        {
            ProgramBlock  pb = _homegenie.ProgramEngine.Programs.Find(p => p.Address == _myprogramid);
            VirtualModule m  = _homegenie.VirtualModules.Find(rm => rm.ParentId == _myprogramid.ToString() && rm.Domain == _myprogramdomain && rm.Address == _myprogramid.ToString());

            //
            if (m == null)
            {
                m = new VirtualModule()
                {
                    ParentId = _myprogramid.ToString(), Visible = (widget != ""), Domain = _myprogramdomain, Address = _myprogramid.ToString(), Name = pb.Name, DeviceType = Module.DeviceTypes.Program
                };
                _homegenie.VirtualModules.Add(m);
            }
            //
            m.Name    = pb.Name;
            m.Domain  = _myprogramdomain;
            m.Visible = (widget != "");
            Utility.ModuleParameterSet(m, Properties.WIDGET_DISPLAYMODULE, widget);
            //
            _relocateprogrammodule();
            //
            return(this);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a new set of virtual modules to the system.
 /// </summary>
 /// <returns>ProgramHelper.</returns>
 /// <param name="domain">Domain.</param>
 /// <param name="type">Type.</param>
 /// <param name="widget">Empty string or the path of the widget to be associated to the virtual module.</param>
 /// <param name="startAddress">Start address (numeric).</param>
 /// <param name="endAddress">End address (numeric).</param>
 public ProgramHelper AddVirtualModules(
     string domain,
     string type,
     string widget,
     int startAddress,
     int endAddress
     )
 {
     for (int x = startAddress; x <= endAddress; x++)
     {
         VirtualModule virtualModule = null;
         try
         {
             virtualModule = homegenie.VirtualModules.Find(rm => rm.ParentId == myProgramId.ToString() && rm.Domain == domain && rm.Address == x.ToString());
         }
         catch
         {
         }
         //
         if (virtualModule == null)
         {
             virtualModule = new VirtualModule()
             {
                 ParentId   = myProgramId.ToString(),
                 Domain     = domain,
                 Address    = x.ToString(),
                 DeviceType = (MIG.ModuleTypes)Enum.Parse(
                     typeof(MIG.ModuleTypes),
                     type
                     )
             };
             virtualModule.Properties.Add(new ModuleParameter()
             {
                 Name  = Properties.WidgetDisplayModule,
                 Value = widget
             });
             homegenie.VirtualModules.Add(virtualModule);
         }
         else
         {
             virtualModule.Domain = domain;
             if (virtualModule.DeviceType == MIG.ModuleTypes.Generic)
             {
                 virtualModule.DeviceType = (MIG.ModuleTypes)Enum.Parse(typeof(MIG.ModuleTypes), type);
             }
             Utility.ModuleParameterSet(virtualModule, Properties.WidgetDisplayModule, widget);
         }
         // update real module device type and widget
         Module module = homegenie.Modules.Find(o => o.Domain == virtualModule.Domain && o.Address == virtualModule.Address);
         if (module != null)
         {
             if (module.DeviceType == MIG.ModuleTypes.Generic)
             {
                 module.DeviceType = virtualModule.DeviceType;
             }
             Utility.ModuleParameterSet(module, Properties.WidgetDisplayModule, widget);
         }
     }
     homegenie.modules_RefreshVirtualModules();
     homegenie.modules_Sort();
     return(this);
 }