582 lines
26 KiB
C#
582 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
|
|
namespace DatabaseExport
|
|
{
|
|
public class Region
|
|
{
|
|
private TestObjectTemplate _template;
|
|
public TestObjectTemplate Template
|
|
{
|
|
get => _template;
|
|
set
|
|
{
|
|
_template = value;
|
|
DetermineAvailableISOSettings();
|
|
}
|
|
}
|
|
private void InvalidateVisual()
|
|
{
|
|
_adorner?.InvalidateVisual();
|
|
}
|
|
private string _name;
|
|
public string RegionName
|
|
{
|
|
get => _name;
|
|
set { _name = value; InvalidateVisual(); }
|
|
}
|
|
|
|
private string _regionDescription;
|
|
public string RegionDescription
|
|
{
|
|
get => _regionDescription;
|
|
set { _regionDescription = value; InvalidateVisual(); }
|
|
}
|
|
|
|
public Point RegionUpperLeft { get; set; }
|
|
|
|
public Point RegionBottomRight { get; set; }
|
|
|
|
private MMEDirections _direction;
|
|
public MMEDirections RegionDirection
|
|
{
|
|
get => _direction;
|
|
set
|
|
{
|
|
_direction = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
private MMEFilterClasses _filterClass;
|
|
public MMEFilterClasses RegionFilterClass
|
|
{
|
|
get => _filterClass;
|
|
set
|
|
{
|
|
_filterClass = value;
|
|
if (null != value)
|
|
{
|
|
_filterClassIndex = _filterClasses.IndexOf(value);
|
|
}
|
|
else
|
|
{
|
|
_filterClassIndex = -1;
|
|
}
|
|
SetISOCode();
|
|
}
|
|
}
|
|
private MMEFineLocations1 _fineLocation1;
|
|
public MMEFineLocations1 RegionFineLocation1
|
|
{
|
|
get => _fineLocation1;
|
|
set
|
|
{
|
|
_fineLocation1 = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
private MMEFineLocations2 _fineLocation2;
|
|
public MMEFineLocations2 RegionFineLocation2
|
|
{
|
|
get => _fineLocation2;
|
|
set
|
|
{
|
|
_fineLocation2 = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
private MMEFineLocations3 _fineLocation3;
|
|
public MMEFineLocations3 RegionFineLocation3
|
|
{
|
|
get => _fineLocation3;
|
|
set
|
|
{
|
|
_fineLocation3 = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
private MMETransducerMainLocation _mainLocation;
|
|
public MMETransducerMainLocation RegionMainLocation
|
|
{
|
|
get => _mainLocation;
|
|
set
|
|
{
|
|
if (_mainLocation != value)
|
|
{
|
|
_mainLocation = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
}
|
|
private void FilterRegionChannels()
|
|
{
|
|
_regionChannels = new List<TestObjectTemplateChannel>(Template.TemplateAllChannels);
|
|
_regionUIChannels = new List<TemplateChannelUI>(Template.TemplateAllUIChannels);
|
|
for (var i = _regionChannels.Count - 1; i >= 0; i--)
|
|
{
|
|
var channel = _regionChannels[i];
|
|
var mmeChannel = channel.Channel;
|
|
|
|
if (RegionMainLocation != null && RegionMainLocation.Trans_Main_Loc != mmeChannel.Trans_Main_Loc)
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionDirection != null && RegionDirection.Direction != mmeChannel.Direction && RegionDirection.Direction != "?")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionFilterClass != null && RegionFilterClass.Filter_Class != mmeChannel.Default_Filter_Class && RegionFilterClass.Filter_Class != "?")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionFineLocation1 != null && RegionFineLocation1.Fine_Loc_1 != mmeChannel.Fine_Loc_1 && RegionFineLocation1.Fine_Loc_1 != "??")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionFineLocation2 != null && RegionFineLocation2.FINE_LOC_2 != mmeChannel.Fine_Loc_2 && RegionFineLocation2.FINE_LOC_2 != "??")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionFineLocation3 != null && RegionFineLocation3.FINE_LOC_3 != mmeChannel.Fine_Loc_3 && RegionFineLocation3.FINE_LOC_3 != "??")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionPhysicalDimension != null && RegionPhysicalDimension.Physical_Dimension != mmeChannel.Physical_Dimension && RegionPhysicalDimension.Physical_Dimension != "??")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (RegionPosition != null && RegionPosition.Position != mmeChannel.Position && RegionPosition.Position != "?")
|
|
{
|
|
_regionChannels.RemoveAt(i);
|
|
_regionUIChannels.RemoveAt(i);
|
|
continue;
|
|
}
|
|
}
|
|
RegionChannels = _regionChannels.ToArray();
|
|
RegionUIChannels = _regionUIChannels.ToArray();
|
|
SetISOCode();
|
|
}
|
|
private MMEPhysicalDimensions _physicalDimension;
|
|
public MMEPhysicalDimensions RegionPhysicalDimension
|
|
{
|
|
get => _physicalDimension;
|
|
set
|
|
{
|
|
_physicalDimension = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
private MMEPositions _position;
|
|
public MMEPositions RegionPosition
|
|
{
|
|
get => _position;
|
|
set
|
|
{
|
|
_position = value;
|
|
SetISOCode();
|
|
}
|
|
}
|
|
|
|
public MMETestObjects RegionTestObject { get; set; }
|
|
|
|
|
|
private readonly RegionAdorner _adorner;
|
|
public Region(RegionAdorner adorner, TestObjectTemplate template)
|
|
{
|
|
_adorner = adorner;
|
|
RegionName = "New region";
|
|
RegionDescription = "Describe region";
|
|
Template = template;
|
|
RegionTestObject = template.TestObject;
|
|
RegionChannels = template.TemplateAllChannels;
|
|
RegionUIChannels = template.TemplateAllUIChannels;
|
|
DetermineAvailableISOSettings();
|
|
}
|
|
|
|
public Region(TestObjectTemplate template, TemplateRegion r)
|
|
{
|
|
RegionName = r.RegionName;
|
|
RegionDescription = r.RegionDescription;
|
|
Template = template;
|
|
RegionChannels = template.TemplateAllChannels;
|
|
RegionUIChannels = template.TemplateAllUIChannels;
|
|
RegionTestObject = ISO13499FileDb.IsoDb.GetTestObjectByIso(r.TestObject);
|
|
RegionBottomRight = new Point(r.LowerRight.X, r.LowerRight.Y);
|
|
RegionUpperLeft = new Point(r.UpperLeft.X, r.UpperLeft.Y);
|
|
RegionDirection = ISO13499FileDb.IsoDb.GetDirectionByIso(r.Direction);
|
|
RegionFilterClass = ISO13499FileDb.IsoDb.GetFilterClassByIso(r.FilterClass);
|
|
RegionFineLocation1 = ISO13499FileDb.IsoDb.GetFineLocation1ByIso(r.FineLocation1);
|
|
RegionFineLocation2 = ISO13499FileDb.IsoDb.GetFineLocation2ByIso(r.FineLocation2);
|
|
RegionFineLocation3 = ISO13499FileDb.IsoDb.GetFineLocation3ByIso(r.FineLocation3);
|
|
RegionMainLocation = ISO13499FileDb.IsoDb.GetMainLocationByIso(r.MainLocation);
|
|
RegionPhysicalDimension = ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(r.PhysicalDimension);
|
|
RegionPosition = ISO13499FileDb.IsoDb.GetPosition(r.Position);
|
|
FilterRegionChannels();
|
|
SetISOCode();
|
|
}
|
|
|
|
public Visibility RegionAddVisibility { get; set; } = Visibility.Visible;
|
|
|
|
public Visibility RegionDeleteVisibility { get; set; } = Visibility.Hidden;
|
|
|
|
private List<MMEDirections> _allDirections = new List<MMEDirections>();
|
|
public MMEDirections[] AllDirections
|
|
{
|
|
get => _allDirections.ToArray();
|
|
set
|
|
{
|
|
_allDirections = new List<MMEDirections>(value);
|
|
var directions = new List<string>();
|
|
foreach (var dir in _allDirections)
|
|
{
|
|
if (null == dir) { directions.Add("?"); }
|
|
else { directions.Add(dir.Text_L1); }
|
|
}
|
|
AllDirectionsStrings = directions.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allDirectionsStrings = new List<string>();
|
|
public string[] AllDirectionsStrings
|
|
{
|
|
get => _allDirectionsStrings.ToArray();
|
|
set => _allDirectionsStrings = new List<String>(value);
|
|
}
|
|
|
|
private List<MMEFilterClasses> _filterClasses = new List<MMEFilterClasses>();
|
|
public MMEFilterClasses[] AllFilterClasses
|
|
{
|
|
get => _filterClasses.ToArray();
|
|
set
|
|
{
|
|
_filterClasses = new List<MMEFilterClasses>(value);
|
|
var filterclasses = new List<string>();
|
|
foreach (var fc in _filterClasses) { filterclasses.Add(fc.Text_L1); }
|
|
AllFilterClassStrings = filterclasses.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allFilterClassStrings = new List<string>();
|
|
public string[] AllFilterClassStrings
|
|
{
|
|
get => _allFilterClassStrings.ToArray();
|
|
set => _allFilterClassStrings = new List<string>(value);
|
|
}
|
|
public int _filterClassIndex = -1;
|
|
private List<MMEFineLocations1> _fineLocations1 = new List<MMEFineLocations1>();
|
|
public MMEFineLocations1[] AllFineLocations1
|
|
{
|
|
get => _fineLocations1.ToArray();
|
|
set
|
|
{
|
|
_fineLocations1 = new List<MMEFineLocations1>(value);
|
|
var fineLocations1 = new List<string>();
|
|
foreach (var loc in _fineLocations1)
|
|
{
|
|
fineLocations1.Add(null == loc ? "??" : loc.Text_L1);
|
|
}
|
|
AllFineLocations1Strings = fineLocations1.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allFineLocations1Strings = new List<string>();
|
|
public string[] AllFineLocations1Strings
|
|
{
|
|
get => _allFineLocations1Strings.ToArray();
|
|
set => _allFineLocations1Strings = new List<string>(value);
|
|
}
|
|
|
|
private List<MMEFineLocations2> _fineLocations2 = new List<MMEFineLocations2>();
|
|
public MMEFineLocations2[] AllFineLocations2
|
|
{
|
|
get => _fineLocations2.ToArray();
|
|
set
|
|
{
|
|
_fineLocations2 = new List<MMEFineLocations2>(value);
|
|
var locations = new List<string>();
|
|
foreach (var loc in _fineLocations2) { locations.Add(loc.Text_L1); }
|
|
AllFineLocations2Strings = locations.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allFineLocations2Strings = new List<string>();
|
|
public string[] AllFineLocations2Strings
|
|
{
|
|
get => _allFineLocations2Strings.ToArray();
|
|
set => _allFineLocations2Strings = new List<string>(value);
|
|
}
|
|
|
|
private List<MMEFineLocations3> _fineLocations3 = new List<MMEFineLocations3>();
|
|
public MMEFineLocations3[] AllFineLocations3
|
|
{
|
|
get => _fineLocations3.ToArray();
|
|
set
|
|
{
|
|
_fineLocations3 = new List<MMEFineLocations3>(value);
|
|
var locations = new List<string>();
|
|
foreach (var l in _fineLocations3) { locations.Add(l.Text_L1); }
|
|
AllFineLocations3Strings = locations.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allFineLocations3Strings = new List<string>();
|
|
public string[] AllFineLocations3Strings
|
|
{
|
|
get => _allFineLocations3Strings.ToArray();
|
|
set => _allFineLocations3Strings = new List<String>(value);
|
|
}
|
|
|
|
private List<MMETransducerMainLocation> _mainLocations = new List<MMETransducerMainLocation>();
|
|
public MMETransducerMainLocation[] AllMainLocations
|
|
{
|
|
get => _mainLocations.ToArray();
|
|
set
|
|
{
|
|
_mainLocations = new List<MMETransducerMainLocation>(value);
|
|
var locations = new List<string>();
|
|
foreach (var loc in _mainLocations)
|
|
{
|
|
if (null == loc)
|
|
{
|
|
locations.Add("????");
|
|
}
|
|
else { locations.Add(loc.Text_L1); }
|
|
}
|
|
AllMainLocationsStrings = locations.ToArray();
|
|
}
|
|
}
|
|
private List<String> _allMainLocationsStrings = new List<string>();
|
|
public string[] AllMainLocationsStrings
|
|
{
|
|
get => _allMainLocationsStrings.ToArray();
|
|
set => _allMainLocationsStrings = new List<string>(value);
|
|
}
|
|
|
|
private List<MMEPhysicalDimensions> _physicalDimensions = new List<MMEPhysicalDimensions>();
|
|
public MMEPhysicalDimensions[] AllPhysicalDimensions
|
|
{
|
|
get => _physicalDimensions.ToArray();
|
|
set
|
|
{
|
|
_physicalDimensions = new List<MMEPhysicalDimensions>(value);
|
|
var dimensions = new List<string>();
|
|
foreach (var dim in _physicalDimensions)
|
|
{
|
|
if (null == dim) { dimensions.Add("??"); }
|
|
else { dimensions.Add(dim.Text_L1); }
|
|
}
|
|
AllPhysicalDimensionStrings = dimensions.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allPhysicalDimensionStrings = new List<string>();
|
|
public string[] AllPhysicalDimensionStrings
|
|
{
|
|
get => _allPhysicalDimensionStrings.ToArray();
|
|
set => _allPhysicalDimensionStrings = new List<String>(value);
|
|
}
|
|
|
|
private List<MMEPositions> _positions = new List<MMEPositions>();
|
|
public MMEPositions[] AllPositions
|
|
{
|
|
get => _positions.ToArray();
|
|
set
|
|
{
|
|
_positions = new List<MMEPositions>(value);
|
|
var positions = new List<string>();
|
|
foreach (var pos in _positions) { positions.Add(pos.Text_L1); }
|
|
AllPositionStrings = positions.ToArray();
|
|
}
|
|
}
|
|
private List<string> _allPositionsStrings = new List<string>();
|
|
public string[] AllPositionStrings
|
|
{
|
|
get => _allPositionsStrings.ToArray();
|
|
set => _allPositionsStrings = new List<string>(value);
|
|
}
|
|
|
|
public string ISOCode { get; set; } = "????????????????";
|
|
|
|
private void SetISOCode()
|
|
{
|
|
var testObject = "?";
|
|
if (null != RegionTestObject) { testObject = RegionTestObject.Test_Object; }
|
|
var position = "?";
|
|
if (null != RegionPosition) { position = RegionPosition.Position; }
|
|
var main = "????";
|
|
if (null != RegionMainLocation) { main = RegionMainLocation.Trans_Main_Loc; }
|
|
var floc1 = "??";
|
|
if (null != RegionFineLocation1) { floc1 = RegionFineLocation1.Fine_Loc_1; }
|
|
var floc2 = "??";
|
|
if (null != RegionFineLocation2) { floc2 = RegionFineLocation2.FINE_LOC_2; }
|
|
var floc3 = "??";
|
|
if (null != RegionFineLocation3) { floc3 = RegionFineLocation3.FINE_LOC_3; }
|
|
var physdim = "??";
|
|
if (null != RegionPhysicalDimension) { physdim = RegionPhysicalDimension.Physical_Dimension; }
|
|
var dir = "?";
|
|
if (null != RegionDirection) { dir = RegionDirection.Direction; }
|
|
var fc = "?";
|
|
if (null != RegionFilterClass) { fc = RegionFilterClass.Filter_Class; }
|
|
ISOCode = ISO.IsoCode.GetString(testObject, position, main, floc1, floc2, floc3, physdim, dir, fc);
|
|
}
|
|
private List<TestObjectTemplateChannel> _regionChannels = new List<TestObjectTemplateChannel>();
|
|
public TestObjectTemplateChannel[] RegionChannels
|
|
{
|
|
get => _regionChannels.ToArray();
|
|
set
|
|
{
|
|
_regionChannels = new List<TestObjectTemplateChannel>(value);
|
|
DetermineAvailableISOSettings();
|
|
}
|
|
}
|
|
private void DetermineAvailableISOSettings()
|
|
{
|
|
|
|
var regionChannels = RegionChannels;
|
|
var templateChannels = Template.TemplateAllChannels;
|
|
|
|
var testObjects = (from pc in regionChannels.AsParallel() select pc.Channel.Test_Object).Distinct().ToArray();
|
|
if (testObjects.Length < 1) { return; }
|
|
RegionTestObject = ISO13499FileDb.IsoDb.GetTestObjectByIso(testObjects[0]);
|
|
|
|
|
|
var dirs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
|
dirs.Sort();
|
|
var directions = new List<MMEDirections>();
|
|
foreach (var dir in dirs) { directions.Add(ISO13499FileDb.IsoDb.GetDirectionByIso(dir)); }
|
|
var d = ISO13499FileDb.IsoDb.GetDirectionByIso("?");
|
|
if (!directions.Contains(d)) { directions.Add(d); }
|
|
AllDirections = directions.ToArray();
|
|
dirs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
|
if (1 == dirs.Count) { RegionDirection = (ISO13499FileDb.IsoDb.GetDirectionByIso(dirs[0])); }
|
|
else if (0 == dirs.Count) { RegionDirection = null; }
|
|
|
|
var fcs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
|
fcs.Sort();
|
|
var filterclasses = new List<MMEFilterClasses>();
|
|
foreach (var fc in fcs) { filterclasses.Add(ISO13499FileDb.IsoDb.GetFilterClassByIso(fc)); }
|
|
var fc2 = ISO13499FileDb.IsoDb.GetFilterClassByIso("?");
|
|
if (!filterclasses.Contains(fc2)) { filterclasses.Add(fc2); }
|
|
AllFilterClasses = filterclasses.ToArray();
|
|
fcs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
|
if (1 == fcs.Count) { RegionFilterClass = (ISO13499FileDb.IsoDb.GetFilterClassByIso(fcs[0])); }
|
|
else if (0 == fcs.Count) { RegionFilterClass = null; }
|
|
|
|
var locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
|
locs.Sort();
|
|
var finelocations1 = new List<MMEFineLocations1>();
|
|
foreach (var loc in locs) { finelocations1.Add(ISO13499FileDb.IsoDb.GetFineLocation1ByIso(loc)); }
|
|
var f = ISO13499FileDb.IsoDb.GetFineLocation1ByIso("??");
|
|
if (!finelocations1.Contains(f)) { finelocations1.Add(f); }
|
|
AllFineLocations1 = finelocations1.ToArray();
|
|
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
|
if (1 == locs.Count) { RegionFineLocation1 = (ISO13499FileDb.IsoDb.GetFineLocation1ByIso(locs[0])); }
|
|
else if (0 == locs.Count) { RegionFineLocation1 = null; }
|
|
|
|
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
|
locs.Sort();
|
|
var finelocations2 = new List<MMEFineLocations2>();
|
|
foreach (var loc in locs) { finelocations2.Add(ISO13499FileDb.IsoDb.GetFineLocation2ByIso(loc)); }
|
|
AllFineLocations2 = finelocations2.ToArray();
|
|
var f2 = ISO13499FileDb.IsoDb.GetFineLocation2ByIso("??");
|
|
if (!finelocations2.Contains(f2)) { finelocations2.Add(f2); }
|
|
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
|
if (1 == locs.Count) { RegionFineLocation2 = (ISO13499FileDb.IsoDb.GetFineLocation2ByIso(locs[0])); }
|
|
else if (0 == locs.Count) { RegionFineLocation2 = null; }
|
|
|
|
|
|
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
|
locs.Sort();
|
|
var finelocations3 = new List<MMEFineLocations3>();
|
|
foreach (var loc in locs) { finelocations3.Add(ISO13499FileDb.IsoDb.GetFineLocation3ByIso(loc)); }
|
|
var f3 = ISO13499FileDb.IsoDb.GetFineLocation3ByIso("??");
|
|
if (!finelocations3.Contains(f3)) { finelocations3.Add(f3); }
|
|
AllFineLocations3 = finelocations3.ToArray();
|
|
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
|
if (1 == locs.Count) { RegionFineLocation3 = (ISO13499FileDb.IsoDb.GetFineLocation3ByIso(locs[0])); }
|
|
else if (0 == locs.Count) { RegionFineLocation3 = null; }
|
|
|
|
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
|
locs.Sort();
|
|
var mains = new List<MMETransducerMainLocation>();
|
|
foreach (var loc in locs) { mains.Add(ISO13499FileDb.IsoDb.GetMainLocationByIso(loc)); }
|
|
var m = ISO13499FileDb.IsoDb.GetMainLocationByIso("????");
|
|
if (!mains.Contains(m)) { mains.Add(m); }
|
|
AllMainLocations = mains.ToArray();
|
|
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
|
if (1 == locs.Count) { RegionMainLocation = (ISO13499FileDb.IsoDb.GetMainLocationByIso(locs[0])); }
|
|
else if (0 == locs.Count) { RegionMainLocation = null; }
|
|
|
|
var dims = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
|
dims.Sort();
|
|
var dimensions = new List<MMEPhysicalDimensions>();
|
|
foreach (var dim in dims) { dimensions.Add(ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(dim)); }
|
|
var pd = ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso("??");
|
|
if (!dimensions.Contains(pd)) { dimensions.Add(pd); }
|
|
AllPhysicalDimensions = dimensions.ToArray();
|
|
dims = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
|
if (1 == dims.Count) { RegionPhysicalDimension = (ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(dims[0])); }
|
|
else if (0 == dims.Count) { RegionPhysicalDimension = null; }
|
|
|
|
var poss = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
|
poss.Sort();
|
|
var positions = new List<MMEPositions>();
|
|
foreach (var pos in poss) { positions.Add(ISO13499FileDb.IsoDb.GetPositionByISO(pos)); }
|
|
AllPositions = positions.ToArray();
|
|
poss = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
|
if (1 == poss.Count) { RegionPosition = positions[0]; }
|
|
else if (0 == poss.Count) { RegionPosition = null; }
|
|
|
|
}
|
|
|
|
public TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)
|
|
{
|
|
var region = new TemplateRegion(template.TemplateName, zone.Name, template.IsLocalOnly);
|
|
region.Direction = null == RegionDirection ? "?" : RegionDirection.Direction;
|
|
region.FilterClass = null == RegionFilterClass ? "?" : RegionFilterClass.Filter_Class;
|
|
region.FineLocation1 = null == RegionFineLocation1 ? "??" : RegionFineLocation1.Fine_Loc_1;
|
|
region.FineLocation2 = null == RegionFineLocation2 ? "??" : RegionFineLocation2.FINE_LOC_2;
|
|
region.FineLocation3 = null == RegionFineLocation3 ? "??" : RegionFineLocation3.FINE_LOC_3;
|
|
region.LowerRight = new System.Drawing.Point(Convert.ToInt32(RegionBottomRight.X), Convert.ToInt32(RegionBottomRight.Y));
|
|
region.MainLocation = null == RegionMainLocation ? "????" : RegionMainLocation.Trans_Main_Loc;
|
|
region.PhysicalDimension = null == RegionPhysicalDimension ? "??" : RegionPhysicalDimension.Physical_Dimension;
|
|
region.Position = null == RegionPosition ? "?" : RegionPosition.Position;
|
|
region.RegionDescription = RegionDescription;
|
|
region.RegionName = RegionName;
|
|
region.RegionNumber = number;
|
|
region.TestObject = null == RegionTestObject ? "?" : RegionTestObject.Test_Object;
|
|
region.UpperLeft = new System.Drawing.Point(Convert.ToInt32(RegionUpperLeft.X), Convert.ToInt32(RegionUpperLeft.Y));
|
|
return region;
|
|
}
|
|
|
|
private List<TemplateChannelUI> _regionUIChannels = new List<TemplateChannelUI>();
|
|
public TemplateChannelUI[] RegionUIChannels
|
|
{
|
|
get => _regionUIChannels.ToArray();
|
|
set => _regionUIChannels = new List<TemplateChannelUI>(value);
|
|
}
|
|
}
|
|
}
|