private void buttonControlAdd_Click(object sender, RoutedEventArgs e)
        {
            Control c = new Control
            {
                ControlId = GetFirstAvailableID()
            };

            Controls.Add(c);
            LoadedControls.Add(c);
            lblNoControls.Visibility = Visibility.Hidden;
            ControlObjectEditor editor = new ControlObjectEditor(c);

            editor.Closed += async delegate
            {
                await c.SaveAsync();

                if (Diseases.ElementAt(listDiseases.SelectedIndex).ControlIds.Count == 0)
                {
                    List <int> ids = new List <int>();
                    ids.Add(c.ControlId);
                    Diseases.ElementAt(listDiseases.SelectedIndex).ControlIds = ids;
                }
                else
                {
                    Diseases.ElementAt(listDiseases.SelectedIndex).ControlIds.Add(c.ControlId);
                }
                FindControls(Diseases.ElementAt(listDiseases.SelectedIndex));
                await(Diseases.ElementAt(listDiseases.SelectedIndex)).SaveAsync();

                listControls.SelectedIndex = LoadedControls.Count - 1;
            };
            editor.ShowDialog();
        }
        void listControls_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (listControls.SelectedIndex == -1)
            {
                return;
            }
            Control             c      = LoadedControls.ElementAt(listControls.SelectedIndex);
            ControlObjectEditor window = new ControlObjectEditor(c);

            window.Closed += async delegate
            {
                await c.SaveAsync();
            };
            window.ShowDialog();
        }