コード例 #1
0
        private void m_dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 0 || e.RowIndex < 0 || e.RowIndex >= m_dataGridView.RowCount)
            {
                return;
            }

            var row = m_dataGridView.Rows[e.RowIndex];
            var vm  = row.Tag as VM;

            if (vm != null)
            {
                if ((bool)row.Cells[0].Value)
                {
                    if (!VMsToExport.Contains(vm))
                    {
                        VMsToExport.Add(vm);
                    }
                }
                else
                {
                    VMsToExport.Remove(vm);
                }
            }

            m_ctrlError.HideError();
            UpdateCounterLabel();
            IsDirty = true;
            EnableButtons();
        }
コード例 #2
0
        private void m_buttonSelectAll_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow dataGridViewRow in m_dataGridView.Rows)
            {
                dataGridViewRow.Cells[0].Value = true;

                if (dataGridViewRow.Tag is VM vm && !VMsToExport.Contains(vm))
                {
                    VMsToExport.Add(vm);
                }
            }
        }
コード例 #3
0
        public override void PopulatePage()
        {
            var pool = Helpers.GetPoolOfOne(Connection);

            label2.Text = string.Format(Helpers.IsPool(pool.Connection) ? Messages.VMS_IN_POOL : Messages.VMS_IN_SERVER,
                                        pool.Name.Ellipsise(60));
            VMsToExport.Clear();

            try
            {
                m_dataGridView.SuspendLayout();
                m_dataGridView.Rows.Clear();

                var applianceVMs = new List <XenRef <VM> >();
                if (SelectedItems != null && SelectedItems.FirstIsVMappliance)
                {
                    applianceVMs.AddRange(((VM_appliance)SelectedItems.FirstAsXenObject).VMs);
                }

                foreach (var vm in Connection.Cache.VMs.Where(vm => IsVmExportable(vm) && MatchesSearchText(vm)))
                {
                    VM   curVm    = vm;               //closure below
                    bool selected = SelectedItems != null &&
                                    (SelectedItems.AsXenObjects().Contains(vm) || applianceVMs.FirstOrDefault(xenref => xenref.opaque_ref == curVm.opaque_ref) != null);

                    m_dataGridView.Rows.Add(GetDataGridViewRow(vm, selected));

                    if (selected)
                    {
                        VMsToExport.Add(vm);
                    }
                }
                m_dataGridView.Sort(columnTick, ListSortDirection.Descending);
            }
            finally
            {
                m_dataGridView.ResumeLayout();
            }
            UpdateCounterLabel();
            EnableButtons();
        }