/// <summary> /// Reads opacity and color function from the open xml. /// </summary> /// <returns>Information about the preset, which includes series of color and opacity function.</returns> private PresetInformation ReadOpacityAndColorFunction() { PresetInformation presetInformation = new PresetInformation(); if (_reader.ReadToFollowing("ColoredFunctions")) { while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("PointList")) { Dictionary <float, float> opacityFunction = new Dictionary <float, float>(); Dictionary <float, Color[]> colorFunction = new Dictionary <float, Color[]>(); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("First")) { Color[] colorArray = new Color[2]; float first = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); _reader.ReadToFollowing("LeftColor"); colorArray[0] = ReadColor(); _reader.ReadToFollowing("RightColor"); colorArray[1] = ReadColor(); _reader.ReadToFollowing("Opacity"); float opacity = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); opacityFunction.Add(first, opacity); colorFunction.Add(first, colorArray); } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("PointList")) { presetInformation.AddSerie(opacityFunction, colorFunction); break; } } } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("ColoredFunctions")) { break; } } } return(presetInformation); }
/// <summary> /// Reads opacity function from the open xml /// </summary> /// <param name="colorFunction">Color function which will be appply to loaded opacity function</param> /// <param name="fileName">Name of open xml</param> /// <returns>Information about the preset, which includes series of color and opacity function</returns> private PresetInformation ReadOpacityFunction(String fileName, Dictionary <float, Color[]> colorFunction) { PresetInformation presetInformation = new PresetInformation(); _reader = new XmlTextReader(Path.Combine(Directory.GetCurrentDirectory(), @"presety\", fileName)); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("PointList")) { Console.WriteLine("<PointList>");; Dictionary <float, float> opacityFunction = new Dictionary <float, float>(); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("First")) { float first = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); _reader.ReadToFollowing("Second"); float second = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); opacityFunction.Add(first, second); } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("PointList")) { Console.WriteLine("</PointList>"); presetInformation.AddSerie(opacityFunction, colorFunction); break; } } } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("OpacityFunctions")) { break; } } return(presetInformation); }
/// <summary> /// Reads opacity function from the open xml /// </summary> /// <param name="colorFunction">Color function which will be appply to loaded opacity function</param> /// <param name="fileName">Name of open xml</param> /// <returns>Information about the preset, which includes series of color and opacity function</returns> private PresetInformation ReadOpacityFunction(String fileName, Dictionary<float, Color[]> colorFunction) { PresetInformation presetInformation = new PresetInformation(); _reader = new XmlTextReader(Path.Combine(Directory.GetCurrentDirectory(), @"presety\", fileName)); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("PointList")) { Console.WriteLine("<PointList>"); ; Dictionary<float, float> opacityFunction = new Dictionary<float, float>(); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("First")) { float first = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); _reader.ReadToFollowing("Second"); float second = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); opacityFunction.Add(first, second); } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("PointList")) { Console.WriteLine("</PointList>"); presetInformation.AddSerie(opacityFunction,colorFunction); break; } } } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("OpacityFunctions")) { break; } } return presetInformation; }
/// <summary> /// Reads opacity and color function from the open xml. /// </summary> /// <returns>Information about the preset, which includes series of color and opacity function.</returns> private PresetInformation ReadOpacityAndColorFunction() { PresetInformation presetInformation = new PresetInformation(); if (_reader.ReadToFollowing("ColoredFunctions")) while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("PointList")) { Dictionary<float, float> opacityFunction = new Dictionary<float, float>(); Dictionary<float, Color[]> colorFunction = new Dictionary<float, Color[]>(); while (_reader.Read()) { if ((_reader.NodeType == XmlNodeType.Element) && _reader.Name.Equals("First")) { Color[] colorArray = new Color[2]; float first = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); _reader.ReadToFollowing("LeftColor"); colorArray[0] = ReadColor(); _reader.ReadToFollowing("RightColor"); colorArray[1] = ReadColor(); _reader.ReadToFollowing("Opacity"); float opacity = float.Parse(_reader.ReadElementContentAsString().Replace('.', ',')); opacityFunction.Add(first, opacity); colorFunction.Add(first, colorArray); } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("PointList")) { presetInformation.AddSerie(opacityFunction, colorFunction); break; } } } if ((_reader.NodeType == XmlNodeType.EndElement) && _reader.Name.Equals("ColoredFunctions")) { break; } } return presetInformation; }
//wizualizacja 3d ----------------------------------------------------------------- private void fourthWindow_Load(object sender, EventArgs e) { string[] filePaths = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(),PresetDir), "*.xml"); PresetInfo = PresetReader.ReadXmlFile(new FileInfo(filePaths[0]).Name); foreach (string dir in filePaths) { comboBox1.Items.Add(new FileInfo(dir).Name); } comboBox1.SelectedIndex = 1; comboBoxSeries.Items.Clear(); int numberOfSeries = PresetInfo.Series.Count; for (int i = 0; i < numberOfSeries; i++) { comboBoxSeries.Items.Add(i.ToString(CultureInfo.InvariantCulture)); } comboBoxSeries.SelectedIndex = 0; createVisialization3D(); updateChart(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxSeries != null && PresetInfo != null) { PresetInfo = PresetReader.ReadXmlFile(comboBox1.Text); if (_vizualization3D != null) _vizualization3D.ChangeColorAndOpacityFunction(PresetInfo); comboBoxSeries.Items.Clear(); int numberOfSeries = PresetInfo.Series.Count; for (var i = 0; i < numberOfSeries; i++) { comboBoxSeries.Items.Add(i.ToString(CultureInfo.InvariantCulture)); } comboBoxSeries.SelectedIndex = 0; updateChart(); colorStrip.Invalidate(); } }