public GXManufacturerForm(GXDeviceManufacturer manufacturer)
 {
     InitializeComponent();
     Manufacturer = manufacturer;
     NameTB.Text = manufacturer.Name;
     WebAddressTB.Text = manufacturer.Url;
 }
 /// <summary>
 /// Copy Constructor.
 /// </summary>
 public GXDeviceManufacturer(GXDeviceManufacturer item)
 {
     m_Models = new GXDeviceModelCollection(this);
     Name = item.Name;
     Url = item.Url;
     foreach (GXDeviceModel it in item.Models)
     {
         Models.Add(new GXDeviceModel(it));
     }            
 }
 public void Next()
 {
     if (ManufacturerCB.SelectedIndex == -1)
     {
         ManufacturerCB.Focus();
         throw new Exception(Gurux.DeviceSuite.Properties.Resources.ErrNameEmptyTxt);
     }
     if ((ManufacturerCB.SelectedItem as GXDeviceManufacturer).Models.Count == 0)
     {
         throw new Exception(Gurux.DeviceSuite.Properties.Resources.PublishFailedNotEnoughtData);
     }
     //Update selected manufacturer to target.
     Target = new GXDeviceManufacturer(ManufacturerCB.SelectedItem as GXDeviceManufacturer);
     Item.Manufacturers.Clear();
     Item.Manufacturers.Add(Target as GXDeviceManufacturer);
 }
 /// <summary>
 /// Add new model.
 /// </summary>
 private void AddModel(GXDeviceManufacturer man)
 {            
     GXDeviceModel model = new GXDeviceModel();
     model.Status = DownloadStates.Add;
     GXDeviceModelForm dlg = new GXDeviceModelForm(model);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         man.Models.Add(model);
         //Add tree item.
         TreeNode parentNode = ItemToTreeNode[man] as TreeNode;
         TreeNode node = parentNode.Nodes.Add(model.Name);
         node.Tag = model;
         ItemToTreeNode[model] = node;
         //Add list item.
         ListViewItem li = PresetList.Items.Add(model.Name);
         li.Tag = model;
         ItemToListItem[model] = li;
         //Select new item from the tree.
         PresetTree.SelectedNode = node;
     }
 }
 /// <summary>
 /// Add new manufacturer.
 /// </summary>
 private void AddManufacturer()
 {
     GXDeviceManufacturer manufacturer = new GXDeviceManufacturer();
     manufacturer.Status = DownloadStates.Add;
     GXManufacturerForm dlg = new GXManufacturerForm(manufacturer);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         PresetManufacturers.Add(manufacturer);
         ListViewItem li = PresetList.Items.Add(manufacturer.Name);
         li.Tag = manufacturer;
         TreeNode manNode = ManufacturersNode.Nodes.Add(manufacturer.Name);
         manNode.Tag = manufacturer;
         ItemToListItem[manufacturer] = li;
         ItemToTreeNode[manufacturer] = manNode;
         PresetTree.SelectedNode = manNode;
     }
 }
 /// <summary>
 /// Edit selected manufacturer.
 /// </summary>
 private void EditManufacturer(GXDeviceManufacturer manufacturer)
 {
     GXManufacturerForm dlg = new GXManufacturerForm(manufacturer);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         TreeNode manNode = ItemToTreeNode[manufacturer] as TreeNode;
         manNode.Text = manufacturer.Name;
     }
 }
 GXPublishedDeviceProfile UpdatePublishedDeviceType(GXDeviceProfileVersion tv, byte[] data)
 {
     GXPublishedDeviceProfile dt = tv.Parent.Parent;
     GXDeviceVersion dv = dt.Parent.Parent;
     GXDeviceModel model = dv.Parent.Parent;
     GXDeviceManufacturer man = model.Parent.Parent;
     GXPublishedDeviceProfile type = GXZip.Import(this, data, null) as GXPublishedDeviceProfile;            
     GXDeviceManufacturer ma;
     dt.DeviceGuid = type.DeviceGuid;
     if ((ma = PresetManufacturers.Find(man)) == null)
     {
         GXDeviceManufacturer man2 = new GXDeviceManufacturer(man);
         GXPublishedDeviceProfileCollection templates = man2.Models.Find(model).Versions.Find(dv).Templates;
         templates.Clear();
         templates.Add(dt);
         PresetManufacturers.Add(man2);
     }
     else
     {
         GXDeviceModel mo = ma.Models.Find(model);
         if (mo == null)
         {
             ma.Models.Add(new GXDeviceModel(model));
         }
         else
         {
             GXDeviceVersion ve = mo.Versions.Find(dv);
             if (ve == null)
             {
                 mo.Versions.Add(new GXDeviceVersion(dv));
             }
             else
             {
                 GXPublishedDeviceProfile dt3 = ve.Templates.Find(dt.PresetName);
                 if (dt3 == null)
                 {
                     ve.Templates.Add(new GXPublishedDeviceProfile(dt));
                 }
                 else
                 {
                     dt3.Versions.Clear();
                     dt3.Versions.Add(tv);
                 }
             }
         }
     }
     return type;
 }
Exemplo n.º 8
0
 public void Initialize()
 {
     GXDeviceManufacturer man = Target as GXDeviceManufacturer;
     if (man != null)
     {
         SelectedManufacturer = man;
         ModelCB.Items.Clear();
         foreach (GXDeviceModel it in man.Models)
         {
             ModelCB.Items.Add(it);
         }
         if (ModelCB.Items.Count != 0)
         {
             ModelCB.SelectedIndex = 0;
         }
     }            
 }