void UpdateMedias() { MediaCB.Items.Clear(); List<string> medias = new List<string>(); if (Device.AllowedMediaTypes.Count == 0) { medias.AddRange(Gurux.Communication.GXClient.GetAvailableMedias()); } else { List<string> availableMedias = new List<string>(Gurux.Communication.GXClient.GetAvailableMedias()); string gw = new GXAmiGateway().MediaType; foreach (GXMediaType it in Device.AllowedMediaTypes) { if (availableMedias.Contains(it.Name)) { medias.Add(it.Name); } } //Add Gateway media. if (!medias.Contains(gw)) { medias.Add(gw); } } string selectedMediaType = Device.GXClient.MediaType; foreach (string it in medias) { int pos = MediaCB.Items.Add(it); if (Device != null && selectedMediaType == it) { MediaCB.SelectedIndex = pos; } } if (MediaCB.SelectedIndex == -1) { MediaCB.SelectedIndex = 0; } PropertyGrid.SelectedObject = Device; SettingsForm = Device.AddIn.GetCustomUI(Device); if (SettingsForm != null) { SettingsForm.Location = SettingsPanel.Location; SettingsForm.Width = SettingsPanel.Width; SettingsForm.Height = SettingsPanel.Height; SettingsPanel.Visible = true; PropertyGrid.Visible = false; if (SettingsForm as IGXPropertyPage == null) { throw new Exception("Custom Device UI do not implement IGXPropertyPage interface."); } while (SettingsForm.Controls.Count != 0) { Control ctr = SettingsForm.Controls[0]; if (ctr is Panel) { if (!ctr.Enabled) { SettingsForm.Controls.RemoveAt(0); continue; } } SettingsPanel.Controls.Add(ctr); } ((IGXPropertyPage)SettingsForm).Initialize(); } else { SettingsPanel.Visible = false; PropertyGrid.Visible = true; } }
public Settings(GXAmiGateway target) { Target = target; InitializeComponent(); }