/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="version"></param>
 public GXDeviceVersionForm(GXDeviceVersion version)
 {
     Version = version;
     InitializeComponent();
     NameTB.Text = Version.Name;
     DescriptionTB.Text = Version.Description;
 }
 /// <summary>
 /// Copy Constructor.
 /// </summary>
 public GXDeviceVersion(GXDeviceVersion item)
 {
     Name = item.Name;
     Description = item.Description;
     m_Profiles = new GXDeviceProfileCollection(this);
     foreach (GXDeviceProfile it in item.Profiles)
     {
         m_Profiles.Add(it);
     }
 }
 public void Next()
 {
     if (VersionCB.SelectedIndex == -1)
     {
         VersionCB.Focus();
         throw new Exception(Gurux.DeviceSuite.Properties.Resources.ErrNameEmptyTxt);
     }
     if ((VersionCB.SelectedItem as GXDeviceVersion).Templates.Count == 0)
     {
         throw new Exception(Gurux.DeviceSuite.Properties.Resources.PublishFailedNotEnoughtData);
     }
     //Update selected version to target.
     Target = SelectedVersion = VersionCB.SelectedItem as GXDeviceVersion;
     Item.Manufacturers[0].Models[0].Versions.Clear();
     Item.Manufacturers[0].Models[0].Versions.Add(SelectedVersion);
 }
 /// <summary>
 /// Add new device template and select it.
 /// </summary>
 private void AddTemplate(GXDeviceVersion version)
 {
     try
     {
         GXPublishedDeviceProfile type = new GXPublishedDeviceProfile();
         type.Status = DownloadStates.Add;
         GXDeviceProfilesForm dlg = new GXDeviceProfilesForm(type);
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             type = dlg.Target;
             type.Status = DownloadStates.Add;
             version.Templates.Add(type);
             //Add list item.
             ListViewItem li = PresetList.Items.Add(type.PresetName);
             li.Tag = type;
             ItemToListItem[type] = li;
         }
     }
     catch (Exception ex)
     {
         GXCommon.ShowError(this.Parent, ex);
     }
 }
 /// <summary>
 /// Add new version and select it.
 /// </summary>
 private void AddVersion(GXDeviceModel model)
 {
     try
     {
         GXDeviceVersion version = new GXDeviceVersion();
         version.Status = DownloadStates.Add;
         GXDeviceVersionForm dlg = new GXDeviceVersionForm(version);
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             model.Versions.Add(version);
             //Add tree item.
             TreeNode parentNode = ItemToTreeNode[model] as TreeNode;
             TreeNode node = parentNode.Nodes.Add(version.Name);
             node.Tag = version;
             ItemToTreeNode[version] = node;
             //Add list item.
             ListViewItem li = PresetList.Items.Add(version.Name);
             li.Tag = version;
             ItemToListItem[version] = li;
             //Select new item from the tree.
             PresetTree.SelectedNode = node;
         }
     }
     catch (Exception ex)
     {
         GXCommon.ShowError(this.Parent, ex);
     }
 }
 /// <summary>
 /// Edit selected version.
 /// </summary>
 private void EditVersion(GXDeviceVersion version)
 {
     try
     {
         GXDeviceVersionForm dlg = new GXDeviceVersionForm(version);
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             TreeNode node = ItemToTreeNode[version] as TreeNode;
             node.Text = version.Name;
         }
     }
     catch (Exception ex)
     {
         GXCommon.ShowError(this.Parent, ex);
     }
 }