| | |
| | | btnInsertMeasurement.Enabled = false; |
| | | btnInsertMeasurement.Text = "生成中。。。"; |
| | | |
| | | string measureType = cboMeasureType.Text; |
| | | MeasureType measureType = cboMeasureType.SelectedItem as MeasureType; |
| | | string startKey = cboStartKey.Text; |
| | | string endKey = cboEndKey.Text; |
| | | |
| | |
| | | btnInsertMeasurement.Text = "生成检测项"; |
| | | } |
| | | |
| | | private async Task<string> PatchInsertMeasurement(string measureType, string startKey, string endKey) |
| | | private async Task<string> PatchInsertMeasurement(MeasureType measureType, string startKey, string endKey) |
| | | { |
| | | return await Task.Run(() => |
| | | { |
| | |
| | | int endIndex = Config.KeyNameCollection.IndexOf(endKey); |
| | | |
| | | KeyLocation startRect = Config.KeyLocationCollection.FirstOrDefault(u => u.Key == startKey); |
| | | //KeyLocation endRect = Config.KeyLocationCollection.FirstOrDefault(u => u.Key == endKey); |
| | | if (startRect == null) |
| | | { |
| | | return $"未配置{(startRect == null ? startKey : "")}的显示位置"; |
| | |
| | | return "起始键不能小于结束键"; |
| | | } |
| | | |
| | | switch (measureType) |
| | | RectangleF curKeyRect = new RectangleF((float)startRect.KeyPosition.X, (float)startRect.KeyPosition.Y, startRect.KeySize.Width, startRect.KeySize.Height); |
| | | KeyLocation curKey = null; |
| | | |
| | | switch (measureType.Code) |
| | | { |
| | | case "Slant": |
| | | { |
| | | for (int i = startIndex; i <= endIndex; i++) |
| | | { |
| | | int curKeyEdge_X = (i - startIndex + 1) * (startRect.KeyRect.Width + startRect.IntervalRect.Width) + startRect.KeyRect.X - startRect.IntervalRect.Width; |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.Key == Config.KeyNameCollection[i]); |
| | | if (curKey == null) |
| | | { |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.IsDefault); |
| | | } |
| | | |
| | | int lableX = (curKeyEdge_X + curKeyEdge_X - startRect.KeyRect.Width - 25) / 2; |
| | | int lable_Up_Y = startRect.KeyRect.Y + (startRect.KeyRect.Height - 25) / 2; |
| | | int lableX = (int)((curKeyRect.X + curKeyRect.X + curKey.KeySize.Width - measureType.DisplayRect.Width) / 2.0); |
| | | int lable_Up_Y = (int)(startRect.KeyPosition.Y + (startRect.KeySize.Height - measureType.DisplayRect.Height) / 2.0); |
| | | |
| | | MeasurementUnit mUnitUp = new MeasurementUnit(); |
| | | mUnitUp.MeasureType = measureType; |
| | | mUnitUp.MeasureType = measureType.Code; |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "All" }); |
| | | mUnitUp.DisplayLocation = new Rectangle(lableX, lable_Up_Y, 25, 25); |
| | | mUnitUp.DisplayLocation = new Rectangle(lableX, lable_Up_Y, measureType.DisplayRect.Width, measureType.DisplayRect.Height); |
| | | Config.MeasurementUnitCollection.Add(mUnitUp); |
| | | |
| | | curKeyRect.Offset(curKey.KeySize.Width + curKey.IntervalSize.Width, 0); |
| | | } |
| | | } |
| | | break; |
| | |
| | | { |
| | | for (int i = startIndex; i < endIndex; i++) |
| | | { |
| | | int curKeyEdge_X = (i - startIndex + 1) * (startRect.KeyRect.Width + startRect.IntervalRect.Width) + startRect.KeyRect.X - startRect.IntervalRect.Width; |
| | | int nextKeyStart_X = curKeyEdge_X + startRect.IntervalRect.Width; |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.Key == Config.KeyNameCollection[i]); |
| | | if (curKey == null) |
| | | { |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.IsDefault); |
| | | } |
| | | |
| | | int lableX = (curKeyEdge_X + nextKeyStart_X - 25) / 2; |
| | | int lable_Up_Y = startRect.KeyRect.Y + 4; |
| | | int lable_Down_y = startRect.KeyRect.Y + startRect.KeyRect.Height - 4 - 12; |
| | | int lableX = (int)((curKeyRect.X + curKey.KeySize.Width + curKeyRect.X + curKey.KeySize.Width + curKey.IntervalSize.Width - measureType.DisplayRect.Width) / 2.0); |
| | | int lable_Up_Y = (int)startRect.KeyPosition.Y + 4; |
| | | int lable_Down_y = (int)(startRect.KeyPosition.Y + startRect.KeySize.Height - 4 - measureType.DisplayRect.Height); |
| | | |
| | | MeasurementUnit mUnitUp = new MeasurementUnit(); |
| | | mUnitUp.MeasureType = measureType; |
| | | mUnitUp.MeasureType = measureType.Code; |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "Z2" }); |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i + 1], KeyResultId = "Z1" }); |
| | | mUnitUp.DisplayLocation = new Rectangle(lableX, lable_Up_Y, 25, 12); |
| | | mUnitUp.DisplayLocation = new Rectangle(lableX, lable_Up_Y, measureType.DisplayRect.Width, measureType.DisplayRect.Height); |
| | | Config.MeasurementUnitCollection.Add(mUnitUp); |
| | | |
| | | MeasurementUnit mUnitDown = new MeasurementUnit(); |
| | | mUnitDown.MeasureType = measureType; |
| | | mUnitDown.MeasureType = measureType.Code; |
| | | mUnitDown.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "Z4" }); |
| | | mUnitDown.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i + 1], KeyResultId = "Z3" }); |
| | | mUnitDown.DisplayLocation = new Rectangle(lableX, lable_Down_y, 25, 12); |
| | | mUnitDown.DisplayLocation = new Rectangle(lableX, lable_Down_y, measureType.DisplayRect.Width, measureType.DisplayRect.Height); |
| | | Config.MeasurementUnitCollection.Add(mUnitDown); |
| | | |
| | | curKeyRect.Offset(curKey.KeySize.Width + curKey.IntervalSize.Width, 0); |
| | | } |
| | | } |
| | | break; |
| | | case "RowAlignment": |
| | | { |
| | | int start_X = startRect.KeyRect.X + startRect.KeyRect.Width / 3; |
| | | int end_X = (startRect.KeyRect.Width + startRect.IntervalRect.Width) * (endIndex - startIndex) + startRect.KeyRect.X + startRect.KeyRect.Width * 2 / 3; |
| | | int start_X = (int)(startRect.KeyPosition.X + startRect.KeySize.Width / 3.0); |
| | | int end_X = (int)((startRect.KeySize.Width + startRect.IntervalSize.Width) * (endIndex - startIndex) + startRect.KeyPosition.X + startRect.KeySize.Width * 2.0 / 3.0); |
| | | |
| | | int lable_Up_Y = startRect.KeyRect.Y - 6; |
| | | int lable_Down_Y = startRect.KeyRect.Y + startRect.KeyRect.Height - 6; |
| | | int lable_Up_Y = (int)startRect.KeyPosition.Y - 6; |
| | | int lable_Down_Y = (int)(startRect.KeyPosition.Y + startRect.KeySize.Height - 6); |
| | | |
| | | MeasurementUnit mUnitUp = new MeasurementUnit(); |
| | | mUnitUp.MeasureType = measureType; |
| | | mUnitUp.MeasureType = measureType.Code; |
| | | for (int i = startIndex; i < endIndex; i++) |
| | | { |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "Z2" }); |
| | |
| | | Config.MeasurementUnitCollection.Add(mUnitUp); |
| | | |
| | | MeasurementUnit mUnitDown = new MeasurementUnit(); |
| | | mUnitDown.MeasureType = measureType; |
| | | mUnitDown.MeasureType = measureType.Code; |
| | | for (int i = startIndex; i < endIndex; i++) |
| | | { |
| | | mUnitDown.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "Z4" }); |
| | |
| | | Config.MeasurementUnitCollection.Add(mUnitDown); |
| | | } |
| | | break; |
| | | case "Blind": |
| | | case "Blind1": |
| | | { |
| | | for (int i = startIndex; i <= endIndex; i++) |
| | | { |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.Key == Config.KeyNameCollection[i]); |
| | | if (curKey == null) |
| | | { |
| | | curKey = Config.KeyLocationCollection.FirstOrDefault(u => u.IsDefault); |
| | | } |
| | | int lableX = (int)((curKeyRect.X + curKeyRect.X + curKey.KeySize.Width - measureType.DisplayRect.Width) / 2.0); |
| | | //int lable_Up_Y = (int)(startRect.KeyPosition.Y + (startRect.KeySize.Height - measureType.DisplayRect.Height) / 2.0); |
| | | int lable_Up_Y = (int)(startRect.KeyPosition.Y + startRect.KeySize.Height - (measureType.DisplayRect.Height )); |
| | | |
| | | MeasurementUnit mUnitUp = new MeasurementUnit(); |
| | | mUnitUp.MeasureType = measureType.Code; |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "B1" }); |
| | | mUnitUp.KeyUnitCollection.Add(new KeyUnitBind() { Key = Config.KeyNameCollection[i], KeyResultId = "B2" }); |
| | | mUnitUp.DisplayLocation = new Rectangle(lableX, lable_Up_Y, measureType.DisplayRect.Width, measureType.DisplayRect.Height); |
| | | Config.MeasurementUnitCollection.Add(mUnitUp); |
| | | |
| | | curKeyRect.Offset(curKey.KeySize.Width + curKey.IntervalSize.Width, 0); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | return "已批量生成检测项,请到配置界面查看和保存"; |