/Application/GUI/Controls/Bookmark.xaml.cs

http://yet-another-music-application.googlecode.com/ · 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. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Windows;
  23. using System.Windows.Controls;
  24. using System.Windows.Data;
  25. using System.Windows.Documents;
  26. using System.Windows.Input;
  27. using System.Windows.Media;
  28. using System.Windows.Media.Imaging;
  29. using System.Windows.Navigation;
  30. using System.Windows.Shapes;
  31. namespace Stoffi
  32. {
  33. /// <summary>
  34. /// Interaction logic for Bookmark.xaml
  35. /// </summary>
  36. public partial class Bookmark : UserControl
  37. {
  38. #region Members
  39. #endregion
  40. #region Properties
  41. /// <summary>
  42. ///
  43. /// </summary>
  44. public String Text { get; set; }
  45. /// <summary>
  46. ///
  47. /// </summary>
  48. public Brush Color
  49. {
  50. get { return Box.Fill; }
  51. set { Box.Fill = value; }
  52. }
  53. /// <summary>
  54. ///
  55. /// </summary>
  56. public double Position { get; set; }
  57. #endregion
  58. #region Constructor
  59. /// <summary>
  60. /// Creates a bookmark
  61. /// </summary>
  62. public Bookmark()
  63. {
  64. U.L(LogLevel.Debug, "BOOKMARK", "Initialize");
  65. InitializeComponent();
  66. U.L(LogLevel.Debug, "BOOKMARK", "Initialized");
  67. }
  68. #endregion
  69. #region Methods
  70. #region Event handlers
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void Remove_Click(object sender, RoutedEventArgs e)
  77. {
  78. DispatchRemoveClicked();
  79. }
  80. /// <summary>
  81. ///
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="e"></param>
  85. private void Bookmark_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  86. {
  87. DispatchClicked(this.Position);
  88. }
  89. #endregion
  90. #region Dispatchers
  91. public void DispatchRemoveClicked()
  92. {
  93. if (RemoveClicked != null)
  94. {
  95. RemoveClicked(this, new EventArgs());
  96. }
  97. }
  98. public void DispatchClicked(double pos)
  99. {
  100. if (Clicked != null)
  101. {
  102. Clicked(this, new BookmarkEventArgs(pos));
  103. }
  104. }
  105. #endregion
  106. #endregion
  107. #region Events
  108. public event EventHandler RemoveClicked;
  109. public event BookmarkEventHandler Clicked;
  110. #endregion
  111. }
  112. /// <summary>
  113. /// Holds data for a bookmark event
  114. /// </summary>
  115. public class BookmarkEventArgs : EventArgs
  116. {
  117. #region Properties
  118. public double Position;
  119. #endregion
  120. #region Constructor
  121. /// <summary>
  122. ///
  123. /// </summary>
  124. /// <param name="pos"></param>
  125. public BookmarkEventArgs(double pos)
  126. {
  127. Position = pos;
  128. }
  129. #endregion
  130. }
  131. /// <summary>
  132. /// Describes the method called when en event occurs for a bookmark
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. public delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e);
  137. }