26 |
26 |
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm
|
27 |
27 |
{
|
28 |
28 |
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>();
|
29 |
|
public List< SPPID_Document> Documents { get { return _DicDocuments.Select(x => x.Value).ToList(); } }
|
|
29 |
private List<SPPID_Document> _Documents = new List<SPPID_Document>();
|
|
30 |
public List<SPPID_Document> Documents { get { return _Documents; } }
|
30 |
31 |
private DataTable _ConverterDT = new DataTable();
|
31 |
32 |
private DataTable _SPPIDSymbolPathDT = new DataTable();
|
32 |
33 |
private DataTable _SPPIDUnitDT = new DataTable();
|
... | ... | |
396 |
397 |
{
|
397 |
398 |
SPPID_Document document = new SPPID_Document(fileName);
|
398 |
399 |
document.SymbolMappings = symbolMappings;
|
|
400 |
document.LineMappings = lineMappings;
|
|
401 |
document.LineNumberMappings = lineNumberMappings;
|
|
402 |
document.AssociationMappings = associationMappings;
|
|
403 |
|
399 |
404 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
|
400 |
405 |
DataRow row;
|
401 |
406 |
if (rows.Length == 0)
|
... | ... | |
422 |
427 |
|
423 |
428 |
private void btnRun_Click(object sender, EventArgs e)
|
424 |
429 |
{
|
|
430 |
_Documents.Clear();
|
|
431 |
|
|
432 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
|
433 |
{
|
|
434 |
string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
|
|
435 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
|
436 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
|
437 |
string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
|
|
438 |
string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
|
|
439 |
SPPID_Document document = _DicDocuments[_FilePath];
|
|
440 |
document.Unit = _Unit;
|
|
441 |
document.Template = _Template;
|
|
442 |
document.DrawingNumber = _DrawingNumber;
|
|
443 |
document.DrawingName = _DrawingName;
|
|
444 |
_Documents.Add(document);
|
|
445 |
}
|
|
446 |
|
425 |
447 |
DialogResult = DialogResult.OK;
|
426 |
448 |
}
|
427 |
449 |
|
... | ... | |
445 |
467 |
form.ShowDialog();
|
446 |
468 |
InitMapping();
|
447 |
469 |
}
|
|
470 |
private List<int> prevSelectedList = new List<int>();
|
|
471 |
|
|
472 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
|
473 |
{
|
|
474 |
if (e.Action == CollectionChangeAction.Add)
|
|
475 |
{
|
|
476 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
|
|
477 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
|
|
478 |
|
|
479 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
|
480 |
gridViewConverter.UnselectRow(e.ControllerRow);
|
|
481 |
}
|
|
482 |
else if (e.Action == CollectionChangeAction.Refresh)
|
|
483 |
{
|
|
484 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows())
|
|
485 |
{
|
|
486 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
|
|
487 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
|
|
488 |
|
|
489 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
|
|
490 |
gridViewConverter.UnselectRow(rowHandle);
|
|
491 |
}
|
|
492 |
|
|
493 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
|
|
494 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
|
|
495 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
|
448 |
496 |
|
|
497 |
if (!firstNotSecond.Any() && !secondNotFirst.Any())
|
|
498 |
{
|
|
499 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
|
500 |
gridViewConverter.ClearSelection();
|
|
501 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
|
|
502 |
}
|
|
503 |
}
|
|
504 |
|
|
505 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
|
|
506 |
}
|
449 |
507 |
}
|
450 |
508 |
}
|