/// <summary> /// Update the <see cref="chart_filters"/> to reflect the gains of the filters. /// </summary> /// <seealso cref="UpdateAll"/> private void UpdateEqualizerGraph() { // // update the series // // get the list of filters SortedList <double, Filter> filters = eqAPI.GetFilters(); // update the equalizer series chart_filters.Series.Clear(); System.Windows.Forms.DataVisualization.Charting.Series series = chart_filters.Series.Add("frequencies"); foreach (System.Collections.Generic.KeyValuePair <double, Filter> pair in filters) { Filter filter = pair.Value; series.Points.Add(filter.Gain); } // // change the equalizer graph visually // // make it a line graph instead of bar graph series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; // set the range of the axis double gainMax = equalizerapo_api.GAIN_MAX; System.Windows.Forms.DataVisualization.Charting.Axis yaxis = chart_filters.ChartAreas["ChartArea1"].AxisY; System.Windows.Forms.DataVisualization.Charting.Axis xaxis = chart_filters.ChartAreas["ChartArea1"].AxisX; yaxis.Interval = gainMax / 3; yaxis.Minimum = -gainMax; yaxis.Maximum = gainMax; xaxis.Minimum = 1; xaxis.Maximum = filters.Count; // make grid lines lighter xaxis.MajorGrid.LineColor = Color.LightGray; yaxis.MajorGrid.LineColor = Color.LightGray; // make graph easier to see series.BorderWidth = 3; }
/// <summary> /// Create a message to be passed to the client. /// </summary> /// <param name="type">The type of message to be passed.</param> /// <returns>Said message.</returns> public string CreateMessage(MESSAGE_TYPE type) { StringBuilder sb = new StringBuilder(); switch (type) { case MESSAGE_TYPE.FILTER_APPLY: sb.Append("apply_filter:"); sb.Append(eqAPI.IsEqualizerApplied() ? "true" : "false"); break; case MESSAGE_TYPE.FILTER_REMOVED: sb.Append("filter:removed"); break; case MESSAGE_TYPE.FILTER_ADDED: sb.Append("filter:added"); break; case MESSAGE_TYPE.FILTERS_GAIN: sb.Append("filters:"); // get the gains on the filters bool first = true; foreach (KeyValuePair <double, Filter> pair in eqAPI.GetFilters()) { Filter filter = pair.Value; if (first) { first = false; } else { sb.Append(","); } sb.Append(filter.Gain.ToString()); } break; case MESSAGE_TYPE.PAUSE: sb.Append("playback:pause"); break; case MESSAGE_TYPE.PLAY: sb.Append("playback:play"); break; case MESSAGE_TYPE.VOLUME_CHANGED: sb.Append("volume:"); sb.Append(eqAPI.PreAmp); break; case MESSAGE_TYPE.TRACK_CHANGED: sb.Append("track_changed:artist:"); sb.Append(zuneAPI.CurrentTrack.Artist); sb.Append(";trackname:"); sb.Append(zuneAPI.CurrentTrack.Title); sb.Append(";"); sb.Append(zuneAPI.IsPlaying() ? CreateMessage(MESSAGE_TYPE.PLAY) : CreateMessage(MESSAGE_TYPE.PAUSE)); sb.Append(";"); sb.Append(CreateMessage(MESSAGE_TYPE.VOLUME_CHANGED)); sb.Append(";"); sb.Append(CreateMessage(MESSAGE_TYPE.FILTERS_GAIN)); break; } return(sb.ToString()); }