public static Group MakeGroupWirhAttributes(string chartName, List <string> channelNames) { var newGroup = new Group(LastGroupID++, chartName); foreach (var name in channelNames) { newGroup.AddAttribute(name, ColorManager.GetChartColor, 1); } return(newGroup); }
public void BuildCharts() { ChartsGrid.Children.Clear(); ChartsGrid.RowDefinitions.Clear(); int rowIndex = 0; foreach (var channelName in ChannelNames) { if (selectedChannels.Contains(channelName.Item1)) { var group = new Group(GroupManager.LastGroupID++, channelName.Item1); foreach (var inputFile in channelName.Item2) { group.AddAttribute(InputFileManager.GetDriverlessInputFile(inputFile.Item1).GetChannel(channelName.Item1)); } BuildChartGrid(group, ref rowIndex); } } foreach (var group in GroupManager.Groups) { if (selectedGroups.Contains(group.Name)) { BuildChartGrid(group, ref rowIndex); } } RowDefinition chartRow = new RowDefinition() { Height = new GridLength() }; ChartsGrid.RowDefinitions.Add(chartRow); Grid.SetRow(new Grid(), rowIndex++); UpdateCharts(); }
/// <summary> /// Reads groups from file. /// </summary> /// <param name="fileName">File name from read groups.</param> private static void ReadGroups(string fileName) { using var reader = new StreamReader(fileName); try { dynamic groupsJSON = JsonConvert.DeserializeObject(reader.ReadToEnd()); for (int i = 0; i < groupsJSON.Count; i++) { if (groupsJSON[i].Name == null) { throw new Exception("Can't add group, because 'name' is null!"); } if (groupsJSON[i].Name.ToString().Equals(string.Empty)) { throw new Exception("Can't add group, because 'name' is empty!"); } if (groupsJSON[i].Attributes == null) { throw new Exception("Can't add group, because 'attributes' are null!"); } else { var group = new Group(LastGroupID++, groupsJSON[i].Name.ToString()); for (int j = 0; j < groupsJSON[i].Attributes.Count; j++) { string attributeName = ""; string attributeColor = ""; int attributeLineWidth = 0; if (groupsJSON[i].Attributes[j].Name == null) { throw new Exception("Can't add attribute, because 'name' is null!"); } if (groupsJSON[i].Attributes[j].Color == null) { throw new Exception("Can't add attribute, because 'color' is null!"); } if (groupsJSON[i].Attributes[j].LineWidth == null) { throw new Exception("Can't add attribute, because 'line width' is null!"); } attributeName = groupsJSON[i].Attributes[j].Name.ToString(); attributeColor = groupsJSON[i].Attributes[j].Color.ToString(); attributeLineWidth = int.Parse(groupsJSON[i].Attributes[j].LineWidth.ToString()); if (!attributeName.Equals(string.Empty) && !attributeColor.Equals(string.Empty)) { group.AddAttribute(attributeName, attributeColor, attributeLineWidth); } else { throw new Exception("Can't add attribute, because 'name' or/and 'color' are empty!"); } } AddGroup(group); } } var temporaryGroup = GetGroup($"Temporary{TemporaryGroupIndex}"); while (temporaryGroup != null) { TemporaryGroupIndex++; temporaryGroup = GetGroup($"Temporary{TemporaryGroupIndex}"); } } catch (JsonReaderException) { throw new Exception($"There was a problem reading '{TextManager.GroupsFileName}'"); } }