Ejemplo n.º 1
0
        async Task EditIPAddressCell(NetworkDeviceItem editedNDI, DataGridViewCell editedCell, string proposedAddress)
        {
            string oldAddress = editedNDI.IpAddress;
            Task   task       = editedNDI.ChangeIPAddress(proposedAddress);

            try
            {
                await task.ConfigureAwait(true);
            }
            catch (ArgumentException ex)
            {
                editedCell.Value = oldAddress;
                txt_Status.AppendText(ex.Message + Environment.NewLine);
            }
            catch (EngineeringNotSupportedException ex)
            {
                editedCell.Value = oldAddress;

                txt_Status.AppendText(ex.Message + Environment.NewLine);
                Debug.WriteLine(ex.Message);
            }

            string newAddress = editedNDI.IpAddress;

            editedCell.Value = newAddress;
            if (editedNDI.IpAddress == proposedAddress)
            {
                txt_Status.AppendText($"Device \"{editedNDI.HMName}\" changed IP address from: {oldAddress} to: {newAddress}." +
                                      $"{Environment.NewLine}");
            }

            DeviceRowsHelper.MarkRepeatingIPs(deviceTable.Rows, dgv_IpAddress.Index, dgv_Mode.Index);
        }
Ejemplo n.º 2
0
        private void PopulateDeviceTable(SortBy sortingOrder, string searchText)
        {
            if (projectLevel == null)
            {
                Debug.WriteLine("Nothing to populate device table with.");
                return;
            }

            deviceTableAutoEdit = true;
            deviceTable.Rows.Clear();
            ID.Clear();
            DeviceRowsHelper.DeviceByRowID.Clear();

            if (String.IsNullOrWhiteSpace(searchText) | searchText.Length <= 2)
            {
                deviceTable.Rows.AddRange(GetMatchingRows(sortingOrder).ToArray());
            }
            else
            {
                deviceTable.Rows.AddRange(GetMatchingRows(sortingOrder, searchText).ToArray());
            }
            deviceTableAutoEdit = false;

            DeviceRowsHelper.MarkRepeatingIPs(deviceTable.Rows, dgv_IpAddress.Index, dgv_Mode.Index);
        }