public void Add(RadioStation item) { Items.Add(item); this.Invalidate(); scrollBar.Maximum = Items.Count; }
//protected override void OnPaint(PaintEventArgs e) //{ //} //protected override void OnPaintBackground(PaintEventArgs pevent) //{ //} protected override void OnDrawItem(DrawItemEventArgs e) { if (Items.Count > 0) { //e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.; RadioStation station = (RadioStation)Items[e.Index]; station.Bounds = e.Bounds; Items[e.Index] = station; // Draw Background if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(Brushes.CornflowerBlue, e.Bounds); } else if (e.Index == _MouseIndex) { e.Graphics.FillRectangle(Brushes.DimGray, e.Bounds); } else { e.Graphics.FillRectangle(ItemBackground, e.Bounds); } // Draw seperator e.Graphics.DrawLine(Pens.DimGray, e.Bounds.X, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1); int textXOffset = 0; if (station.EditorsChoice) { textXOffset += 8; e.Graphics.FillRectangle(HighLight, new Rectangle(e.Bounds.X, e.Bounds.Y, 8, e.Bounds.Height)); } if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { // genre e.Graphics.DrawString(station.Genre, new Font("Segoe UI", 8f, FontStyle.Bold), Brushes.White, new Point(e.Bounds.X + 6 + textXOffset, e.Bounds.Y + 24)); } else { // genre e.Graphics.DrawString(station.Genre, new Font("Segoe UI", 8f, FontStyle.Bold), Brushes.Orange, new Point(e.Bounds.X + 6 + textXOffset, e.Bounds.Y + 24)); } // Draw text items e.Graphics.DrawString(station.Name, new Font("Segoe UI", 12f, FontStyle.Regular), TextColour, new Point(e.Bounds.X + 4 + textXOffset, e.Bounds.Y + 2)); //e.DrawFocusRectangle(); } }
private void zinListView1_ItemClicked(int index) { RadioStation selected = zinListView1.Items[index]; if (MainForm.CurrentStation == null || selected.URL != MainForm.CurrentStation.URL) { MainForm.CurrentStation = selected; MainForm.StaticForm.UpdateTitleText(); MainForm.RadioStationLogo.Start(); WebStreamPlayer.PlayStream(selected.URL); MainForm.StaticForm.UpdateThemedControls(true); HideMe(); } else { HideMe(); } }
public void ApplyStations(string rawData) { string[] rawStations = rawData.Split("\n", StringSplitOptions.RemoveEmptyEntries); List <RadioStation> stations = new List <RadioStation>(); for (int i = 0; i < rawStations.Length; i++) { stations.Add(RadioStation.FromString(rawStations[i])); } // Push loaded stations into global scope. //Stations = stations; stations.Sort(new StationSort()); //stationListBox.Items.AddRange(stations.ToArray()); zinListView1.Items.Clear(); zinListView1.AddRange(stations.ToArray()); zinListView1.Invalidate(); }
private void zinListView1_DrawItem(DrawItemState state, Graphics g, int index, Rectangle bounds) { if (zinListView1.Items.Count > 0) { RadioStation station = (RadioStation)zinListView1.Items[index]; // Draw Background if (state == DrawItemState.Selected) { g.FillRectangle(SelectedColour, bounds); } else { g.FillRectangle(ItemBackground, bounds); } int textXOffset = 0; if (station.EditorsChoice) { textXOffset += 4; g.FillRectangle(EditorsChoiceColour, new Rectangle(bounds.X, bounds.Y, 4, bounds.Height)); } SizeF s = g.MeasureString(station.Genre, SubTextFont); g.DrawString(station.Genre, SubTextFont, SubTextColour, new Point((bounds.X + bounds.Width / 2) - (int)(s.Width / 2), bounds.Y + 25)); // Draw text items s = g.MeasureString(station.Name, TextFont); g.DrawString(station.Name, TextFont, TextColour, new Point((bounds.X + bounds.Width / 2) - (int)(s.Width / 2), bounds.Y + 2)); if (!station.ValidSearch) { g.FillRectangle(new SolidBrush(Color.FromArgb(150, 255, 255, 255)), bounds); } } }