Esempio n. 1
0
        /// <summary>
        /// Event delegate method fired when the <see cref="DeleteButton"/> button is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            switch (_selectedItem)
            {
            case null:
                return;

            case MySqlService selectedService:
            {
                var machine = MachinesList.GetMachineById(selectedService.Host.MachineId);
                machine.ChangeService(selectedService, ListChangeType.RemoveByUser);
                MonitoredServicesListView.Items.RemoveAt(MonitoredServicesListView.SelectedIndices[0]);
                break;
            }

            case MySqlInstance selectedInstance:
            {
                if (InstancesList.Remove(selectedInstance))
                {
                    MonitoredInstancesListView.Items.RemoveAt(MonitoredInstancesListView.SelectedIndices[0]);
                }

                break;
            }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Event delegate method fired when the <see cref="DeleteButton"/> button is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (_selectedItem == null)
            {
                return;
            }

            if (_selectedItem is MySqlService)
            {
                var     selectedService = (MySqlService)_selectedItem;
                Machine machine         = MachinesList.GetMachineById(selectedService.Host.MachineId);
                machine.ChangeService(selectedService, ListChangeType.RemoveByUser);
                MonitoredServicesListView.Items.RemoveAt(MonitoredServicesListView.SelectedIndices[0]);
            }
            else if (_selectedItem is MySqlInstance)
            {
                var selectedInstance = (MySqlInstance)_selectedItem;
                if (InstancesList.Remove(selectedInstance))
                {
                    MonitoredInstancesListView.Items.RemoveAt(MonitoredInstancesListView.SelectedIndices[0]);
                }
            }
        }