private void RenderListItemSide(TapeSide side, Graphics g, Rectangle bounds, string prefix, bool isSelected) { bool isLoaded = side == loadedTapeSide; var backBrush = isSelected ? SystemBrushes.Highlight : SystemBrushes.Window; g.FillRectangle(backBrush, new Rectangle(bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1)); int rectSize = bounds.Height - 1; var textColor = isSelected ? SystemColors.HighlightText : SystemColors.ControlText; using (SolidBrush b = new SolidBrush(side.Parent.Color)) { var rect = new Rectangle(bounds.X, bounds.Y, rectSize, rectSize); g.FillRectangle(b, rect); if (isLoaded) { rect.Inflate(-rectSize / 4, -rectSize / 4); g.FillEllipse(Brushes.Black, rect); } } TextRenderer.DrawText(g, string.Format("{0}: {1} ({2})", prefix, side.Label, Common.FormatTime((int)side.Parent.Length)), SystemFonts.DefaultFont, new Rectangle(bounds.X + rectSize, bounds.Y, bounds.Width - rectSize, bounds.Height), textColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); }
public void EjectTape() { LoadedTapeSide = null; listBox.Invalidate(); SaveList(); }
public Tape() { SideA = new TapeSide() { Parent = this }; SideB = new TapeSide() { Parent = this }; }
private void TapeManager_LoadedTapeSideChanged() { if (tapeManager.LoadedTapeSide != loadedTapeSide) { if (tapeManager.LoadedTapeSide != null) { LoadTapeSide(tapeManager.LoadedTapeSide); } else { music?.wavFile.Close(); loadedTapeSide = null; } buttonImport.Enabled = tapeManager.LoadedTapeSide != null && music.wavFile.isValid; } }
private void listBox_MouseDown(object sender, MouseEventArgs e) { TapeSide side = GetClickedItem(e); if (side != null && e.Button == MouseButtons.Right) { rightClickedTapeSide = side; bool isSideA = (side == side.Parent.SideA); toolStripMenuItemLoadA.Font = isSideA ? boldFont : normalFont; toolStripMenuItemLoadB.Font = !isSideA ? boldFont : normalFont; toolStripMenuItemLoadA.Enabled = (LoadedTapeSide == null); toolStripMenuItemLoadB.Enabled = (LoadedTapeSide == null); toolStripMenuItemDelete.Enabled = (LoadedTapeSide == null); contextMenuStrip.Show(listBox.PointToScreen(e.Location)); } }
private void LoadTapeSide(TapeSide tapeSide) { string path = Path.Combine(tapeManager.TapesDirectory, tapeSide.FilePath); if (music != null && loadedTapeSide != null) { loadedTapeSide.Position = music.GetCurrentPositionSeconds(); } mixer.RemoveSample(music); music?.wavFile.Close(); WAVFile wav = new WAVFile(); //default value in case of error try { wav = WAVFile.Load(path); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error while loading tape", MessageBoxButtons.OK, MessageBoxIcon.Error); } music = new SoundMixer.Sample(wav, false, false, false, 0.2f, 1.0f); mixer.AddSample(music); mixer.SetRecordingSample(music); loadedTapeSide = tapeSide; music.SetCurrentPositionSeconds(tapeSide.Position); State = PlayerState.STOPPED; cassetteControl.LoadedTapeSide = tapeSide; cassetteButtons.Enabled = true; counter.IgnoreNextSetPosition(); cassetteClose.UpdatePlayback(true); }
private void ToolStripMenuItemLoadB_Click(object sender, EventArgs e) { LoadedTapeSide = rightClickedTapeSide.Parent.SideB; }
private void listBox_MouseDoubleClick(object sender, MouseEventArgs e) { TapeSide side = GetClickedItem(e); LoadedTapeSide = side; }