コード例 #1
0
        private void ParseItem()
        {
            var itemFileName = Uri.IsWellFormedUriString(_value, UriKind.Absolute) ? _value : $"{_dirName}\\{_value}";

            if (!int.TryParse(GetValue(StreamReader.ReadLine()), out int itemQuant))
            {
                throw new Exception($"{_dirName}\\{FileName}:{_currentLine}: invalid parameter ITEMQUANT");
            }
            if (!int.TryParse(GetValue(StreamReader.ReadLine()), out int rotate))
            {
                throw new Exception($"{_dirName}\\{FileName}:{_currentLine}: invalid parameter ROTATE");
            }
            var rotStep = GetValue(StreamReader.ReadLine());

            if (!int.TryParse(GetValue(StreamReader.ReadLine()), out int reflect))
            {
                throw new Exception($"{_dirName}\\{FileName}:{_currentLine}: invalid parameter REFLECT");
            }

            int id = GetItemId();

            var itemReader  = new NFItemReader(FormatPathForItems(itemFileName));
            var partProfile = itemReader.Read();

            var part = new PartDefinition
            {
                ID = id,
                OriginalPartProfile = partProfile,
                Count           = itemQuant,
                DisableTurn     = rotate == 0,
                OverturnAllowed = reflect == 1
            };

            part.Name = part.OriginalPartProfile.ItemName;
            switch (rotStep)
            {
            case "PI":
                part.AngleStep = 180;
                break;

            case "PI/2":
                part.AngleStep = 90;
                break;

            case "NO":
                part.AngleStep = 360;
                break;
            }
            _task.Parts.Add(part);
        }
コード例 #2
0
        private void ParseSheet()
        {
            var itemReader = new NFItemReader(FormatPathForItems(_value), true);
            var sheet      = new ContourSheet
            {
                ID           = _task.GetNewSheetId(),
                SheetProfile = itemReader.Read()
            };

            sheet.Name = sheet.SheetProfile.ItemName;
            if (!int.TryParse(GetValue(StreamReader.ReadLine()), out int sheetCount))
            {
                throw new Exception($"{_dirName}\\{FileName}:{_currentLine}: expected parameter SHEETCOUNT");
            }
            _currentLine++;
            sheet.Count = sheetCount;
            _task.Sheets.Add(sheet);
        }