Exemplo n.º 1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDeviceList()
 {            
     DeviceGroups = new GXDeviceGroupCollection();
     this.Schedules = new GXScheduleCollection();
     lock(this)
     {
         if (EventHandlers == null)
         {
             EventHandlers = new Dictionary<Guid, IGXEventHandler>();
         }
     }
 }
 void FindParentGroups(object target)
 {
     //Find selected device groups			
     if (target is GXDeviceList)
     {
         ParentCollection = ((GXDeviceList)target).DeviceGroups;
     }
     else if (target is GXDeviceGroupCollection)
     {
         ParentCollection = (GXDeviceGroupCollection)target;
     }
     else if (target is GXDeviceGroup)
     {
         ParentCollection = ((GXDeviceGroup)target).DeviceGroups;
     }
     else if (target is GXDevice)
     {
         ParentCollection = ((GXDeviceGroup)((GXDevice)target).Parent.Parent).Parent;
     }
     else if (target is GXTable)
     {
         ParentCollection = ((GXDeviceGroup)((GXTable)target).Device.Parent.Parent).Parent;
     }
     else if (target is GXCategory)
     {
         ParentCollection = ((GXDeviceGroup)((GXCategory)target).Device.Parent.Parent).Parent;
     }
     else if (target is GXProperty)
     {
         ParentCollection = ((GXDeviceGroup)((GXProperty)target).Device.Parent.Parent).Parent;
     }
     else
     {
         throw new Exception(Gurux.DeviceSuite.Properties.Resources.ErrUnknownNodeTxt);
     }
 }
		private void CreateDeviceGroupNodes(GXDeviceGroupCollection deviceGroups, TreeNode parentNode, object target, ref TreeNode selNode, long UsedDataSources)
		{
			foreach (GXDeviceGroup devGroup in deviceGroups)
			{
				TreeNode groupNode = new TreeNode(devGroup.Name, 0, 0);
				groupNode.Tag = devGroup;
				if (target == devGroup)
				{
					selNode = groupNode;
				}
				parentNode.Nodes.Add(groupNode);
				if (devGroup.DeviceGroups.Count > 0)
				{
					CreateDeviceGroupNodes(devGroup.DeviceGroups, groupNode, target, ref selNode, UsedDataSources);
				}
				foreach (GXDevice device in devGroup.Devices)
				{
					TreeNode deviceNode;
					CreateDeviceNode(device, target, UsedDataSources, out deviceNode, ref selNode);
					deviceNode.Text = device.Name;
					groupNode.Nodes.Add(deviceNode);
				}
			}
		}
		//Recursive
		private void CreateDeviceGroupTree(GXDeviceGroupCollection deviceGroups, TreeNode rootNode)
		{
			foreach (GXDeviceGroup DeviceGroup in deviceGroups)
			{
				TreeNode GroupNode = new TreeNode(DeviceGroup.Name);
				GroupNode.Tag = DeviceGroup;
				GroupNode.SelectedImageIndex = GroupNode.ImageIndex = 1;
				rootNode.Nodes.Add(GroupNode);
				//Add devices
				foreach (GXDevice Device in DeviceGroup.Devices)
				{
					TreeNode DeviceNode = new TreeNode(Device.Name);
					DeviceNode.Tag = Device;
					DeviceNode.SelectedImageIndex = DeviceNode.ImageIndex = 2;
					GroupNode.Nodes.Add(DeviceNode);
					//Add tables
					foreach (GXTable table in Device.Tables)
					{
						TreeNode TableNode = new TreeNode(table.Name);
						TableNode.Tag = table;
						TableNode.SelectedImageIndex = TableNode.ImageIndex = 3;
						DeviceNode.Nodes.Add(TableNode);

						//Table properties cannot be selected.
					}
					//Add categories
					foreach (GXCategory cat in Device.Categories)
					{
						TreeNode CategoryNode = new TreeNode(cat.Name);
						CategoryNode.Tag = cat;
						CategoryNode.SelectedImageIndex = CategoryNode.ImageIndex = 4;
						DeviceNode.Nodes.Add(CategoryNode);
						//Add category properties
						foreach (GXProperty prop in cat.Properties)
						{
							TreeNode PropNode = new TreeNode(prop.Name);
							PropNode.Tag = prop;
							PropNode.SelectedImageIndex = PropNode.ImageIndex = 5;
							CategoryNode.Nodes.Add(PropNode);
						}
					}
				}
				//Recursion
				CreateDeviceGroupTree(DeviceGroup.DeviceGroups, GroupNode);
			}
		}
Exemplo n.º 5
0
 /// <summary>
 /// Override this to made changes before device group load.
 /// </summary>
 protected override void OnDeserializing(bool designMode)
 {
     DeviceGroups = new GXDeviceGroupCollection();
     Devices = new GXDeviceCollection();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDeviceGroup()
 {
     DeviceGroups = new GXDeviceGroupCollection();
     Devices = new GXDeviceCollection();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Override this to made changes before device list load.
        /// </summary>
        protected override void OnDeserializing(bool designMode)
        {
			DeviceGroups = new GXDeviceGroupCollection();
			this.Schedules = new GXScheduleCollection();
            lock(this)
            {
                if (EventHandlers == null)
                {
                    EventHandlers = new Dictionary<Guid, IGXEventHandler>();
                }
            }
        }
Exemplo n.º 8
0
 void NotifySerialized(bool serialized, GXDeviceGroupCollection groups)
 {
     GXSite site;
     foreach (GXDeviceGroup group in groups)
     {
         foreach (GXDevice device in group.Devices)
         {
             foreach (GXCategory cat in device.Categories)
             {
                 foreach (GXProperty prop in cat.Properties)
                 {
                     site = prop as GXSite;
                     site.NotifySerialized(serialized);
                 }
                 site = cat as GXSite;
                 site.NotifySerialized(serialized);
             }
             foreach (GXTable table in device.Tables)
             {
                 foreach (GXProperty prop in table.Columns)
                 {
                     site = prop as GXSite;
                     site.NotifySerialized(serialized);
                 }
                 site = table as GXSite;
                 site.NotifySerialized(serialized);
             }
         }
         NotifySerialized(serialized, group.DeviceGroups);
         site = group as GXSite;
         site.NotifySerialized(serialized);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Delete selected device groups.
 /// </summary>
 /// <param name="deviceGroups">A collection of device groups to be deleted.</param>
 public void DeleteDeviceGroups(GXDeviceGroupCollection deviceGroups)
 {
     if (deviceGroups == null)
     {
         System.Diagnostics.Debug.Assert(false);
         return;
     }
     //Show default Gurux dialog.
     if (GXCommon.ShowExclamation(ParentComponent, Gurux.DeviceSuite.Properties.Resources.GuruxDeviceSuiteTxt, Gurux.DeviceSuite.Properties.Resources.RemoveDeviceTxt) != DialogResult.Yes)
     {
         return;
     }
     deviceGroups.Clear();
 }
Exemplo n.º 10
0
 private void ShowAvailableDeviceGroups(GXDeviceGroupCollection groups, TreeNodeCollection nodes, bool showDevices)
 {
     foreach (GXDeviceGroup group in groups)
     {
         ShowAvailableDeviceGroup(group, nodes, showDevices);
     }
 }