/// <summary>
		/// Constructor. Initializes the dialog and populates the tree.
		/// </summary>
        public GXDataIOSourceDialog(GXDataIOSource dataIOSource, GXDataIOSourceAttribute sourceAttributes, GXDeviceList list)
        {
            InitializeComponent();
			PopulateTree(dataIOSource, sourceAttributes, list);
        }
            public List <object[]> Import(string path, string target, out byte[] data, out string assemblyName, out string addInType)
            {
                data            = null;
                TargetDirectory = target;
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                GXDeviceProfile type = GXZip.Import(null, path, target);

                GXDeviceList.Update(target);
                string filename = Path.Combine(target, type.DeviceGuid + ".gxp");

                using (FileStream s = File.OpenRead(filename))
                {
                    long size = s.Length;
                    size = 0;
                }
                GXDevice device = GXDevice.Load(filename);

                addInType    = device.AddIn.ToString();
                assemblyName = device.AddIn.GetType().Assembly.FullName;
                GXAmiDeviceProfile dt = new GXAmiDeviceProfile();

                dt.Guid           = device.Guid;
                dt.Protocol       = device.ProtocolName;
                dt.Profile        = device.DeviceProfile;
                dt.PresetName     = device.PresetName;
                dt.Manufacturer   = device.Manufacturer;
                dt.Model          = device.Model;
                dt.Version        = device.Version;
                dt.UpdateInterval = device.UpdateInterval;
                dt.WaitTime       = device.WaitTime;
                dt.ResendCount    = device.ResendCount;
                dt.Added          = DateTime.Now.ToUniversalTime();
                List <GXAmiMediaType> list   = new List <GXAmiMediaType>();
                List <string>         medias = new List <string>(Gurux.Communication.GXClient.GetAvailableMedias());

                foreach (GXMediaType it in device.AllowedMediaTypes)
                {
                    GXAmiMediaType mt = new GXAmiMediaType();
                    mt.Name = it.Name;
                    //If default media settings are not given, ask them from the parser.
                    if (string.IsNullOrEmpty(it.DefaultMediaSettings) && medias.Contains(it.Name))
                    {
                        Gurux.Common.IGXMedia m = device.GXClient.SelectMedia(it.Name);
                        mt.Settings = m.Settings;
                    }
                    else
                    {
                        mt.Settings = it.DefaultMediaSettings;
                    }
                    list.Add(mt);
                }
                dt.AllowedMediaTypes = list.ToArray();
                List <object[]> items = new List <object[]>();

                items.Add(new object[] { dt, dt });
                ImportParameters(device, device.ID, dt, items);
                foreach (GXCategory cat in device.Categories)
                {
                    GXAmiCategoryTemplate ct = new GXAmiCategoryTemplate();
                    items.Add(new object[] { dt, ct });
                    ct.Name = cat.Name;
                    ct.Id   = cat.ID;
                    ImportParameters(cat, cat.ID, ct, items);
                    foreach (GXProperty prop in cat.Properties)
                    {
                        GXAmiPropertyTemplate pt = new GXAmiPropertyTemplate();
                        pt.Id       = prop.ID;
                        pt.ParentID = cat.ID;
                        pt.Name     = prop.Name;
                        pt.Unit     = prop.Unit;
                        if (prop.ValueType != null)
                        {
                            pt.TypeAsString = prop.ValueType.ToString();
                        }
                        pt.AccessMode = prop.AccessMode;
                        items.Add(new object[] { dt, pt });
                        ImportParameters(prop, prop.ID, pt, items);
                    }
                }

                foreach (GXTable table in device.Tables)
                {
                    GXAmiDataTableTemplate tt = new GXAmiDataTableTemplate();
                    items.Add(new object[] { dt, tt });
                    tt.Name = table.Name;
                    tt.Id   = table.ID;
                    ImportParameters(table, table.ID, tt, items);
                    foreach (GXProperty prop in table.Columns)
                    {
                        GXAmiPropertyTemplate pt = new GXAmiPropertyTemplate();
                        pt.Id       = prop.ID;
                        pt.ParentID = table.ID;
                        pt.Name     = prop.Name;
                        pt.Unit     = prop.Unit;
                        if (prop.ValueType != null)
                        {
                            pt.TypeAsString = prop.ValueType.ToString();
                        }
                        pt.AccessMode = prop.AccessMode;
                        items.Add(new object[] { dt, pt });
                        ImportParameters(prop, prop.ID, pt, items);
                    }
                }
                return(items);
            }