Permalink
Browse files

Changed the chart type on Categories with over a dozen items or sub-c…

…ategories.
  • Loading branch information...
IAmCoder committed Dec 26, 2014
1 parent 3bd03bb commit 1350c64ff3e68686bc8172b26483a51bd21eba46

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -18,8 +18,21 @@ Public Class CategoriesListControl
objSeries("PieDrawingStyle") = "SoftEdge"
lstCategories.Items.Clear()

Dim objDozenSeries As Series = graphDozen.Series("DreamSeries")
objDozenSeries.Color = Color.FromArgb(200, 65, 140, 240)
objDozenSeries.BorderWidth = 1
objSeries("BarLabelStyle") = "Right"
objDozenSeries.Points.Clear()

Dim total As Integer

For Each categoryPath As String In Directory.GetDirectories(m_strPath + "Categories")
Dim intCount As Integer = Directory.GetFiles(categoryPath, "*.ld3", SearchOption.AllDirectories).Length
Dim intCount As Integer = 0
For Each categoryFile As String In Directory.GetFiles(categoryPath, "*.ld3", SearchOption.AllDirectories)
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load(categoryFile)
intCount += xmlDoc.DocumentElement.SelectNodes("//Dream").Count
Next

Dim lstItem As New ListViewItem(New FileInfo(categoryPath).Name)
lstItem.SubItems.Add(intCount)
@@ -28,12 +41,20 @@ Public Class CategoriesListControl
If intCount > 0 Then
Dim intPoint As Integer = objSeries.Points.AddY(intCount)
objSeries.Points(intPoint).Label = New FileInfo(categoryPath).Name

Dim intPointDozen As Integer = objDozenSeries.Points.AddY(intCount)
objDozenSeries.Points(intPointDozen).Label = " " + New FileInfo(categoryPath).Name
total += 1
End If
Next

Catch ex As Exception
MessageBox.Show(ex.Message, "LightenedDream.Categories.LoadCategory()", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
If total > 12 Then
graphDozen.Visible = True
End If

Catch ex As Exception
MessageBox.Show(ex.Message, "LightenedDream.Categories.LoadCategory()", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Private Sub graph_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles graph.MouseMove
@@ -74,4 +95,39 @@ Public Class CategoriesListControl
End If
End If
End Sub

Private Sub graphDozen_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles graphDozen.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim result As HitTestResult = graphDozen.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
' Set cursor type
Me.Cursor = Cursors.Hand

' Find selected data point
point = graphDozen.Series(0).Points(result.PointIndex)
RaiseEvent CategorySelected(point.Label.Trim(" "))
End If
End If
End Sub

Private Sub graphDozen_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles graphDozen.MouseMove
Dim result As HitTestResult = graphDozen.HitTest(e.X, e.Y)

' Reset Data Point Attributes
Dim point As DataPoint
For Each objSeries As Series In graphDozen.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
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
End Sub
End Class

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -27,28 +27,70 @@ Public Class CategoryListControl

Dim hasData As Boolean = False

For Each strCatgeoryFile As String In Directory.GetFiles(CategoryFile, "*.ld3")
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load(strCatgeoryFile)
Dim objDozenSeries As Series = graphDozen.Series("DreamSeries")
objDozenSeries.Color = Color.FromArgb(200, 65, 140, 240)
objDozenSeries.BorderWidth = 1
objSeries("BarLabelStyle") = "Right"
objDozenSeries.Points.Clear()

Dim intCount As Integer = xmlDoc.DocumentElement.SelectNodes("//Dream").Count
Dim total As Integer

Dim lstItem As New ListViewItem(New FileInfo(strCatgeoryFile).Name.Replace(".ld3", ""))
lstItem.SubItems.Add(intCount)
lstCategories.Items.Add(lstItem)
For Each strCatgeoryFolder As String In Directory.GetDirectories(CategoryFile)
Dim intCount As Integer = 0
For Each strCatgeoryFile As String In Directory.GetFiles(strCatgeoryFolder, "*.ld3", SearchOption.AllDirectories)
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load(strCatgeoryFile)

If intCount > 0 Then
Dim intPoint As Integer = objSeries.Points.AddY(intCount)
intCount += xmlDoc.DocumentElement.SelectNodes("//Dream").Count
Next

Dim lstItem As New ListViewItem(New DirectoryInfo(strCatgeoryFolder).Name)
lstItem.SubItems.Add(intCount)
lstCategories.Items.Add(lstItem)

If intCount > 0 Then
Dim intPoint As Integer = objSeries.Points.AddY(intCount)
objSeries.Points(intPoint).Label = lstItem.Text
hasData = True

Dim intPointDozen As Integer = objDozenSeries.Points.AddY(intCount)
objDozenSeries.Points(intPointDozen).Label = " " + New DirectoryInfo(strCatgeoryFolder).Name
total += 1
End If
Next

For Each strCatgeoryFile As String In Directory.GetFiles(CategoryFile, "*.ld3")
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load(strCatgeoryFile)

Dim intCount As Integer = xmlDoc.DocumentElement.SelectNodes("//Dream").Count

Dim lstItem As New ListViewItem(New FileInfo(strCatgeoryFile).Name.Replace(".ld3", ""))
lstItem.SubItems.Add(intCount)
lstCategories.Items.Add(lstItem)

If intCount > 0 Then
Dim intPoint As Integer = objSeries.Points.AddY(intCount)
objSeries.Points(intPoint).Label = lstItem.Text
hasData = True
End If

Dim intPointDozen As Integer = objDozenSeries.Points.AddY(intCount)
objDozenSeries.Points(intPointDozen).Label = " " + New FileInfo(strCatgeoryFile).Name.Replace(".ld3", "")
total += 1
End If
Next

graph.Visible = hasData
graph.Visible = hasData

Catch ex As Exception
MessageBox.Show(ex.Message, "LightenedDream.Categories.LoadCategory()", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
If total > 12 Then
graphDozen.Visible = True
Else
graphDozen.Visible = False
End If

Catch ex As Exception
MessageBox.Show(ex.Message, "LightenedDream.Categories.LoadCategory()", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Public Sub Save()
@@ -96,4 +138,40 @@ Public Class CategoryListControl

End If
End Sub

Private Sub graphDozen_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles graphDozen.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim result As HitTestResult = graphDozen.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
' Set cursor type
Me.Cursor = Cursors.Hand

' Find selected data point
point = graphDozen.Series(0).Points(result.PointIndex)
RaiseEvent CategorySelected(point.Label.Trim(" "))
End If

End If
End Sub

Private Sub graphDozen_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles graphDozen.MouseMove
Dim result As HitTestResult = graphDozen.HitTest(e.X, e.Y)

' Reset Data Point Attributes
Dim point As DataPoint
For Each objSeries As Series In graphDozen.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
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
End Sub
End Class
@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("lucidcode")>
<Assembly: AssemblyProduct("Categories")>
<Assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2014")>
<Assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2015")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>
@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("3.3.4")>
<Assembly: AssemblyFileVersion("3.3.4.0")>
<Assembly: AssemblyVersion("3.3.6")>
<Assembly: AssemblyFileVersion("3.3.6.0")>
Oops, something went wrong.

0 comments on commit 1350c64

Please sign in to comment.