Пример #1
0
 protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0 && e.RowIndex < Rows.Count)
     {
         if (e.Button == MouseButtons.Left)
         {
             SetCurrentRow(e.RowIndex);
             SetRowSelection(false);
             Invalidate();
         }
         else if (e.Button == MouseButtons.Right)
         {
             DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[e.RowIndex];
             if (!m_isControlDown && !row.selected)
             {
                 SetCurrentRow(e.RowIndex);
                 SetRowSelection(false);
                 Invalidate();
             }
             ContextMenuStrip = m_core.CanApply(CoreDll.ActionEnableType.Any) ? m_contextMenuStrip : null;
         }
     }
     else
     {
         ContextMenuStrip = null;
     }
     base.OnCellMouseDown(e);
 }
Пример #2
0
        public bool MoveEnable()
        {
            bool moveEnable = false;

            if (m_results.Length > 0)
            {
                for (int i = 0; i < Rows.Count; i++)
                {
                    DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[i];
                    if (row.selected)
                    {
                        if (String.IsNullOrEmpty(m_results[i].second.path))
                        {
                            return(false);
                        }
                        if (!Path.GetDirectoryName(m_results[i].first.path).Equals(Path.GetDirectoryName(m_results[i].second.path)))
                        {
                            moveEnable = true;
                            break;
                        }
                    }
                }
            }
            return(moveEnable);
        }
Пример #3
0
 private void SetColumns(ResultsOptions.ViewMode viewMode)
 {
     Rows.Clear();
     RowCount = 1;
     if (viewMode == ResultsOptions.ViewMode.VerticalPairTable)
     {
         ColumnCount = (int)ColumnsTypeVertical.Size;
         for (int i = 0; i < (int)ColumnsTypeVertical.Size; i++)
         {
             Columns[i].Name         = ((ColumnsTypeVertical)i).ToString();
             Columns[i].SortMode     = DataGridViewColumnSortMode.Programmatic;
             Columns[i].Width        = m_options.resultsOptions.columnOptionsVertical[i].width;
             Columns[i].DisplayIndex = m_options.resultsOptions.columnOptionsVertical[i].order;
         }
         Rows[0].Cells[0] = new DataGridViewDoubleTextBoxCell("0", "0");
     }
     if (viewMode == ResultsOptions.ViewMode.HorizontalPairTable)
     {
         ColumnCount = (int)ColumnsTypeHorizontal.Size;
         for (int i = 0; i < (int)ColumnsTypeHorizontal.Size; i++)
         {
             Columns[i].Name         = ((ColumnsTypeHorizontal)i).ToString();
             Columns[i].SortMode     = DataGridViewColumnSortMode.Programmatic;
             Columns[i].Width        = m_options.resultsOptions.columnOptionsHorizontal[i].width;
             Columns[i].DisplayIndex = m_options.resultsOptions.columnOptionsHorizontal[i].order;
         }
         Rows[0].Cells[0]       = new DataGridViewTextBoxCell();
         Rows[0].Cells[0].Value = "0";
     }
     RowTemplate        = new DataGridViewCustomRow();
     RowTemplate.Height = Rows[0].Cells[0].PreferredSize.Height;
     Rows.Clear();
     UpdateRows();
 }
Пример #4
0
 private void SetRowSelection(int beginRowIndex, int endRowIndex, bool value)
 {
     for (int i = beginRowIndex; i < endRowIndex; i++)
     {
         DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[i];
         row.selected = value;
     }
     m_core.SetSelection((UInt32)beginRowIndex, (UInt32)(endRowIndex - beginRowIndex), value);
 }
Пример #5
0
        protected override void OnRowPrePaint(DataGridViewRowPrePaintEventArgs e)
        {
            int index = e.RowIndex;
            DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[index];

            if (!row.updated && index >= 0 && index < m_results.Length)
            {
                m_resultRowSetter.Set(m_results[index], row);
                row.updated = true;
            }
            row.current = (index == m_currentRowIndex);
            base.OnRowPrePaint(e);
        }
Пример #6
0
        public void Set(CoreResult result, DataGridViewCustomRow row)
        {
            switch (result.type)
            {
            case CoreDll.ResultType.DefectImage:
                SetDefectToRow(row.Cells, result);
                break;

            case CoreDll.ResultType.DuplImagePair:
                SetDuplPairToRow(row.Cells, result);
                break;
            }
        }
Пример #7
0
        public int GetSelectedResultCount()
        {
            int selectedResultsCount = 0;

            for (int i = 0; i < Rows.Count; i++)
            {
                DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[i];
                if (row.selected && i >= 0 && i < m_results.Length)
                {
                    selectedResultsCount++;
                }
            }
            return(selectedResultsCount);
        }
Пример #8
0
        public override DataObject GetClipboardContent()
        {
            DataObject dataObject = new DataObject();

            if (m_results.Length > 0)
            {
                ClipboardContentBuilder builder = new ClipboardContentBuilder(m_options.resultsOptions);
                for (int i = 0; i < Rows.Count; i++)
                {
                    DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[i];
                    if (row.selected)
                    {
                        builder.Add(m_results[i]);
                    }
                }
                dataObject.SetText(builder.ToString());
            }
            return(dataObject);
        }
Пример #9
0
        private void UpdateRows()
        {
            if (m_results.Length == 0)
            {
                Rows.Clear();
                RowCount = 1;
                SetCurrentRow(0);
            }
            else
            {
                if (m_results.Length < RowCount - 1000)//rows are removed very slowly!!!
                {
                    Rows.Clear();
                }
                RowCount = m_results.Length;

                bool[] selection = m_core.GetSelection(0, (uint)m_results.Length);

                for (int i = 0; i < Rows.Count; i++)
                {
                    DataGridViewCustomRow row = (DataGridViewCustomRow)Rows[i];
                    row.updated = false;
                    if (selection != null)
                    {
                        row.selected = selection[i];
                    }
                }
                int current = m_core.GetCurrent();
                if (current != -1)
                {
                    SetCurrentRow(current);
                }
                else
                {
                    SetCurrentRow(0);
                    SetRowSelection(0, 1, true);
                }
            }
        }