/Application/GUI/Controls/Bookmark.xaml.cs
C# | 165 lines | 83 code | 28 blank | 54 comment | 4 complexity | ed0db04a31ce20442bd0676905fc435e MD5 | raw file
1/** 2 * Bookmark.xaml.cs 3 * 4 * A bookmark shown over the track timeline. 5 * 6 * * * * * * * * * 7 * 8 * This code is part of the Stoffi Music Player Project. 9 * Visit our website at: stoffiplayer.com 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 14 * 3 of the License, or (at your option) any later version. 15 * 16 * See stoffiplayer.com/license for more information. 17 **/ 18 19using System; 20using System.Collections.Generic; 21using System.Linq; 22using System.Text; 23using System.Windows; 24using System.Windows.Controls; 25using System.Windows.Data; 26using System.Windows.Documents; 27using System.Windows.Input; 28using System.Windows.Media; 29using System.Windows.Media.Imaging; 30using System.Windows.Navigation; 31using System.Windows.Shapes; 32 33namespace Stoffi 34{ 35 /// <summary> 36 /// Interaction logic for Bookmark.xaml 37 /// </summary> 38 public partial class Bookmark : UserControl 39 { 40 #region Members 41 42 #endregion 43 44 #region Properties 45 46 /// <summary> 47 /// 48 /// </summary> 49 public String Text { get; set; } 50 51 /// <summary> 52 /// 53 /// </summary> 54 public Brush Color 55 { 56 get { return Box.Fill; } 57 set { Box.Fill = value; } 58 } 59 60 /// <summary> 61 /// 62 /// </summary> 63 public double Position { get; set; } 64 #endregion 65 66 #region Constructor 67 68 /// <summary> 69 /// Creates a bookmark 70 /// </summary> 71 public Bookmark() 72 { 73 U.L(LogLevel.Debug, "BOOKMARK", "Initialize"); 74 InitializeComponent(); 75 U.L(LogLevel.Debug, "BOOKMARK", "Initialized"); 76 } 77 78 #endregion 79 80 #region Methods 81 82 #region Event handlers 83 84 /// <summary> 85 /// 86 /// </summary> 87 /// <param name="sender"></param> 88 /// <param name="e"></param> 89 private void Remove_Click(object sender, RoutedEventArgs e) 90 { 91 DispatchRemoveClicked(); 92 } 93 94 /// <summary> 95 /// 96 /// </summary> 97 /// <param name="sender"></param> 98 /// <param name="e"></param> 99 private void Bookmark_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 100 { 101 DispatchClicked(this.Position); 102 } 103 104 #endregion 105 106 #region Dispatchers 107 108 public void DispatchRemoveClicked() 109 { 110 if (RemoveClicked != null) 111 { 112 RemoveClicked(this, new EventArgs()); 113 } 114 } 115 116 public void DispatchClicked(double pos) 117 { 118 if (Clicked != null) 119 { 120 Clicked(this, new BookmarkEventArgs(pos)); 121 } 122 } 123 124 #endregion 125 126 #endregion 127 128 #region Events 129 130 public event EventHandler RemoveClicked; 131 public event BookmarkEventHandler Clicked; 132 133 #endregion 134 } 135 136 /// <summary> 137 /// Holds data for a bookmark event 138 /// </summary> 139 public class BookmarkEventArgs : EventArgs 140 { 141 #region Properties 142 public double Position; 143 #endregion 144 145 #region Constructor 146 147 /// <summary> 148 /// 149 /// </summary> 150 /// <param name="pos"></param> 151 public BookmarkEventArgs(double pos) 152 { 153 Position = pos; 154 } 155 156 #endregion 157 } 158 159 /// <summary> 160 /// Describes the method called when en event occurs for a bookmark 161 /// </summary> 162 /// <param name="sender"></param> 163 /// <param name="e"></param> 164 public delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e); 165}