static public void Parse(string comment, string culture, PresetTag preset) { Ctxt ctxt = new Ctxt { preset = preset, culture = culture }; CommentParser.Parse(comment, ctxt.Handler); }
public void HandleTag(object source, TagParser.HandleTagEventArgs ev) { PresetTag preset = new PresetTag() { tagPath = ev.Path }; foreach (string c in ev.Comment.Cultures) { PresetCommentParser.Parse(ev.Comment[c], c, preset); } if (preset.labels != null) { presetList.AddTag(preset); } }
static public void Save(string file, Dictionary <string, PresetGroup> preset_groups, string culture) { var wb = new XLWorkbook(); foreach (var preset_group in preset_groups) { int npresets = preset_group.Value.presets[0].values.Count(); var ws = wb.Worksheets.Add("Group " + preset_group.Key); string[] headers = new string[N_PROPERTIES] { "Decription", "Order", "Tag", "Type", "Unit", "Min", "Max", "Precision" }; int row_index = 1; var rangePresetTitle = ws.Range(row_index, N_PROPERTIES + 1, row_index, N_PROPERTIES + npresets); rangePresetTitle.FirstCell().Value = "Presets"; rangePresetTitle.Merge(); rangePresetTitle.Style.Font.Bold = true; row_index++; var rangePresetIndexHeader = ws.Range(row_index, 1, row_index, N_PROPERTIES); rangePresetIndexHeader.FirstCell().Value = "Preset index"; rangePresetIndexHeader.Merge(); rangePresetIndexHeader.Style.Font.Bold = true; rangePresetIndexHeader.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; for (int i = 1; i <= npresets; i++) { var cell = ws.Cell(row_index, i + N_PROPERTIES); cell.Value = i; } row_index++; var rangePresetNameHeader = ws.Range(row_index, 1, row_index, N_PROPERTIES); rangePresetNameHeader.FirstCell().Value = "Preset name"; rangePresetNameHeader.Merge(); rangePresetNameHeader.Style.Font.Bold = true; rangePresetNameHeader.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; var rangePresetName = ws.Cell(row_index, N_PROPERTIES + 1).InsertData(preset_group.Value.preset_names, true); row_index++; var rangePresetColorHeader = ws.Range(row_index, 1, row_index, N_PROPERTIES); rangePresetColorHeader.FirstCell().Value = "Color index"; rangePresetColorHeader.Merge(); rangePresetColorHeader.Style.Font.Bold = true; rangePresetColorHeader.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; var rangePresetColors = ws.Cell(row_index, N_PROPERTIES + 1).InsertData(preset_group.Value.preset_colors, true); row_index++; var rangeHeader = ws.Cell(row_index, 1).InsertData(headers, true); rangeHeader.Style.Font.Bold = true; row_index++; foreach (PresetInfo info in preset_group.Value.presets) { int col_index = 1; PresetTag tag = info.tag; // Label ws.Cell(row_index, col_index).Value = ResolveLabelTags(tag.labels[culture].ToString()); col_index++; // Order ws.Cell(row_index, col_index).Value = tag.order; col_index++; // PLC tag ws.Cell(row_index, col_index).Value = tag.tagPath.ToString(); col_index++; // Value type ws.Cell(row_index, col_index).Value = PathType(tag.tagPath); col_index++; // Value unit ws.Cell(row_index, col_index).Value = tag.unit; col_index++; // Minimum value ws.Cell(row_index, col_index).Value = tag.min; col_index++; // Maximum value ws.Cell(row_index, col_index).Value = tag.max; col_index++; // Decimal precision ws.Cell(row_index, col_index).Value = tag.precision; col_index++; for (int i = 0; i < info.values.Count(); i++) { var cell = ws.Cell(row_index, col_index); cell.Value = info.values[i]; if (info.enabled[i] == true) { cell.Style.Fill.PatternType = XLFillPatternValues.Solid; cell.Style.Fill.BackgroundColor = XLColor.LightGreen; } col_index++; } row_index++; } wb.SaveAs(file); } }