예제 #1
0
        private void EnableAllEquivalentValues(LunComboBoxItem item)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                {
                    return;
                }

                foreach (LunComboBoxItem i in cb.Items)
                {
                    i.EnableItemMatching(item);
                }
            }
            dataGridView.Refresh();
        }
예제 #2
0
        private void DisableOtherEquivalentValues(LunComboBoxItem item, int excludingRowIndex)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                {
                    return;
                }

                if (row.Index != excludingRowIndex)
                {
                    foreach (LunComboBoxItem i in cb.Items)
                    {
                        i.DisableItemMatching(item);
                    }
                }
            }
            dataGridView.Refresh();
        }
예제 #3
0
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != LunColumn.Index || e.RowIndex < 0 || e.RowIndex >= dataGridView.RowCount)
            {
                return;
            }

            dataGridView.BeginEdit(false);

            DataGridViewEnableableComboBoxCell senderItem = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewEnableableComboBoxCell;

            if (senderItem == null)
            {
                return;
            }

            if (dataGridView.EditingControl != null && dataGridView.EditingControl is ComboBox)
            {
                EnableAllEquivalentValues(senderItem.Value as LunComboBoxItem);
                (dataGridView.EditingControl as ComboBox).DroppedDown = true;
            }
        }
예제 #4
0
        protected void ConstructCells()
        {
            var tbVDI = new DataGridViewTextBoxCell {
                Value = VdiColumnText
            };
            var tbSR = new DataGridViewTextBoxCell {
                Value = SrColumnText
            };
            var cbLUN = new DataGridViewEnableableComboBoxCell {
                FlatStyle = FlatStyle.Flat
            };

            foreach (VDI vdi in Sr.Connection.ResolveAll(Sr.VDIs))
            {
                cbLUN.Items.Add(new LunComboBoxItem(vdi)
                {
                    AdditionalConstraints = LunConstraints
                });
            }

            cbLUN.Items.OfType <LunComboBoxItem>().OrderBy(i => i.Enabled);
            Cells.AddRange(tbVDI, cbLUN, tbSR);
            Debug.Assert(cbLUN.Items.Count == Sr.VDIs.Count, "Not all combobox items were converted");
        }
예제 #5
0
        protected void ConstructCells()
        {
            var tbVDI = new DataGridViewTextBoxCell { Value = VdiColumnText };
            var tbSR = new DataGridViewTextBoxCell { Value = SrColumnText };
            var cbLUN = new DataGridViewEnableableComboBoxCell{FlatStyle = FlatStyle.Flat};
            foreach (VDI vdi in Sr.Connection.ResolveAll(Sr.VDIs))
            {
                cbLUN.Items.Add(new LunComboBoxItem(vdi) { AdditionalConstraints = LunConstraints });
            }

            cbLUN.Items.OfType<LunComboBoxItem>().OrderBy(i=>i.Enabled);
            Cells.AddRange(tbVDI, cbLUN, tbSR);
            Debug.Assert(cbLUN.Items.Count == Sr.VDIs.Count, "Not all combobox items were converted");
        }
 private void SetComboBoxPreSelection(DataGridViewEnableableComboBoxCell cb)
 {
     if (cb.Value == null)
     {
         if (cb.Items.Count > 0)
         {
             if (cb.Items.OfType<IEnableableComboBoxItem>().All(i => !i.Enabled))
             {
                 cb.Value = null;
                 SetButtonNextEnabled(false);
             }
             else
                 cb.Value = cb.Items.OfType<IEnableableComboBoxItem>().First(i => i.Enabled);
         }
         else
             SetButtonNextEnabled(false); //do not allow to leave the page if a vm has no target
     }
 }
        private void PopulateDataGridView(List<ReasoningFilter> homeserverFilters)
        {
            Program.AssertOnEventThread();

            updatingHomeServerList = true;
            try
            {
                Connection = null;

                var target = m_comboBoxConnection.SelectedItem as DelayLoadingOptionComboBoxItem;

                if (target != null)
                    Connection = target.Item.Connection;

                ClearDataGridView();

                SetButtonNextEnabled(true);
                var hasPoolSharedStorage = HasPoolSharedStorage();

                foreach (var kvp in m_vmMappings)
                {
                    var tb = new DataGridViewTextBoxCell {Value = kvp.Value.VmNameLabel, Tag = kvp.Key};
                    var cb = new DataGridViewEnableableComboBoxCell{FlatStyle = FlatStyle.Flat};

                    if (Connection != null)
                    {
                        if (hasPoolSharedStorage)
                        {
                            foreach (var pool in Connection.Cache.Pools)
                            {
                                var item = new DoNotAssignHomeServerPoolItem(pool);
                                cb.Items.Add(item);

                                if ((m_selectedObject != null && m_selectedObject.opaque_ref == pool.opaque_ref) ||
                                    (target != null && target.Item.opaque_ref == pool.opaque_ref))
                                    cb.Value = item;

                                break; //there exists one pool per connection
                            }
                        }

                        foreach (var host in Connection.Cache.Hosts)
                        {
                            HomeServerItem item = new HomeServerItem(host, homeserverFilters);
                            cb.Items.Add(item);

                            if ((m_selectedObject != null && m_selectedObject.opaque_ref == host.opaque_ref) ||
                                (target != null && target.Item.opaque_ref == host.opaque_ref))
                                cb.Value = item;
                        }
                    }

                    SetComboBoxPreSelection(cb);

                    var row = new DataGridViewRow();
                    row.Cells.AddRange(tb, cb);
                    m_dataGridView.Rows.Add(row);
                }

                HelpersGUI.ResizeLastGridViewColumn(m_colTarget); //set properly the width of the last column

                if (restoreGridHomeServerSelection)
                {
                    RestoreGridHomeServerSelectionFromMapping();
                    restoreGridHomeServerSelection = false;
                }
            }
            finally
            {
                updatingHomeServerList = false;
            }
        }