Пример #1
0
        /// <summary>
		/// Initializes a new instance of the OpenDlg class.
		/// </summary>
        public OpenDlg(GXDeviceManufacturerCollection manufacturers, GXDeviceProfile target)
		{			
			InitializeComponent();
            Target = target;
            Manufacturers = manufacturers;            
			UpdateResources();
            if (GXDeviceList.GetDeviceTypes(false, null).Count == 0 && GXDeviceList.GetDeviceTypes(true, null).Count == 0)
            {
                throw new Exception(Gurux.DeviceSuite.Properties.Resources.NoDevicesPublishedTxt);
            }
            ShowPresetDevices();
			ShowCustomDeviceTypes();
		}
Пример #2
0
 /// <summary>
 /// Copy Constructor.
 /// </summary>
 public GXDeviceProfile(GXDeviceProfile item)
 {
     Protocol = item.Protocol;
     Name = item.Name;
     Description = item.Description;
     this.Guid = Guid;
     this.ProfileGuid = item.ProfileGuid;
     this.DeviceManufacturer = item.DeviceManufacturer;
     this.DeviceModel = item.DeviceModel;
     this.DeviceVersion = item.DeviceVersion;
     this.Publisher = item.Publisher;
     this.Anynomous = item.Anynomous;
     this.Version = item.Version;
     this.Date = item.Date;
 }
 private void LoadDevice(GXDeviceProfile deviceType)
 {
     try
     {
         if (deviceType == null)
         {
             throw new Exception("LoadDevice failed: DeviceType is null");
         }
         this.Cursor = Cursors.WaitCursor;
         Clear();
         Device = GXDevice.Load(deviceType.Path);
         ShowProperties(Device);
         ParentComponent.CloseMenu.Enabled = true;                
         ParentComponent.ImportMenu.Enabled = Device.AddIn.ImportFromDeviceEnabled;
         Device.Dirty = false;
         ValidateTasks();
     }
     catch (Exception Ex)
     {
         GXCommon.ShowError(ParentComponent, Ex);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Пример #4
0
 void ApplyChanges(GXDeviceProfile dp)
 {
     if (Device)
     {
         Arguments.Target = GXDevice.Create(dp.Protocol, dp.Name, "");
     }
     else
     {
         Arguments.Target = dp;
     }
     try
     {
         GXJsonParser parser = new GXJsonParser();
         GXDeviceProfileFormSettings settings = new GXDeviceProfileFormSettings();
         settings.Custom = CustomCB.Checked;
         settings.Download = DownloadCB.Checked;
         settings.SearchText = SearchTB.Text;
         settings.Earlier = ShowEarlierVersionsCB.Checked;
         Arguments.Settings = parser.Serialize(settings);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     if (Arguments.OnSelect != null)
     {
         if (Arguments.UseThread)
         {
             DialogResult = DialogResult.None;
             Work = new GXAsyncWork(this, OnAsyncStateChange, OnSelect, null, "Selecting", null);
             Work.Start();
             return;
         }
         else
         {
             Arguments.OnSelect(Arguments.Target, Arguments);
         }
     }
     DialogResult = DialogResult.OK;
     Close();
 }
Пример #5
0
        void AddProfile(GXDeviceProfile it, string searchText)
        {
            if (Arguments.Edit || !(Arguments.Target is GXDevice))
            {
                if (searchText == null || it.Name.ToLower().Contains(searchText) || 
                    it.Protocol.ToLower().Contains(searchText) ||
                    (it.DeviceManufacturer != null && it.DeviceManufacturer.ToLower().Contains(searchText)) ||
                    (it.DeviceModel != null && it.DeviceModel.ToLower().Contains(searchText)) ||
                    (it.DeviceVersion != null && it.DeviceVersion.ToLower().Contains(searchText)))
                {

                    ListViewItem li = new ListViewItem(new string[] { it.Name, it.Protocol, 
                        it.DeviceManufacturer, it.DeviceModel, it.DeviceVersion, it.VersionToString() });
                    li.Tag = it;
                    DeviceProfiles.Items.Add(li);
                    if (Arguments.Target != null && (Arguments.Target as GXDeviceProfile).ProfileGuid == it.ProfileGuid)
                    {
                        li.Selected = true;
                    }
                }
            }
            else if ((Arguments.Target as GXDevice).Guid == it.Guid)
            {
                //If edit is not allowed only selected device is shown.
                ListViewItem li = new ListViewItem(new string[] { it.Name, it.Protocol, 
                        it.DeviceManufacturer, it.DeviceModel, it.DeviceVersion, it.VersionToString() });
                li.Tag = it;
                DeviceProfiles.Items.Add(li);
                li.Selected = true;
                return;
            }
        }
Пример #6
0
 protected virtual void OKBtn_Click(object sender, System.EventArgs e)
 {
     this.Checked = GetChecked();
     if (this.Checked == null)
     {
         return;
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Пример #7
0
 /// <summary>
 /// Unregisters the device profile.
 /// </summary>
 public static bool Unregister(GXDeviceProfile profile)
 {
     GXDeviceProfileCollection list = GXDeviceList.DeviceProfiles;
     GXDeviceProfile it = list.Find(profile.Guid);
     if (it == null)
     {
         return false;
     }
     list.Remove(it);
     GXJsonParser.Save(list, GXDeviceList.DeviceProfilesPath);
     return true;
 }