Skip to content
This repository
tree: f8ac6c5e19
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 112 lines (82 sloc) 3.804 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
Imports System.Xml
Imports System.IO
Imports System.Windows.Forms.DataVisualization.Charting

Public Class YearsListControl

  Public Event MonthSelected(ByVal Month As String)
    Private m_strPath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\lucidcode\Lightened Dream\"
  Private m_boolSearching As Boolean = False
  Private objDreamSeries As Series

  Private m_strSelectedNewCategory As String

  Public Sub LoadYears()

    If m_boolSearching Then
      Return
    End If

    m_boolSearching = True

    Try
      Dim intPos As Double = 0.5

      Dim xmlDream As New XmlDocument

      graph.Series.Clear()
      graph.ChartAreas(0).AxisX.CustomLabels.Clear()
      graph.Visible = True

      objDreamSeries = graph.Series.Add("Dreams")
      objDreamSeries.ChartType = SeriesChartType.Column
      objDreamSeries.Tag = 0
      objDreamSeries.Color = Color.FromArgb(200, 65, 140, 240)
      objDreamSeries.BorderWidth = 1
      objDreamSeries("BarLabelStyle") = "Center"


      For Each strYearFolder As String In Directory.GetDirectories(m_strPath + "Lucidity\Exercises")
        For Each strMonthFolder As String In Directory.GetDirectories(strYearFolder)

          objDreamSeries.Points.AddY(0)

          graph.ChartAreas(0).AxisX.CustomLabels.Add(intPos, intPos + 1, New DirectoryInfo(strYearFolder).Name & "-" & New DirectoryInfo(strMonthFolder).Name)
          intPos += 1

          For Each strDreamFile As String In Directory.GetFiles(strMonthFolder, "*.ld3")

            objDreamSeries.Tag += 1
            objDreamSeries.Points(objDreamSeries.Points.Count - 1).YValues(0) += 1
            objDreamSeries.Points(objDreamSeries.Points.Count - 1).ToolTip = New DirectoryInfo(strYearFolder).Name & "-" & New DirectoryInfo(strMonthFolder).Name

          Next

          Application.DoEvents()

        Next
      Next

      ' Totals
      objDreamSeries.Name += " (" & objDreamSeries.Tag & ")"

    Catch ex As Exception

    End Try

    m_boolSearching = False
  End Sub

  Private Sub graph_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles graph.MouseMove
    Try
      Dim result As HitTestResult = graph.HitTest(e.X, e.Y)

      ' Reset Data Point Attributes
      Dim point As DataPoint
      For Each objSeries As Series In graph.Series
        For Each point In objSeries.Points
          point.Color = Color.FromArgb(200, point.Color.R, point.Color.G, point.Color.B)
        Next point
      Next

      If result.ChartElementType = ChartElementType.DataPoint Or result.ChartElementType = ChartElementType.DataPointLabel Or result.ChartElementType = ChartElementType.LegendItem Then
        If result.Series.Name.StartsWith("Dreams (") Then
          Me.Cursor = Cursors.Hand
          point = result.Series.Points(result.PointIndex)
          point.Color = Color.FromArgb(255, point.Color.R, point.Color.G, point.Color.B)
        Else
          Me.Cursor = Cursors.Default
        End If
      Else
        Me.Cursor = Cursors.Default
      End If
    Catch ex As Exception

    End Try
  End Sub

  Private Sub graph_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles graph.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Left Then
      Dim result As HitTestResult = graph.HitTest(e.X, e.Y)
      Dim point As DataPoint
      If result.ChartElementType = ChartElementType.DataPoint Or result.ChartElementType = ChartElementType.DataPointLabel Or result.ChartElementType = ChartElementType.LegendItem Then
        If result.Series.Name.StartsWith("Dreams (") Then
          point = objDreamSeries.Points(result.PointIndex)
          RaiseEvent MonthSelected(point.ToolTip)
        End If
      End If
    End If
  End Sub

End Class
Something went wrong with that request. Please try again.