Exemplo n.º 1
0
        private async void btnDeleteAll_Click(object sender, EventArgs e)
        {
            if (!btnDeleteAll.Enabled)
            {
                return;
            }
            try
            {
                for (int i = 0; i < lbActiveMappings.Items.Count; i++)
                {
                    if (lbActiveMappings.Items[i] is MappingWrapper)
                    {
                        MappingWrapper wrapper = (MappingWrapper)lbActiveMappings.Items[i];
                        Mapping        result  = await dev.Device.DeletePortMapAsync(wrapper.mapping);

                        lbActiveMappings.Items.RemoveAt(i);
                        i--;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void AddMapping(Mapping mapping)
        {
            MappingWrapper wrapper = new MappingWrapper(mapping);

            if (!lbActiveMappings.Items.Contains(wrapper))
            {
                lbActiveMappings.Items.Add(wrapper);
            }
        }
Exemplo n.º 3
0
        private async void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            if (!btnDeleteSelected.Enabled)
            {
                return;
            }
            if (lbActiveMappings.SelectedItem is MappingWrapper)
            {
                MappingWrapper wrapper = (MappingWrapper)lbActiveMappings.SelectedItem;
                try
                {
                    Mapping result = await dev.Device.DeletePortMapAsync(wrapper.mapping);

                    lbActiveMappings.Items.Remove(wrapper);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }